babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713
  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/ShadersInclude/packingFunctions" {
  11294. /** @hidden */
  11295. export var packingFunctions: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  11302. /** @hidden */
  11303. export var shadowMapPixelShader: {
  11304. name: string;
  11305. shader: string;
  11306. };
  11307. }
  11308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11309. /** @hidden */
  11310. export var bonesDeclaration: {
  11311. name: string;
  11312. shader: string;
  11313. };
  11314. }
  11315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11316. /** @hidden */
  11317. export var morphTargetsVertexGlobalDeclaration: {
  11318. name: string;
  11319. shader: string;
  11320. };
  11321. }
  11322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11323. /** @hidden */
  11324. export var morphTargetsVertexDeclaration: {
  11325. name: string;
  11326. shader: string;
  11327. };
  11328. }
  11329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11330. /** @hidden */
  11331. export var instancesDeclaration: {
  11332. name: string;
  11333. shader: string;
  11334. };
  11335. }
  11336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11337. /** @hidden */
  11338. export var helperFunctions: {
  11339. name: string;
  11340. shader: string;
  11341. };
  11342. }
  11343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11344. /** @hidden */
  11345. export var morphTargetsVertex: {
  11346. name: string;
  11347. shader: string;
  11348. };
  11349. }
  11350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11351. /** @hidden */
  11352. export var instancesVertex: {
  11353. name: string;
  11354. shader: string;
  11355. };
  11356. }
  11357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11358. /** @hidden */
  11359. export var bonesVertex: {
  11360. name: string;
  11361. shader: string;
  11362. };
  11363. }
  11364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11373. /** @hidden */
  11374. export var shadowMapVertexShader: {
  11375. name: string;
  11376. shader: string;
  11377. };
  11378. }
  11379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11380. /** @hidden */
  11381. export var depthBoxBlurPixelShader: {
  11382. name: string;
  11383. shader: string;
  11384. };
  11385. }
  11386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11387. import { Nullable } from "babylonjs/types";
  11388. import { Scene } from "babylonjs/scene";
  11389. import { Matrix } from "babylonjs/Maths/math";
  11390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11392. import { Mesh } from "babylonjs/Meshes/mesh";
  11393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11395. import { Effect } from "babylonjs/Materials/effect";
  11396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11397. import "babylonjs/Shaders/shadowMap.fragment";
  11398. import "babylonjs/Shaders/shadowMap.vertex";
  11399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11400. import { Observable } from "babylonjs/Misc/observable";
  11401. /**
  11402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11403. */
  11404. export interface ICustomShaderOptions {
  11405. /**
  11406. * Gets or sets the custom shader name to use
  11407. */
  11408. shaderName: string;
  11409. /**
  11410. * The list of attribute names used in the shader
  11411. */
  11412. attributes?: string[];
  11413. /**
  11414. * The list of unifrom names used in the shader
  11415. */
  11416. uniforms?: string[];
  11417. /**
  11418. * The list of sampler names used in the shader
  11419. */
  11420. samplers?: string[];
  11421. /**
  11422. * The list of defines used in the shader
  11423. */
  11424. defines?: string[];
  11425. }
  11426. /**
  11427. * Interface to implement to create a shadow generator compatible with BJS.
  11428. */
  11429. export interface IShadowGenerator {
  11430. /**
  11431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11432. * @returns The render target texture if present otherwise, null
  11433. */
  11434. getShadowMap(): Nullable<RenderTargetTexture>;
  11435. /**
  11436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11437. * @returns The render target texture if the shadow map is present otherwise, null
  11438. */
  11439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11440. /**
  11441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11442. * @param subMesh The submesh we want to render in the shadow map
  11443. * @param useInstances Defines wether will draw in the map using instances
  11444. * @returns true if ready otherwise, false
  11445. */
  11446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11447. /**
  11448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11449. * @param defines Defines of the material we want to update
  11450. * @param lightIndex Index of the light in the enabled light list of the material
  11451. */
  11452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11453. /**
  11454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11455. * defined in the generator but impacting the effect).
  11456. * It implies the unifroms available on the materials are the standard BJS ones.
  11457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11458. * @param effect The effect we are binfing the information for
  11459. */
  11460. bindShadowLight(lightIndex: string, effect: Effect): void;
  11461. /**
  11462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11463. * (eq to shadow prjection matrix * light transform matrix)
  11464. * @returns The transform matrix used to create the shadow map
  11465. */
  11466. getTransformMatrix(): Matrix;
  11467. /**
  11468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11469. * Cube and 2D textures for instance.
  11470. */
  11471. recreateShadowMap(): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param onCompiled Callback triggered at the and of the effects compilation
  11475. * @param options Sets of optional options forcing the compilation with different modes
  11476. */
  11477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): void;
  11480. /**
  11481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11482. * @param options Sets of optional options forcing the compilation with different modes
  11483. * @returns A promise that resolves when the compilation completes
  11484. */
  11485. forceCompilationAsync(options?: Partial<{
  11486. useInstances: boolean;
  11487. }>): Promise<void>;
  11488. /**
  11489. * Serializes the shadow generator setup to a json object.
  11490. * @returns The serialized JSON object
  11491. */
  11492. serialize(): any;
  11493. /**
  11494. * Disposes the Shadow map and related Textures and effects.
  11495. */
  11496. dispose(): void;
  11497. }
  11498. /**
  11499. * Default implementation IShadowGenerator.
  11500. * This is the main object responsible of generating shadows in the framework.
  11501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11502. */
  11503. export class ShadowGenerator implements IShadowGenerator {
  11504. /**
  11505. * Shadow generator mode None: no filtering applied.
  11506. */
  11507. static readonly FILTER_NONE: number;
  11508. /**
  11509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11511. */
  11512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11513. /**
  11514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11516. */
  11517. static readonly FILTER_POISSONSAMPLING: number;
  11518. /**
  11519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11521. */
  11522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11523. /**
  11524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11525. * edge artifacts on steep falloff.
  11526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11527. */
  11528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11529. /**
  11530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11531. * edge artifacts on steep falloff.
  11532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11533. */
  11534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11535. /**
  11536. * Shadow generator mode PCF: Percentage Closer Filtering
  11537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11539. */
  11540. static readonly FILTER_PCF: number;
  11541. /**
  11542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11544. * Contact Hardening
  11545. */
  11546. static readonly FILTER_PCSS: number;
  11547. /**
  11548. * Reserved for PCF and PCSS
  11549. * Highest Quality.
  11550. *
  11551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11552. *
  11553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11554. */
  11555. static readonly QUALITY_HIGH: number;
  11556. /**
  11557. * Reserved for PCF and PCSS
  11558. * Good tradeoff for quality/perf cross devices
  11559. *
  11560. * Execute PCF on a 3*3 kernel.
  11561. *
  11562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11563. */
  11564. static readonly QUALITY_MEDIUM: number;
  11565. /**
  11566. * Reserved for PCF and PCSS
  11567. * The lowest quality but the fastest.
  11568. *
  11569. * Execute PCF on a 1*1 kernel.
  11570. *
  11571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11572. */
  11573. static readonly QUALITY_LOW: number;
  11574. /** Gets or sets the custom shader name to use */
  11575. customShaderOptions: ICustomShaderOptions;
  11576. /**
  11577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11578. */
  11579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11580. /**
  11581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11582. */
  11583. onAfterShadowMapRenderObservable: Observable<Effect>;
  11584. /**
  11585. * Observable triggered before a mesh is rendered in the shadow map.
  11586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11587. */
  11588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11589. /**
  11590. * Observable triggered after a mesh is rendered in the shadow map.
  11591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11592. */
  11593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11594. private _bias;
  11595. /**
  11596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11597. */
  11598. /**
  11599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11600. */
  11601. bias: number;
  11602. private _normalBias;
  11603. /**
  11604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11605. */
  11606. /**
  11607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11608. */
  11609. normalBias: number;
  11610. private _blurBoxOffset;
  11611. /**
  11612. * Gets the blur box offset: offset applied during the blur pass.
  11613. * Only useful if useKernelBlur = false
  11614. */
  11615. /**
  11616. * Sets the blur box offset: offset applied during the blur pass.
  11617. * Only useful if useKernelBlur = false
  11618. */
  11619. blurBoxOffset: number;
  11620. private _blurScale;
  11621. /**
  11622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11623. * 2 means half of the size.
  11624. */
  11625. /**
  11626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11627. * 2 means half of the size.
  11628. */
  11629. blurScale: number;
  11630. private _blurKernel;
  11631. /**
  11632. * Gets the blur kernel: kernel size of the blur pass.
  11633. * Only useful if useKernelBlur = true
  11634. */
  11635. /**
  11636. * Sets the blur kernel: kernel size of the blur pass.
  11637. * Only useful if useKernelBlur = true
  11638. */
  11639. blurKernel: number;
  11640. private _useKernelBlur;
  11641. /**
  11642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11644. */
  11645. /**
  11646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11648. */
  11649. useKernelBlur: boolean;
  11650. private _depthScale;
  11651. /**
  11652. * Gets the depth scale used in ESM mode.
  11653. */
  11654. /**
  11655. * Sets the depth scale used in ESM mode.
  11656. * This can override the scale stored on the light.
  11657. */
  11658. depthScale: number;
  11659. private _filter;
  11660. /**
  11661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11663. */
  11664. /**
  11665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11667. */
  11668. filter: number;
  11669. /**
  11670. * Gets if the current filter is set to Poisson Sampling.
  11671. */
  11672. /**
  11673. * Sets the current filter to Poisson Sampling.
  11674. */
  11675. usePoissonSampling: boolean;
  11676. /**
  11677. * Gets if the current filter is set to ESM.
  11678. */
  11679. /**
  11680. * Sets the current filter is to ESM.
  11681. */
  11682. useExponentialShadowMap: boolean;
  11683. /**
  11684. * Gets if the current filter is set to filtered ESM.
  11685. */
  11686. /**
  11687. * Gets if the current filter is set to filtered ESM.
  11688. */
  11689. useBlurExponentialShadowMap: boolean;
  11690. /**
  11691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11692. * exponential to prevent steep falloff artifacts).
  11693. */
  11694. /**
  11695. * Sets the current filter to "close ESM" (using the inverse of the
  11696. * exponential to prevent steep falloff artifacts).
  11697. */
  11698. useCloseExponentialShadowMap: boolean;
  11699. /**
  11700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11701. * exponential to prevent steep falloff artifacts).
  11702. */
  11703. /**
  11704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11705. * exponential to prevent steep falloff artifacts).
  11706. */
  11707. useBlurCloseExponentialShadowMap: boolean;
  11708. /**
  11709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11710. */
  11711. /**
  11712. * Sets the current filter to "PCF" (percentage closer filtering).
  11713. */
  11714. usePercentageCloserFiltering: boolean;
  11715. private _filteringQuality;
  11716. /**
  11717. * Gets the PCF or PCSS Quality.
  11718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11719. */
  11720. /**
  11721. * Sets the PCF or PCSS Quality.
  11722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11723. */
  11724. filteringQuality: number;
  11725. /**
  11726. * Gets if the current filter is set to "PCSS" (contact hardening).
  11727. */
  11728. /**
  11729. * Sets the current filter to "PCSS" (contact hardening).
  11730. */
  11731. useContactHardeningShadow: boolean;
  11732. private _contactHardeningLightSizeUVRatio;
  11733. /**
  11734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11735. * Using a ratio helps keeping shape stability independently of the map size.
  11736. *
  11737. * It does not account for the light projection as it was having too much
  11738. * instability during the light setup or during light position changes.
  11739. *
  11740. * Only valid if useContactHardeningShadow is true.
  11741. */
  11742. /**
  11743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11744. * Using a ratio helps keeping shape stability independently of the map size.
  11745. *
  11746. * It does not account for the light projection as it was having too much
  11747. * instability during the light setup or during light position changes.
  11748. *
  11749. * Only valid if useContactHardeningShadow is true.
  11750. */
  11751. contactHardeningLightSizeUVRatio: number;
  11752. private _darkness;
  11753. /** Gets or sets the actual darkness of a shadow */
  11754. darkness: number;
  11755. /**
  11756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11757. * 0 means strongest and 1 would means no shadow.
  11758. * @returns the darkness.
  11759. */
  11760. getDarkness(): number;
  11761. /**
  11762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11764. * @returns the shadow generator allowing fluent coding.
  11765. */
  11766. setDarkness(darkness: number): ShadowGenerator;
  11767. private _transparencyShadow;
  11768. /** Gets or sets the ability to have transparent shadow */
  11769. transparencyShadow: boolean;
  11770. /**
  11771. * Sets the ability to have transparent shadow (boolean).
  11772. * @param transparent True if transparent else False
  11773. * @returns the shadow generator allowing fluent coding
  11774. */
  11775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11776. private _shadowMap;
  11777. private _shadowMap2;
  11778. /**
  11779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11780. * @returns The render target texture if present otherwise, null
  11781. */
  11782. getShadowMap(): Nullable<RenderTargetTexture>;
  11783. /**
  11784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11785. * @returns The render target texture if the shadow map is present otherwise, null
  11786. */
  11787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11788. /**
  11789. * Gets the class name of that object
  11790. * @returns "ShadowGenerator"
  11791. */
  11792. getClassName(): string;
  11793. /**
  11794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11795. * @param mesh Mesh to add
  11796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11797. * @returns the Shadow Generator itself
  11798. */
  11799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11800. /**
  11801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11802. * @param mesh Mesh to remove
  11803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11804. * @returns the Shadow Generator itself
  11805. */
  11806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11807. /**
  11808. * Controls the extent to which the shadows fade out at the edge of the frustum
  11809. * Used only by directionals and spots
  11810. */
  11811. frustumEdgeFalloff: number;
  11812. private _light;
  11813. /**
  11814. * Returns the associated light object.
  11815. * @returns the light generating the shadow
  11816. */
  11817. getLight(): IShadowLight;
  11818. /**
  11819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11821. * It might on the other hand introduce peter panning.
  11822. */
  11823. forceBackFacesOnly: boolean;
  11824. private _scene;
  11825. private _lightDirection;
  11826. private _effect;
  11827. private _viewMatrix;
  11828. private _projectionMatrix;
  11829. private _transformMatrix;
  11830. private _cachedPosition;
  11831. private _cachedDirection;
  11832. private _cachedDefines;
  11833. private _currentRenderID;
  11834. private _boxBlurPostprocess;
  11835. private _kernelBlurXPostprocess;
  11836. private _kernelBlurYPostprocess;
  11837. private _blurPostProcesses;
  11838. private _mapSize;
  11839. private _currentFaceIndex;
  11840. private _currentFaceIndexCache;
  11841. private _textureType;
  11842. private _defaultTextureMatrix;
  11843. /** @hidden */
  11844. static _SceneComponentInitialization: (scene: Scene) => void;
  11845. /**
  11846. * Creates a ShadowGenerator object.
  11847. * A ShadowGenerator is the required tool to use the shadows.
  11848. * Each light casting shadows needs to use its own ShadowGenerator.
  11849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11851. * @param light The light object generating the shadows.
  11852. * @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.
  11853. */
  11854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11855. private _initializeGenerator;
  11856. private _initializeShadowMap;
  11857. private _initializeBlurRTTAndPostProcesses;
  11858. private _renderForShadowMap;
  11859. private _renderSubMeshForShadowMap;
  11860. private _applyFilterValues;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param onCompiled Callback triggered at the and of the effects compilation
  11864. * @param options Sets of optional options forcing the compilation with different modes
  11865. */
  11866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): void;
  11869. /**
  11870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11871. * @param options Sets of optional options forcing the compilation with different modes
  11872. * @returns A promise that resolves when the compilation completes
  11873. */
  11874. forceCompilationAsync(options?: Partial<{
  11875. useInstances: boolean;
  11876. }>): Promise<void>;
  11877. /**
  11878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11879. * @param subMesh The submesh we want to render in the shadow map
  11880. * @param useInstances Defines wether will draw in the map using instances
  11881. * @returns true if ready otherwise, false
  11882. */
  11883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11884. /**
  11885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11886. * @param defines Defines of the material we want to update
  11887. * @param lightIndex Index of the light in the enabled light list of the material
  11888. */
  11889. prepareDefines(defines: any, lightIndex: number): void;
  11890. /**
  11891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11892. * defined in the generator but impacting the effect).
  11893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11894. * @param effect The effect we are binfing the information for
  11895. */
  11896. bindShadowLight(lightIndex: string, effect: Effect): void;
  11897. /**
  11898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11899. * (eq to shadow prjection matrix * light transform matrix)
  11900. * @returns The transform matrix used to create the shadow map
  11901. */
  11902. getTransformMatrix(): Matrix;
  11903. /**
  11904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11905. * Cube and 2D textures for instance.
  11906. */
  11907. recreateShadowMap(): void;
  11908. private _disposeBlurPostProcesses;
  11909. private _disposeRTTandPostProcesses;
  11910. /**
  11911. * Disposes the ShadowGenerator.
  11912. * Returns nothing.
  11913. */
  11914. dispose(): void;
  11915. /**
  11916. * Serializes the shadow generator setup to a json object.
  11917. * @returns The serialized JSON object
  11918. */
  11919. serialize(): any;
  11920. /**
  11921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11922. * @param parsedShadowGenerator The JSON object to parse
  11923. * @param scene The scene to create the shadow map for
  11924. * @returns The parsed shadow generator
  11925. */
  11926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11927. }
  11928. }
  11929. declare module "babylonjs/Lights/light" {
  11930. import { Nullable } from "babylonjs/types";
  11931. import { Scene } from "babylonjs/scene";
  11932. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11933. import { Node } from "babylonjs/node";
  11934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11935. import { Effect } from "babylonjs/Materials/effect";
  11936. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11937. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11938. /**
  11939. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11940. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11941. * 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.
  11942. */
  11943. export abstract class Light extends Node {
  11944. /**
  11945. * Falloff Default: light is falling off following the material specification:
  11946. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11947. */
  11948. static readonly FALLOFF_DEFAULT: number;
  11949. /**
  11950. * Falloff Physical: light is falling off following the inverse squared distance law.
  11951. */
  11952. static readonly FALLOFF_PHYSICAL: number;
  11953. /**
  11954. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11955. * to enhance interoperability with other engines.
  11956. */
  11957. static readonly FALLOFF_GLTF: number;
  11958. /**
  11959. * Falloff Standard: light is falling off like in the standard material
  11960. * to enhance interoperability with other materials.
  11961. */
  11962. static readonly FALLOFF_STANDARD: number;
  11963. /**
  11964. * If every light affecting the material is in this lightmapMode,
  11965. * material.lightmapTexture adds or multiplies
  11966. * (depends on material.useLightmapAsShadowmap)
  11967. * after every other light calculations.
  11968. */
  11969. static readonly LIGHTMAP_DEFAULT: number;
  11970. /**
  11971. * material.lightmapTexture as only diffuse lighting from this light
  11972. * adds only specular lighting from this light
  11973. * adds dynamic shadows
  11974. */
  11975. static readonly LIGHTMAP_SPECULAR: number;
  11976. /**
  11977. * material.lightmapTexture as only lighting
  11978. * no light calculation from this light
  11979. * only adds dynamic shadows from this light
  11980. */
  11981. static readonly LIGHTMAP_SHADOWSONLY: number;
  11982. /**
  11983. * Each light type uses the default quantity according to its type:
  11984. * point/spot lights use luminous intensity
  11985. * directional lights use illuminance
  11986. */
  11987. static readonly INTENSITYMODE_AUTOMATIC: number;
  11988. /**
  11989. * lumen (lm)
  11990. */
  11991. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11992. /**
  11993. * candela (lm/sr)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11996. /**
  11997. * lux (lm/m^2)
  11998. */
  11999. static readonly INTENSITYMODE_ILLUMINANCE: number;
  12000. /**
  12001. * nit (cd/m^2)
  12002. */
  12003. static readonly INTENSITYMODE_LUMINANCE: number;
  12004. /**
  12005. * Light type const id of the point light.
  12006. */
  12007. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12008. /**
  12009. * Light type const id of the directional light.
  12010. */
  12011. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12012. /**
  12013. * Light type const id of the spot light.
  12014. */
  12015. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12016. /**
  12017. * Light type const id of the hemispheric light.
  12018. */
  12019. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12020. /**
  12021. * Diffuse gives the basic color to an object.
  12022. */
  12023. diffuse: Color3;
  12024. /**
  12025. * Specular produces a highlight color on an object.
  12026. * Note: This is note affecting PBR materials.
  12027. */
  12028. specular: Color3;
  12029. /**
  12030. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12031. * falling off base on range or angle.
  12032. * This can be set to any values in Light.FALLOFF_x.
  12033. *
  12034. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12035. * other types of materials.
  12036. */
  12037. falloffType: number;
  12038. /**
  12039. * Strength of the light.
  12040. * Note: By default it is define in the framework own unit.
  12041. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12042. */
  12043. intensity: number;
  12044. private _range;
  12045. protected _inverseSquaredRange: number;
  12046. /**
  12047. * Defines how far from the source the light is impacting in scene units.
  12048. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12049. */
  12050. /**
  12051. * Defines how far from the source the light is impacting in scene units.
  12052. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12053. */
  12054. range: number;
  12055. /**
  12056. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12057. * of light.
  12058. */
  12059. private _photometricScale;
  12060. private _intensityMode;
  12061. /**
  12062. * Gets the photometric scale used to interpret the intensity.
  12063. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12064. */
  12065. /**
  12066. * Sets the photometric scale used to interpret the intensity.
  12067. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12068. */
  12069. intensityMode: number;
  12070. private _radius;
  12071. /**
  12072. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12073. */
  12074. /**
  12075. * sets the light radius used by PBR Materials to simulate soft area lights.
  12076. */
  12077. radius: number;
  12078. private _renderPriority;
  12079. /**
  12080. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12081. * exceeding the number allowed of the materials.
  12082. */
  12083. renderPriority: number;
  12084. private _shadowEnabled;
  12085. /**
  12086. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12087. * the current shadow generator.
  12088. */
  12089. /**
  12090. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12091. * the current shadow generator.
  12092. */
  12093. shadowEnabled: boolean;
  12094. private _includedOnlyMeshes;
  12095. /**
  12096. * Gets the only meshes impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the only meshes impacted by this light.
  12100. */
  12101. includedOnlyMeshes: AbstractMesh[];
  12102. private _excludedMeshes;
  12103. /**
  12104. * Gets the meshes not impacted by this light.
  12105. */
  12106. /**
  12107. * Sets the meshes not impacted by this light.
  12108. */
  12109. excludedMeshes: AbstractMesh[];
  12110. private _excludeWithLayerMask;
  12111. /**
  12112. * Gets the layer id use to find what meshes are not impacted by the light.
  12113. * Inactive if 0
  12114. */
  12115. /**
  12116. * Sets the layer id use to find what meshes are not impacted by the light.
  12117. * Inactive if 0
  12118. */
  12119. excludeWithLayerMask: number;
  12120. private _includeOnlyWithLayerMask;
  12121. /**
  12122. * Gets the layer id use to find what meshes are impacted by the light.
  12123. * Inactive if 0
  12124. */
  12125. /**
  12126. * Sets the layer id use to find what meshes are impacted by the light.
  12127. * Inactive if 0
  12128. */
  12129. includeOnlyWithLayerMask: number;
  12130. private _lightmapMode;
  12131. /**
  12132. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12133. */
  12134. /**
  12135. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12136. */
  12137. lightmapMode: number;
  12138. /**
  12139. * Shadow generator associted to the light.
  12140. * @hidden Internal use only.
  12141. */
  12142. _shadowGenerator: Nullable<IShadowGenerator>;
  12143. /**
  12144. * @hidden Internal use only.
  12145. */
  12146. _excludedMeshesIds: string[];
  12147. /**
  12148. * @hidden Internal use only.
  12149. */
  12150. _includedOnlyMeshesIds: string[];
  12151. /**
  12152. * The current light unifom buffer.
  12153. * @hidden Internal use only.
  12154. */
  12155. _uniformBuffer: UniformBuffer;
  12156. /**
  12157. * Creates a Light object in the scene.
  12158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12159. * @param name The firendly name of the light
  12160. * @param scene The scene the light belongs too
  12161. */
  12162. constructor(name: string, scene: Scene);
  12163. protected abstract _buildUniformLayout(): void;
  12164. /**
  12165. * Sets the passed Effect "effect" with the Light information.
  12166. * @param effect The effect to update
  12167. * @param lightIndex The index of the light in the effect to update
  12168. * @returns The light
  12169. */
  12170. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12171. /**
  12172. * Returns the string "Light".
  12173. * @returns the class name
  12174. */
  12175. getClassName(): string;
  12176. /** @hidden */
  12177. readonly _isLight: boolean;
  12178. /**
  12179. * Converts the light information to a readable string for debug purpose.
  12180. * @param fullDetails Supports for multiple levels of logging within scene loading
  12181. * @returns the human readable light info
  12182. */
  12183. toString(fullDetails?: boolean): string;
  12184. /** @hidden */
  12185. protected _syncParentEnabledState(): void;
  12186. /**
  12187. * Set the enabled state of this node.
  12188. * @param value - the new enabled state
  12189. */
  12190. setEnabled(value: boolean): void;
  12191. /**
  12192. * Returns the Light associated shadow generator if any.
  12193. * @return the associated shadow generator.
  12194. */
  12195. getShadowGenerator(): Nullable<IShadowGenerator>;
  12196. /**
  12197. * Returns a Vector3, the absolute light position in the World.
  12198. * @returns the world space position of the light
  12199. */
  12200. getAbsolutePosition(): Vector3;
  12201. /**
  12202. * Specifies if the light will affect the passed mesh.
  12203. * @param mesh The mesh to test against the light
  12204. * @return true the mesh is affected otherwise, false.
  12205. */
  12206. canAffectMesh(mesh: AbstractMesh): boolean;
  12207. /**
  12208. * Sort function to order lights for rendering.
  12209. * @param a First Light object to compare to second.
  12210. * @param b Second Light object to compare first.
  12211. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12212. */
  12213. static CompareLightsPriority(a: Light, b: Light): number;
  12214. /**
  12215. * Releases resources associated with this node.
  12216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12218. */
  12219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12220. /**
  12221. * Returns the light type ID (integer).
  12222. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12223. */
  12224. getTypeID(): number;
  12225. /**
  12226. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12227. * @returns the scaled intensity in intensity mode unit
  12228. */
  12229. getScaledIntensity(): number;
  12230. /**
  12231. * Returns a new Light object, named "name", from the current one.
  12232. * @param name The name of the cloned light
  12233. * @returns the new created light
  12234. */
  12235. clone(name: string): Nullable<Light>;
  12236. /**
  12237. * Serializes the current light into a Serialization object.
  12238. * @returns the serialized object.
  12239. */
  12240. serialize(): any;
  12241. /**
  12242. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12243. * This new light is named "name" and added to the passed scene.
  12244. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12245. * @param name The friendly name of the light
  12246. * @param scene The scene the new light will belong to
  12247. * @returns the constructor function
  12248. */
  12249. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12250. /**
  12251. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12252. * @param parsedLight The JSON representation of the light
  12253. * @param scene The scene to create the parsed light in
  12254. * @returns the created light after parsing
  12255. */
  12256. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12257. private _hookArrayForExcluded;
  12258. private _hookArrayForIncludedOnly;
  12259. private _resyncMeshes;
  12260. /**
  12261. * Forces the meshes to update their light related information in their rendering used effects
  12262. * @hidden Internal Use Only
  12263. */
  12264. _markMeshesAsLightDirty(): void;
  12265. /**
  12266. * Recomputes the cached photometric scale if needed.
  12267. */
  12268. private _computePhotometricScale;
  12269. /**
  12270. * Returns the Photometric Scale according to the light type and intensity mode.
  12271. */
  12272. private _getPhotometricScale;
  12273. /**
  12274. * Reorder the light in the scene according to their defined priority.
  12275. * @hidden Internal Use Only
  12276. */
  12277. _reorderLightsInScene(): void;
  12278. /**
  12279. * Prepares the list of defines specific to the light type.
  12280. * @param defines the list of defines
  12281. * @param lightIndex defines the index of the light for the effect
  12282. */
  12283. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12284. }
  12285. }
  12286. declare module "babylonjs/Meshes/instancedMesh" {
  12287. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12288. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12289. import { Camera } from "babylonjs/Cameras/camera";
  12290. import { Node } from "babylonjs/node";
  12291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12292. import { Mesh } from "babylonjs/Meshes/mesh";
  12293. import { Material } from "babylonjs/Materials/material";
  12294. import { Skeleton } from "babylonjs/Bones/skeleton";
  12295. import { Light } from "babylonjs/Lights/light";
  12296. /**
  12297. * Creates an instance based on a source mesh.
  12298. */
  12299. export class InstancedMesh extends AbstractMesh {
  12300. private _sourceMesh;
  12301. private _currentLOD;
  12302. /** @hidden */
  12303. _indexInSourceMeshInstanceArray: number;
  12304. constructor(name: string, source: Mesh);
  12305. /**
  12306. * Returns the string "InstancedMesh".
  12307. */
  12308. getClassName(): string;
  12309. /** Gets the list of lights affecting that mesh */
  12310. readonly lightSources: Light[];
  12311. _resyncLightSources(): void;
  12312. _resyncLighSource(light: Light): void;
  12313. _removeLightSource(light: Light): void;
  12314. /**
  12315. * If the source mesh receives shadows
  12316. */
  12317. readonly receiveShadows: boolean;
  12318. /**
  12319. * The material of the source mesh
  12320. */
  12321. readonly material: Nullable<Material>;
  12322. /**
  12323. * Visibility of the source mesh
  12324. */
  12325. readonly visibility: number;
  12326. /**
  12327. * Skeleton of the source mesh
  12328. */
  12329. readonly skeleton: Nullable<Skeleton>;
  12330. /**
  12331. * Rendering ground id of the source mesh
  12332. */
  12333. renderingGroupId: number;
  12334. /**
  12335. * Returns the total number of vertices (integer).
  12336. */
  12337. getTotalVertices(): number;
  12338. /**
  12339. * Returns a positive integer : the total number of indices in this mesh geometry.
  12340. * @returns the numner of indices or zero if the mesh has no geometry.
  12341. */
  12342. getTotalIndices(): number;
  12343. /**
  12344. * The source mesh of the instance
  12345. */
  12346. readonly sourceMesh: Mesh;
  12347. /**
  12348. * Is this node ready to be used/rendered
  12349. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12350. * @return {boolean} is it ready
  12351. */
  12352. isReady(completeCheck?: boolean): boolean;
  12353. /**
  12354. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12355. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12356. * @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.
  12357. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12358. */
  12359. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12360. /**
  12361. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12362. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12363. * The `data` are either a numeric array either a Float32Array.
  12364. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12365. * 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).
  12366. * Note that a new underlying VertexBuffer object is created each call.
  12367. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12368. *
  12369. * Possible `kind` values :
  12370. * - VertexBuffer.PositionKind
  12371. * - VertexBuffer.UVKind
  12372. * - VertexBuffer.UV2Kind
  12373. * - VertexBuffer.UV3Kind
  12374. * - VertexBuffer.UV4Kind
  12375. * - VertexBuffer.UV5Kind
  12376. * - VertexBuffer.UV6Kind
  12377. * - VertexBuffer.ColorKind
  12378. * - VertexBuffer.MatricesIndicesKind
  12379. * - VertexBuffer.MatricesIndicesExtraKind
  12380. * - VertexBuffer.MatricesWeightsKind
  12381. * - VertexBuffer.MatricesWeightsExtraKind
  12382. *
  12383. * Returns the Mesh.
  12384. */
  12385. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12386. /**
  12387. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12388. * If the mesh has no geometry, it is simply returned as it is.
  12389. * The `data` are either a numeric array either a Float32Array.
  12390. * No new underlying VertexBuffer object is created.
  12391. * 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.
  12392. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12393. *
  12394. * Possible `kind` values :
  12395. * - VertexBuffer.PositionKind
  12396. * - VertexBuffer.UVKind
  12397. * - VertexBuffer.UV2Kind
  12398. * - VertexBuffer.UV3Kind
  12399. * - VertexBuffer.UV4Kind
  12400. * - VertexBuffer.UV5Kind
  12401. * - VertexBuffer.UV6Kind
  12402. * - VertexBuffer.ColorKind
  12403. * - VertexBuffer.MatricesIndicesKind
  12404. * - VertexBuffer.MatricesIndicesExtraKind
  12405. * - VertexBuffer.MatricesWeightsKind
  12406. * - VertexBuffer.MatricesWeightsExtraKind
  12407. *
  12408. * Returns the Mesh.
  12409. */
  12410. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12411. /**
  12412. * Sets the mesh indices.
  12413. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12414. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12415. * This method creates a new index buffer each call.
  12416. * Returns the Mesh.
  12417. */
  12418. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12419. /**
  12420. * Boolean : True if the mesh owns the requested kind of data.
  12421. */
  12422. isVerticesDataPresent(kind: string): boolean;
  12423. /**
  12424. * Returns an array of indices (IndicesArray).
  12425. */
  12426. getIndices(): Nullable<IndicesArray>;
  12427. readonly _positions: Nullable<Vector3[]>;
  12428. /**
  12429. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12430. * This means the mesh underlying bounding box and sphere are recomputed.
  12431. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12432. * @returns the current mesh
  12433. */
  12434. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12435. /** @hidden */
  12436. _preActivate(): InstancedMesh;
  12437. /** @hidden */
  12438. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12439. /** @hidden */
  12440. _postActivate(): void;
  12441. getWorldMatrix(): Matrix;
  12442. readonly isAnInstance: boolean;
  12443. /**
  12444. * Returns the current associated LOD AbstractMesh.
  12445. */
  12446. getLOD(camera: Camera): AbstractMesh;
  12447. /** @hidden */
  12448. _syncSubMeshes(): InstancedMesh;
  12449. /** @hidden */
  12450. _generatePointsArray(): boolean;
  12451. /**
  12452. * Creates a new InstancedMesh from the current mesh.
  12453. * - name (string) : the cloned mesh name
  12454. * - newParent (optional Node) : the optional Node to parent the clone to.
  12455. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12456. *
  12457. * Returns the clone.
  12458. */
  12459. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12460. /**
  12461. * Disposes the InstancedMesh.
  12462. * Returns nothing.
  12463. */
  12464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12465. }
  12466. }
  12467. declare module "babylonjs/Materials/shaderMaterial" {
  12468. import { Scene } from "babylonjs/scene";
  12469. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12471. import { Mesh } from "babylonjs/Meshes/mesh";
  12472. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12474. import { Texture } from "babylonjs/Materials/Textures/texture";
  12475. import { Material } from "babylonjs/Materials/material";
  12476. /**
  12477. * Defines the options associated with the creation of a shader material.
  12478. */
  12479. export interface IShaderMaterialOptions {
  12480. /**
  12481. * Does the material work in alpha blend mode
  12482. */
  12483. needAlphaBlending: boolean;
  12484. /**
  12485. * Does the material work in alpha test mode
  12486. */
  12487. needAlphaTesting: boolean;
  12488. /**
  12489. * The list of attribute names used in the shader
  12490. */
  12491. attributes: string[];
  12492. /**
  12493. * The list of unifrom names used in the shader
  12494. */
  12495. uniforms: string[];
  12496. /**
  12497. * The list of UBO names used in the shader
  12498. */
  12499. uniformBuffers: string[];
  12500. /**
  12501. * The list of sampler names used in the shader
  12502. */
  12503. samplers: string[];
  12504. /**
  12505. * The list of defines used in the shader
  12506. */
  12507. defines: string[];
  12508. }
  12509. /**
  12510. * 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.
  12511. *
  12512. * This returned material effects how the mesh will look based on the code in the shaders.
  12513. *
  12514. * @see http://doc.babylonjs.com/how_to/shader_material
  12515. */
  12516. export class ShaderMaterial extends Material {
  12517. private _shaderPath;
  12518. private _options;
  12519. private _textures;
  12520. private _textureArrays;
  12521. private _floats;
  12522. private _ints;
  12523. private _floatsArrays;
  12524. private _colors3;
  12525. private _colors3Arrays;
  12526. private _colors4;
  12527. private _colors4Arrays;
  12528. private _vectors2;
  12529. private _vectors3;
  12530. private _vectors4;
  12531. private _matrices;
  12532. private _matrices3x3;
  12533. private _matrices2x2;
  12534. private _vectors2Arrays;
  12535. private _vectors3Arrays;
  12536. private _vectors4Arrays;
  12537. private _cachedWorldViewMatrix;
  12538. private _cachedWorldViewProjectionMatrix;
  12539. private _renderId;
  12540. /**
  12541. * Instantiate a new shader material.
  12542. * 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.
  12543. * This returned material effects how the mesh will look based on the code in the shaders.
  12544. * @see http://doc.babylonjs.com/how_to/shader_material
  12545. * @param name Define the name of the material in the scene
  12546. * @param scene Define the scene the material belongs to
  12547. * @param shaderPath Defines the route to the shader code in one of three ways:
  12548. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12549. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12550. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12551. * @param options Define the options used to create the shader
  12552. */
  12553. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12554. /**
  12555. * Gets the options used to compile the shader.
  12556. * They can be modified to trigger a new compilation
  12557. */
  12558. readonly options: IShaderMaterialOptions;
  12559. /**
  12560. * Gets the current class name of the material e.g. "ShaderMaterial"
  12561. * Mainly use in serialization.
  12562. * @returns the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Specifies if the material will require alpha blending
  12567. * @returns a boolean specifying if alpha blending is needed
  12568. */
  12569. needAlphaBlending(): boolean;
  12570. /**
  12571. * Specifies if this material should be rendered in alpha test mode
  12572. * @returns a boolean specifying if an alpha test is needed.
  12573. */
  12574. needAlphaTesting(): boolean;
  12575. private _checkUniform;
  12576. /**
  12577. * Set a texture in the shader.
  12578. * @param name Define the name of the uniform samplers as defined in the shader
  12579. * @param texture Define the texture to bind to this sampler
  12580. * @return the material itself allowing "fluent" like uniform updates
  12581. */
  12582. setTexture(name: string, texture: Texture): ShaderMaterial;
  12583. /**
  12584. * Set a texture array in the shader.
  12585. * @param name Define the name of the uniform sampler array as defined in the shader
  12586. * @param textures Define the list of textures to bind to this sampler
  12587. * @return the material itself allowing "fluent" like uniform updates
  12588. */
  12589. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12590. /**
  12591. * Set a float in the shader.
  12592. * @param name Define the name of the uniform as defined in the shader
  12593. * @param value Define the value to give to the uniform
  12594. * @return the material itself allowing "fluent" like uniform updates
  12595. */
  12596. setFloat(name: string, value: number): ShaderMaterial;
  12597. /**
  12598. * Set a int in the shader.
  12599. * @param name Define the name of the uniform as defined in the shader
  12600. * @param value Define the value to give to the uniform
  12601. * @return the material itself allowing "fluent" like uniform updates
  12602. */
  12603. setInt(name: string, value: number): ShaderMaterial;
  12604. /**
  12605. * Set an array of floats in the shader.
  12606. * @param name Define the name of the uniform as defined in the shader
  12607. * @param value Define the value to give to the uniform
  12608. * @return the material itself allowing "fluent" like uniform updates
  12609. */
  12610. setFloats(name: string, value: number[]): ShaderMaterial;
  12611. /**
  12612. * Set a vec3 in the shader from a Color3.
  12613. * @param name Define the name of the uniform as defined in the shader
  12614. * @param value Define the value to give to the uniform
  12615. * @return the material itself allowing "fluent" like uniform updates
  12616. */
  12617. setColor3(name: string, value: Color3): ShaderMaterial;
  12618. /**
  12619. * Set a vec3 array in the shader from a Color3 array.
  12620. * @param name Define the name of the uniform as defined in the shader
  12621. * @param value Define the value to give to the uniform
  12622. * @return the material itself allowing "fluent" like uniform updates
  12623. */
  12624. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12625. /**
  12626. * Set a vec4 in the shader from a Color4.
  12627. * @param name Define the name of the uniform as defined in the shader
  12628. * @param value Define the value to give to the uniform
  12629. * @return the material itself allowing "fluent" like uniform updates
  12630. */
  12631. setColor4(name: string, value: Color4): ShaderMaterial;
  12632. /**
  12633. * Set a vec4 array in the shader from a Color4 array.
  12634. * @param name Define the name of the uniform as defined in the shader
  12635. * @param value Define the value to give to the uniform
  12636. * @return the material itself allowing "fluent" like uniform updates
  12637. */
  12638. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12639. /**
  12640. * Set a vec2 in the shader from a Vector2.
  12641. * @param name Define the name of the uniform as defined in the shader
  12642. * @param value Define the value to give to the uniform
  12643. * @return the material itself allowing "fluent" like uniform updates
  12644. */
  12645. setVector2(name: string, value: Vector2): ShaderMaterial;
  12646. /**
  12647. * Set a vec3 in the shader from a Vector3.
  12648. * @param name Define the name of the uniform as defined in the shader
  12649. * @param value Define the value to give to the uniform
  12650. * @return the material itself allowing "fluent" like uniform updates
  12651. */
  12652. setVector3(name: string, value: Vector3): ShaderMaterial;
  12653. /**
  12654. * Set a vec4 in the shader from a Vector4.
  12655. * @param name Define the name of the uniform as defined in the shader
  12656. * @param value Define the value to give to the uniform
  12657. * @return the material itself allowing "fluent" like uniform updates
  12658. */
  12659. setVector4(name: string, value: Vector4): ShaderMaterial;
  12660. /**
  12661. * Set a mat4 in the shader from a Matrix.
  12662. * @param name Define the name of the uniform as defined in the shader
  12663. * @param value Define the value to give to the uniform
  12664. * @return the material itself allowing "fluent" like uniform updates
  12665. */
  12666. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12667. /**
  12668. * Set a mat3 in the shader from a Float32Array.
  12669. * @param name Define the name of the uniform as defined in the shader
  12670. * @param value Define the value to give to the uniform
  12671. * @return the material itself allowing "fluent" like uniform updates
  12672. */
  12673. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12674. /**
  12675. * Set a mat2 in the shader from a Float32Array.
  12676. * @param name Define the name of the uniform as defined in the shader
  12677. * @param value Define the value to give to the uniform
  12678. * @return the material itself allowing "fluent" like uniform updates
  12679. */
  12680. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12681. /**
  12682. * Set a vec2 array in the shader from a number array.
  12683. * @param name Define the name of the uniform as defined in the shader
  12684. * @param value Define the value to give to the uniform
  12685. * @return the material itself allowing "fluent" like uniform updates
  12686. */
  12687. setArray2(name: string, value: number[]): ShaderMaterial;
  12688. /**
  12689. * Set a vec3 array in the shader from a number array.
  12690. * @param name Define the name of the uniform as defined in the shader
  12691. * @param value Define the value to give to the uniform
  12692. * @return the material itself allowing "fluent" like uniform updates
  12693. */
  12694. setArray3(name: string, value: number[]): ShaderMaterial;
  12695. /**
  12696. * Set a vec4 array in the shader from a number array.
  12697. * @param name Define the name of the uniform as defined in the shader
  12698. * @param value Define the value to give to the uniform
  12699. * @return the material itself allowing "fluent" like uniform updates
  12700. */
  12701. setArray4(name: string, value: number[]): ShaderMaterial;
  12702. private _checkCache;
  12703. /**
  12704. * Specifies that the submesh is ready to be used
  12705. * @param mesh defines the mesh to check
  12706. * @param subMesh defines which submesh to check
  12707. * @param useInstances specifies that instances should be used
  12708. * @returns a boolean indicating that the submesh is ready or not
  12709. */
  12710. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12711. /**
  12712. * Checks if the material is ready to render the requested mesh
  12713. * @param mesh Define the mesh to render
  12714. * @param useInstances Define whether or not the material is used with instances
  12715. * @returns true if ready, otherwise false
  12716. */
  12717. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12718. /**
  12719. * Binds the world matrix to the material
  12720. * @param world defines the world transformation matrix
  12721. */
  12722. bindOnlyWorldMatrix(world: Matrix): void;
  12723. /**
  12724. * Binds the material to the mesh
  12725. * @param world defines the world transformation matrix
  12726. * @param mesh defines the mesh to bind the material to
  12727. */
  12728. bind(world: Matrix, mesh?: Mesh): void;
  12729. /**
  12730. * Gets the active textures from the material
  12731. * @returns an array of textures
  12732. */
  12733. getActiveTextures(): BaseTexture[];
  12734. /**
  12735. * Specifies if the material uses a texture
  12736. * @param texture defines the texture to check against the material
  12737. * @returns a boolean specifying if the material uses the texture
  12738. */
  12739. hasTexture(texture: BaseTexture): boolean;
  12740. /**
  12741. * Makes a duplicate of the material, and gives it a new name
  12742. * @param name defines the new name for the duplicated material
  12743. * @returns the cloned material
  12744. */
  12745. clone(name: string): ShaderMaterial;
  12746. /**
  12747. * Disposes the material
  12748. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12749. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12750. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12751. */
  12752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12753. /**
  12754. * Serializes this material in a JSON representation
  12755. * @returns the serialized material object
  12756. */
  12757. serialize(): any;
  12758. /**
  12759. * Creates a shader material from parsed shader material data
  12760. * @param source defines the JSON represnetation of the material
  12761. * @param scene defines the hosting scene
  12762. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12763. * @returns a new material
  12764. */
  12765. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12766. }
  12767. }
  12768. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12769. /** @hidden */
  12770. export var clipPlaneFragmentDeclaration: {
  12771. name: string;
  12772. shader: string;
  12773. };
  12774. }
  12775. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12776. /** @hidden */
  12777. export var clipPlaneFragment: {
  12778. name: string;
  12779. shader: string;
  12780. };
  12781. }
  12782. declare module "babylonjs/Shaders/color.fragment" {
  12783. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12785. /** @hidden */
  12786. export var colorPixelShader: {
  12787. name: string;
  12788. shader: string;
  12789. };
  12790. }
  12791. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12792. /** @hidden */
  12793. export var clipPlaneVertexDeclaration: {
  12794. name: string;
  12795. shader: string;
  12796. };
  12797. }
  12798. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12799. /** @hidden */
  12800. export var clipPlaneVertex: {
  12801. name: string;
  12802. shader: string;
  12803. };
  12804. }
  12805. declare module "babylonjs/Shaders/color.vertex" {
  12806. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12807. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12808. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12809. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12810. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12811. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12812. /** @hidden */
  12813. export var colorVertexShader: {
  12814. name: string;
  12815. shader: string;
  12816. };
  12817. }
  12818. declare module "babylonjs/Meshes/linesMesh" {
  12819. import { Nullable } from "babylonjs/types";
  12820. import { Scene } from "babylonjs/scene";
  12821. import { Color3 } from "babylonjs/Maths/math";
  12822. import { Node } from "babylonjs/node";
  12823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12824. import { Mesh } from "babylonjs/Meshes/mesh";
  12825. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12826. import { Effect } from "babylonjs/Materials/effect";
  12827. import { Material } from "babylonjs/Materials/material";
  12828. import "babylonjs/Shaders/color.fragment";
  12829. import "babylonjs/Shaders/color.vertex";
  12830. /**
  12831. * Line mesh
  12832. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12833. */
  12834. export class LinesMesh extends Mesh {
  12835. /**
  12836. * If vertex color should be applied to the mesh
  12837. */
  12838. readonly useVertexColor?: boolean | undefined;
  12839. /**
  12840. * If vertex alpha should be applied to the mesh
  12841. */
  12842. readonly useVertexAlpha?: boolean | undefined;
  12843. /**
  12844. * Color of the line (Default: White)
  12845. */
  12846. color: Color3;
  12847. /**
  12848. * Alpha of the line (Default: 1)
  12849. */
  12850. alpha: number;
  12851. /**
  12852. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12853. * This margin is expressed in world space coordinates, so its value may vary.
  12854. * Default value is 0.1
  12855. */
  12856. intersectionThreshold: number;
  12857. private _colorShader;
  12858. private color4;
  12859. /**
  12860. * Creates a new LinesMesh
  12861. * @param name defines the name
  12862. * @param scene defines the hosting scene
  12863. * @param parent defines the parent mesh if any
  12864. * @param source defines the optional source LinesMesh used to clone data from
  12865. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12866. * When false, achieved by calling a clone(), also passing False.
  12867. * This will make creation of children, recursive.
  12868. * @param useVertexColor defines if this LinesMesh supports vertex color
  12869. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12870. */
  12871. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12872. /**
  12873. * If vertex color should be applied to the mesh
  12874. */
  12875. useVertexColor?: boolean | undefined,
  12876. /**
  12877. * If vertex alpha should be applied to the mesh
  12878. */
  12879. useVertexAlpha?: boolean | undefined);
  12880. private _addClipPlaneDefine;
  12881. private _removeClipPlaneDefine;
  12882. isReady(): boolean;
  12883. /**
  12884. * Returns the string "LineMesh"
  12885. */
  12886. getClassName(): string;
  12887. /**
  12888. * @hidden
  12889. */
  12890. /**
  12891. * @hidden
  12892. */
  12893. material: Material;
  12894. /**
  12895. * @hidden
  12896. */
  12897. readonly checkCollisions: boolean;
  12898. /** @hidden */
  12899. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12900. /** @hidden */
  12901. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12902. /**
  12903. * Disposes of the line mesh
  12904. * @param doNotRecurse If children should be disposed
  12905. */
  12906. dispose(doNotRecurse?: boolean): void;
  12907. /**
  12908. * Returns a new LineMesh object cloned from the current one.
  12909. */
  12910. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12911. /**
  12912. * Creates a new InstancedLinesMesh object from the mesh model.
  12913. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12914. * @param name defines the name of the new instance
  12915. * @returns a new InstancedLinesMesh
  12916. */
  12917. createInstance(name: string): InstancedLinesMesh;
  12918. }
  12919. /**
  12920. * Creates an instance based on a source LinesMesh
  12921. */
  12922. export class InstancedLinesMesh extends InstancedMesh {
  12923. /**
  12924. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12925. * This margin is expressed in world space coordinates, so its value may vary.
  12926. * Initilized with the intersectionThreshold value of the source LinesMesh
  12927. */
  12928. intersectionThreshold: number;
  12929. constructor(name: string, source: LinesMesh);
  12930. /**
  12931. * Returns the string "InstancedLinesMesh".
  12932. */
  12933. getClassName(): string;
  12934. }
  12935. }
  12936. declare module "babylonjs/Meshes/groundMesh" {
  12937. import { Scene } from "babylonjs/scene";
  12938. import { Vector3 } from "babylonjs/Maths/math";
  12939. import { Mesh } from "babylonjs/Meshes/mesh";
  12940. /**
  12941. * Mesh representing the gorund
  12942. */
  12943. export class GroundMesh extends Mesh {
  12944. /** If octree should be generated */
  12945. generateOctree: boolean;
  12946. private _heightQuads;
  12947. /** @hidden */
  12948. _subdivisionsX: number;
  12949. /** @hidden */
  12950. _subdivisionsY: number;
  12951. /** @hidden */
  12952. _width: number;
  12953. /** @hidden */
  12954. _height: number;
  12955. /** @hidden */
  12956. _minX: number;
  12957. /** @hidden */
  12958. _maxX: number;
  12959. /** @hidden */
  12960. _minZ: number;
  12961. /** @hidden */
  12962. _maxZ: number;
  12963. constructor(name: string, scene: Scene);
  12964. /**
  12965. * "GroundMesh"
  12966. * @returns "GroundMesh"
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * The minimum of x and y subdivisions
  12971. */
  12972. readonly subdivisions: number;
  12973. /**
  12974. * X subdivisions
  12975. */
  12976. readonly subdivisionsX: number;
  12977. /**
  12978. * Y subdivisions
  12979. */
  12980. readonly subdivisionsY: number;
  12981. /**
  12982. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12983. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12984. * @param chunksCount the number of subdivisions for x and y
  12985. * @param octreeBlocksSize (Default: 32)
  12986. */
  12987. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12988. /**
  12989. * Returns a height (y) value in the Worl system :
  12990. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns the ground y position if (x, z) are outside the ground surface.
  12994. */
  12995. getHeightAtCoordinates(x: number, z: number): number;
  12996. /**
  12997. * Returns a normalized vector (Vector3) orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * @param x x coordinate
  13000. * @param z z coordinate
  13001. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  13002. */
  13003. getNormalAtCoordinates(x: number, z: number): Vector3;
  13004. /**
  13005. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  13006. * at the ground coordinates (x, z) expressed in the World system.
  13007. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13008. * @param x x coordinate
  13009. * @param z z coordinate
  13010. * @param ref vector to store the result
  13011. * @returns the GroundMesh.
  13012. */
  13013. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13014. /**
  13015. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13016. * if the ground has been updated.
  13017. * This can be used in the render loop.
  13018. * @returns the GroundMesh.
  13019. */
  13020. updateCoordinateHeights(): GroundMesh;
  13021. private _getFacetAt;
  13022. private _initHeightQuads;
  13023. private _computeHeightQuads;
  13024. /**
  13025. * Serializes this ground mesh
  13026. * @param serializationObject object to write serialization to
  13027. */
  13028. serialize(serializationObject: any): void;
  13029. /**
  13030. * Parses a serialized ground mesh
  13031. * @param parsedMesh the serialized mesh
  13032. * @param scene the scene to create the ground mesh in
  13033. * @returns the created ground mesh
  13034. */
  13035. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13036. }
  13037. }
  13038. declare module "babylonjs/Physics/physicsJoint" {
  13039. import { Vector3 } from "babylonjs/Maths/math";
  13040. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13041. /**
  13042. * Interface for Physics-Joint data
  13043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13044. */
  13045. export interface PhysicsJointData {
  13046. /**
  13047. * The main pivot of the joint
  13048. */
  13049. mainPivot?: Vector3;
  13050. /**
  13051. * The connected pivot of the joint
  13052. */
  13053. connectedPivot?: Vector3;
  13054. /**
  13055. * The main axis of the joint
  13056. */
  13057. mainAxis?: Vector3;
  13058. /**
  13059. * The connected axis of the joint
  13060. */
  13061. connectedAxis?: Vector3;
  13062. /**
  13063. * The collision of the joint
  13064. */
  13065. collision?: boolean;
  13066. /**
  13067. * Native Oimo/Cannon/Energy data
  13068. */
  13069. nativeParams?: any;
  13070. }
  13071. /**
  13072. * This is a holder class for the physics joint created by the physics plugin
  13073. * It holds a set of functions to control the underlying joint
  13074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13075. */
  13076. export class PhysicsJoint {
  13077. /**
  13078. * The type of the physics joint
  13079. */
  13080. type: number;
  13081. /**
  13082. * The data for the physics joint
  13083. */
  13084. jointData: PhysicsJointData;
  13085. private _physicsJoint;
  13086. protected _physicsPlugin: IPhysicsEnginePlugin;
  13087. /**
  13088. * Initializes the physics joint
  13089. * @param type The type of the physics joint
  13090. * @param jointData The data for the physics joint
  13091. */
  13092. constructor(
  13093. /**
  13094. * The type of the physics joint
  13095. */
  13096. type: number,
  13097. /**
  13098. * The data for the physics joint
  13099. */
  13100. jointData: PhysicsJointData);
  13101. /**
  13102. * Gets the physics joint
  13103. */
  13104. /**
  13105. * Sets the physics joint
  13106. */
  13107. physicsJoint: any;
  13108. /**
  13109. * Sets the physics plugin
  13110. */
  13111. physicsPlugin: IPhysicsEnginePlugin;
  13112. /**
  13113. * Execute a function that is physics-plugin specific.
  13114. * @param {Function} func the function that will be executed.
  13115. * It accepts two parameters: the physics world and the physics joint
  13116. */
  13117. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13118. /**
  13119. * Distance-Joint type
  13120. */
  13121. static DistanceJoint: number;
  13122. /**
  13123. * Hinge-Joint type
  13124. */
  13125. static HingeJoint: number;
  13126. /**
  13127. * Ball-and-Socket joint type
  13128. */
  13129. static BallAndSocketJoint: number;
  13130. /**
  13131. * Wheel-Joint type
  13132. */
  13133. static WheelJoint: number;
  13134. /**
  13135. * Slider-Joint type
  13136. */
  13137. static SliderJoint: number;
  13138. /**
  13139. * Prismatic-Joint type
  13140. */
  13141. static PrismaticJoint: number;
  13142. /**
  13143. * Universal-Joint type
  13144. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13145. */
  13146. static UniversalJoint: number;
  13147. /**
  13148. * Hinge-Joint 2 type
  13149. */
  13150. static Hinge2Joint: number;
  13151. /**
  13152. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13153. */
  13154. static PointToPointJoint: number;
  13155. /**
  13156. * Spring-Joint type
  13157. */
  13158. static SpringJoint: number;
  13159. /**
  13160. * Lock-Joint type
  13161. */
  13162. static LockJoint: number;
  13163. }
  13164. /**
  13165. * A class representing a physics distance joint
  13166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13167. */
  13168. export class DistanceJoint extends PhysicsJoint {
  13169. /**
  13170. *
  13171. * @param jointData The data for the Distance-Joint
  13172. */
  13173. constructor(jointData: DistanceJointData);
  13174. /**
  13175. * Update the predefined distance.
  13176. * @param maxDistance The maximum preferred distance
  13177. * @param minDistance The minimum preferred distance
  13178. */
  13179. updateDistance(maxDistance: number, minDistance?: number): void;
  13180. }
  13181. /**
  13182. * Represents a Motor-Enabled Joint
  13183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13184. */
  13185. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13186. /**
  13187. * Initializes the Motor-Enabled Joint
  13188. * @param type The type of the joint
  13189. * @param jointData The physica joint data for the joint
  13190. */
  13191. constructor(type: number, jointData: PhysicsJointData);
  13192. /**
  13193. * Set the motor values.
  13194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13195. * @param force the force to apply
  13196. * @param maxForce max force for this motor.
  13197. */
  13198. setMotor(force?: number, maxForce?: number): void;
  13199. /**
  13200. * Set the motor's limits.
  13201. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13202. * @param upperLimit The upper limit of the motor
  13203. * @param lowerLimit The lower limit of the motor
  13204. */
  13205. setLimit(upperLimit: number, lowerLimit?: number): void;
  13206. }
  13207. /**
  13208. * This class represents a single physics Hinge-Joint
  13209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13210. */
  13211. export class HingeJoint extends MotorEnabledJoint {
  13212. /**
  13213. * Initializes the Hinge-Joint
  13214. * @param jointData The joint data for the Hinge-Joint
  13215. */
  13216. constructor(jointData: PhysicsJointData);
  13217. /**
  13218. * Set the motor values.
  13219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13220. * @param {number} force the force to apply
  13221. * @param {number} maxForce max force for this motor.
  13222. */
  13223. setMotor(force?: number, maxForce?: number): void;
  13224. /**
  13225. * Set the motor's limits.
  13226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13227. * @param upperLimit The upper limit of the motor
  13228. * @param lowerLimit The lower limit of the motor
  13229. */
  13230. setLimit(upperLimit: number, lowerLimit?: number): void;
  13231. }
  13232. /**
  13233. * This class represents a dual hinge physics joint (same as wheel joint)
  13234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13235. */
  13236. export class Hinge2Joint extends MotorEnabledJoint {
  13237. /**
  13238. * Initializes the Hinge2-Joint
  13239. * @param jointData The joint data for the Hinge2-Joint
  13240. */
  13241. constructor(jointData: PhysicsJointData);
  13242. /**
  13243. * Set the motor values.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} targetSpeed the speed the motor is to reach
  13246. * @param {number} maxForce max force for this motor.
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13250. /**
  13251. * Set the motor limits.
  13252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13253. * @param {number} upperLimit the upper limit
  13254. * @param {number} lowerLimit lower limit
  13255. * @param {motorIndex} the motor's index, 0 or 1.
  13256. */
  13257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13258. }
  13259. /**
  13260. * Interface for a motor enabled joint
  13261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13262. */
  13263. export interface IMotorEnabledJoint {
  13264. /**
  13265. * Physics joint
  13266. */
  13267. physicsJoint: any;
  13268. /**
  13269. * Sets the motor of the motor-enabled joint
  13270. * @param force The force of the motor
  13271. * @param maxForce The maximum force of the motor
  13272. * @param motorIndex The index of the motor
  13273. */
  13274. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13275. /**
  13276. * Sets the limit of the motor
  13277. * @param upperLimit The upper limit of the motor
  13278. * @param lowerLimit The lower limit of the motor
  13279. * @param motorIndex The index of the motor
  13280. */
  13281. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13282. }
  13283. /**
  13284. * Joint data for a Distance-Joint
  13285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13286. */
  13287. export interface DistanceJointData extends PhysicsJointData {
  13288. /**
  13289. * Max distance the 2 joint objects can be apart
  13290. */
  13291. maxDistance: number;
  13292. }
  13293. /**
  13294. * Joint data from a spring joint
  13295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13296. */
  13297. export interface SpringJointData extends PhysicsJointData {
  13298. /**
  13299. * Length of the spring
  13300. */
  13301. length: number;
  13302. /**
  13303. * Stiffness of the spring
  13304. */
  13305. stiffness: number;
  13306. /**
  13307. * Damping of the spring
  13308. */
  13309. damping: number;
  13310. /** this callback will be called when applying the force to the impostors. */
  13311. forceApplicationCallback: () => void;
  13312. }
  13313. }
  13314. declare module "babylonjs/Physics/physicsRaycastResult" {
  13315. import { Vector3 } from "babylonjs/Maths/math";
  13316. /**
  13317. * Holds the data for the raycast result
  13318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13319. */
  13320. export class PhysicsRaycastResult {
  13321. private _hasHit;
  13322. private _hitDistance;
  13323. private _hitNormalWorld;
  13324. private _hitPointWorld;
  13325. private _rayFromWorld;
  13326. private _rayToWorld;
  13327. /**
  13328. * Gets if there was a hit
  13329. */
  13330. readonly hasHit: boolean;
  13331. /**
  13332. * Gets the distance from the hit
  13333. */
  13334. readonly hitDistance: number;
  13335. /**
  13336. * Gets the hit normal/direction in the world
  13337. */
  13338. readonly hitNormalWorld: Vector3;
  13339. /**
  13340. * Gets the hit point in the world
  13341. */
  13342. readonly hitPointWorld: Vector3;
  13343. /**
  13344. * Gets the ray "start point" of the ray in the world
  13345. */
  13346. readonly rayFromWorld: Vector3;
  13347. /**
  13348. * Gets the ray "end point" of the ray in the world
  13349. */
  13350. readonly rayToWorld: Vector3;
  13351. /**
  13352. * Sets the hit data (normal & point in world space)
  13353. * @param hitNormalWorld defines the normal in world space
  13354. * @param hitPointWorld defines the point in world space
  13355. */
  13356. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13357. /**
  13358. * Sets the distance from the start point to the hit point
  13359. * @param distance
  13360. */
  13361. setHitDistance(distance: number): void;
  13362. /**
  13363. * Calculates the distance manually
  13364. */
  13365. calculateHitDistance(): void;
  13366. /**
  13367. * Resets all the values to default
  13368. * @param from The from point on world space
  13369. * @param to The to point on world space
  13370. */
  13371. reset(from?: Vector3, to?: Vector3): void;
  13372. }
  13373. /**
  13374. * Interface for the size containing width and height
  13375. */
  13376. interface IXYZ {
  13377. /**
  13378. * X
  13379. */
  13380. x: number;
  13381. /**
  13382. * Y
  13383. */
  13384. y: number;
  13385. /**
  13386. * Z
  13387. */
  13388. z: number;
  13389. }
  13390. }
  13391. declare module "babylonjs/Physics/IPhysicsEngine" {
  13392. import { Nullable } from "babylonjs/types";
  13393. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13395. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13396. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13397. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13398. /**
  13399. * Interface used to describe a physics joint
  13400. */
  13401. export interface PhysicsImpostorJoint {
  13402. /** Defines the main impostor to which the joint is linked */
  13403. mainImpostor: PhysicsImpostor;
  13404. /** Defines the impostor that is connected to the main impostor using this joint */
  13405. connectedImpostor: PhysicsImpostor;
  13406. /** Defines the joint itself */
  13407. joint: PhysicsJoint;
  13408. }
  13409. /** @hidden */
  13410. export interface IPhysicsEnginePlugin {
  13411. world: any;
  13412. name: string;
  13413. setGravity(gravity: Vector3): void;
  13414. setTimeStep(timeStep: number): void;
  13415. getTimeStep(): number;
  13416. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13417. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13418. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13419. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13420. removePhysicsBody(impostor: PhysicsImpostor): void;
  13421. generateJoint(joint: PhysicsImpostorJoint): void;
  13422. removeJoint(joint: PhysicsImpostorJoint): void;
  13423. isSupported(): boolean;
  13424. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13425. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13427. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13428. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13429. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13430. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13431. getBodyMass(impostor: PhysicsImpostor): number;
  13432. getBodyFriction(impostor: PhysicsImpostor): number;
  13433. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13434. getBodyRestitution(impostor: PhysicsImpostor): number;
  13435. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13436. getBodyPressure?(impostor: PhysicsImpostor): number;
  13437. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13438. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13439. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13440. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13441. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13442. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13443. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13444. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13445. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13446. sleepBody(impostor: PhysicsImpostor): void;
  13447. wakeUpBody(impostor: PhysicsImpostor): void;
  13448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13449. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13450. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13451. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13452. getRadius(impostor: PhysicsImpostor): number;
  13453. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13454. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13455. dispose(): void;
  13456. }
  13457. /**
  13458. * Interface used to define a physics engine
  13459. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13460. */
  13461. export interface IPhysicsEngine {
  13462. /**
  13463. * Gets the gravity vector used by the simulation
  13464. */
  13465. gravity: Vector3;
  13466. /**
  13467. * Sets the gravity vector used by the simulation
  13468. * @param gravity defines the gravity vector to use
  13469. */
  13470. setGravity(gravity: Vector3): void;
  13471. /**
  13472. * Set the time step of the physics engine.
  13473. * Default is 1/60.
  13474. * To slow it down, enter 1/600 for example.
  13475. * To speed it up, 1/30
  13476. * @param newTimeStep the new timestep to apply to this world.
  13477. */
  13478. setTimeStep(newTimeStep: number): void;
  13479. /**
  13480. * Get the time step of the physics engine.
  13481. * @returns the current time step
  13482. */
  13483. getTimeStep(): number;
  13484. /**
  13485. * Release all resources
  13486. */
  13487. dispose(): void;
  13488. /**
  13489. * Gets the name of the current physics plugin
  13490. * @returns the name of the plugin
  13491. */
  13492. getPhysicsPluginName(): string;
  13493. /**
  13494. * Adding a new impostor for the impostor tracking.
  13495. * This will be done by the impostor itself.
  13496. * @param impostor the impostor to add
  13497. */
  13498. addImpostor(impostor: PhysicsImpostor): void;
  13499. /**
  13500. * Remove an impostor from the engine.
  13501. * This impostor and its mesh will not longer be updated by the physics engine.
  13502. * @param impostor the impostor to remove
  13503. */
  13504. removeImpostor(impostor: PhysicsImpostor): void;
  13505. /**
  13506. * Add a joint to the physics engine
  13507. * @param mainImpostor defines the main impostor to which the joint is added.
  13508. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13509. * @param joint defines the joint that will connect both impostors.
  13510. */
  13511. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13512. /**
  13513. * Removes a joint from the simulation
  13514. * @param mainImpostor defines the impostor used with the joint
  13515. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13516. * @param joint defines the joint to remove
  13517. */
  13518. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13519. /**
  13520. * Gets the current plugin used to run the simulation
  13521. * @returns current plugin
  13522. */
  13523. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13524. /**
  13525. * Gets the list of physic impostors
  13526. * @returns an array of PhysicsImpostor
  13527. */
  13528. getImpostors(): Array<PhysicsImpostor>;
  13529. /**
  13530. * Gets the impostor for a physics enabled object
  13531. * @param object defines the object impersonated by the impostor
  13532. * @returns the PhysicsImpostor or null if not found
  13533. */
  13534. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13535. /**
  13536. * Gets the impostor for a physics body object
  13537. * @param body defines physics body used by the impostor
  13538. * @returns the PhysicsImpostor or null if not found
  13539. */
  13540. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13541. /**
  13542. * Does a raycast in the physics world
  13543. * @param from when should the ray start?
  13544. * @param to when should the ray end?
  13545. * @returns PhysicsRaycastResult
  13546. */
  13547. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13548. /**
  13549. * Called by the scene. No need to call it.
  13550. * @param delta defines the timespam between frames
  13551. */
  13552. _step(delta: number): void;
  13553. }
  13554. }
  13555. declare module "babylonjs/Physics/physicsImpostor" {
  13556. import { Nullable, IndicesArray } from "babylonjs/types";
  13557. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13558. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13560. import { Scene } from "babylonjs/scene";
  13561. import { Bone } from "babylonjs/Bones/bone";
  13562. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13563. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13564. /**
  13565. * The interface for the physics imposter parameters
  13566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13567. */
  13568. export interface PhysicsImpostorParameters {
  13569. /**
  13570. * The mass of the physics imposter
  13571. */
  13572. mass: number;
  13573. /**
  13574. * The friction of the physics imposter
  13575. */
  13576. friction?: number;
  13577. /**
  13578. * The coefficient of restitution of the physics imposter
  13579. */
  13580. restitution?: number;
  13581. /**
  13582. * The native options of the physics imposter
  13583. */
  13584. nativeOptions?: any;
  13585. /**
  13586. * Specifies if the parent should be ignored
  13587. */
  13588. ignoreParent?: boolean;
  13589. /**
  13590. * Specifies if bi-directional transformations should be disabled
  13591. */
  13592. disableBidirectionalTransformation?: boolean;
  13593. /**
  13594. * The pressure inside the physics imposter, soft object only
  13595. */
  13596. pressure?: number;
  13597. /**
  13598. * The stiffness the physics imposter, soft object only
  13599. */
  13600. stiffness?: number;
  13601. /**
  13602. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13603. */
  13604. velocityIterations?: number;
  13605. /**
  13606. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13607. */
  13608. positionIterations?: number;
  13609. /**
  13610. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13611. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13612. * Add to fix multiple points
  13613. */
  13614. fixedPoints?: number;
  13615. /**
  13616. * The collision margin around a soft object
  13617. */
  13618. margin?: number;
  13619. /**
  13620. * The collision margin around a soft object
  13621. */
  13622. damping?: number;
  13623. /**
  13624. * The path for a rope based on an extrusion
  13625. */
  13626. path?: any;
  13627. /**
  13628. * The shape of an extrusion used for a rope based on an extrusion
  13629. */
  13630. shape?: any;
  13631. }
  13632. /**
  13633. * Interface for a physics-enabled object
  13634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13635. */
  13636. export interface IPhysicsEnabledObject {
  13637. /**
  13638. * The position of the physics-enabled object
  13639. */
  13640. position: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotationQuaternion: Nullable<Quaternion>;
  13645. /**
  13646. * The scale of the physics-enabled object
  13647. */
  13648. scaling: Vector3;
  13649. /**
  13650. * The rotation of the physics-enabled object
  13651. */
  13652. rotation?: Vector3;
  13653. /**
  13654. * The parent of the physics-enabled object
  13655. */
  13656. parent?: any;
  13657. /**
  13658. * The bounding info of the physics-enabled object
  13659. * @returns The bounding info of the physics-enabled object
  13660. */
  13661. getBoundingInfo(): BoundingInfo;
  13662. /**
  13663. * Computes the world matrix
  13664. * @param force Specifies if the world matrix should be computed by force
  13665. * @returns A world matrix
  13666. */
  13667. computeWorldMatrix(force: boolean): Matrix;
  13668. /**
  13669. * Gets the world matrix
  13670. * @returns A world matrix
  13671. */
  13672. getWorldMatrix?(): Matrix;
  13673. /**
  13674. * Gets the child meshes
  13675. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13676. * @returns An array of abstract meshes
  13677. */
  13678. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13679. /**
  13680. * Gets the vertex data
  13681. * @param kind The type of vertex data
  13682. * @returns A nullable array of numbers, or a float32 array
  13683. */
  13684. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13685. /**
  13686. * Gets the indices from the mesh
  13687. * @returns A nullable array of index arrays
  13688. */
  13689. getIndices?(): Nullable<IndicesArray>;
  13690. /**
  13691. * Gets the scene from the mesh
  13692. * @returns the indices array or null
  13693. */
  13694. getScene?(): Scene;
  13695. /**
  13696. * Gets the absolute position from the mesh
  13697. * @returns the absolute position
  13698. */
  13699. getAbsolutePosition(): Vector3;
  13700. /**
  13701. * Gets the absolute pivot point from the mesh
  13702. * @returns the absolute pivot point
  13703. */
  13704. getAbsolutePivotPoint(): Vector3;
  13705. /**
  13706. * Rotates the mesh
  13707. * @param axis The axis of rotation
  13708. * @param amount The amount of rotation
  13709. * @param space The space of the rotation
  13710. * @returns The rotation transform node
  13711. */
  13712. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13713. /**
  13714. * Translates the mesh
  13715. * @param axis The axis of translation
  13716. * @param distance The distance of translation
  13717. * @param space The space of the translation
  13718. * @returns The transform node
  13719. */
  13720. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13721. /**
  13722. * Sets the absolute position of the mesh
  13723. * @param absolutePosition The absolute position of the mesh
  13724. * @returns The transform node
  13725. */
  13726. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13727. /**
  13728. * Gets the class name of the mesh
  13729. * @returns The class name
  13730. */
  13731. getClassName(): string;
  13732. }
  13733. /**
  13734. * Represents a physics imposter
  13735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13736. */
  13737. export class PhysicsImpostor {
  13738. /**
  13739. * The physics-enabled object used as the physics imposter
  13740. */
  13741. object: IPhysicsEnabledObject;
  13742. /**
  13743. * The type of the physics imposter
  13744. */
  13745. type: number;
  13746. private _options;
  13747. private _scene?;
  13748. /**
  13749. * The default object size of the imposter
  13750. */
  13751. static DEFAULT_OBJECT_SIZE: Vector3;
  13752. /**
  13753. * The identity quaternion of the imposter
  13754. */
  13755. static IDENTITY_QUATERNION: Quaternion;
  13756. /** @hidden */
  13757. _pluginData: any;
  13758. private _physicsEngine;
  13759. private _physicsBody;
  13760. private _bodyUpdateRequired;
  13761. private _onBeforePhysicsStepCallbacks;
  13762. private _onAfterPhysicsStepCallbacks;
  13763. /** @hidden */
  13764. _onPhysicsCollideCallbacks: Array<{
  13765. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13766. otherImpostors: Array<PhysicsImpostor>;
  13767. }>;
  13768. private _deltaPosition;
  13769. private _deltaRotation;
  13770. private _deltaRotationConjugated;
  13771. /** @hidden */
  13772. _isFromLine: boolean;
  13773. private _parent;
  13774. private _isDisposed;
  13775. private static _tmpVecs;
  13776. private static _tmpQuat;
  13777. /**
  13778. * Specifies if the physics imposter is disposed
  13779. */
  13780. readonly isDisposed: boolean;
  13781. /**
  13782. * Gets the mass of the physics imposter
  13783. */
  13784. mass: number;
  13785. /**
  13786. * Gets the coefficient of friction
  13787. */
  13788. /**
  13789. * Sets the coefficient of friction
  13790. */
  13791. friction: number;
  13792. /**
  13793. * Gets the coefficient of restitution
  13794. */
  13795. /**
  13796. * Sets the coefficient of restitution
  13797. */
  13798. restitution: number;
  13799. /**
  13800. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13801. */
  13802. /**
  13803. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13804. */
  13805. pressure: number;
  13806. /**
  13807. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13808. */
  13809. /**
  13810. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13811. */
  13812. stiffness: number;
  13813. /**
  13814. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13815. */
  13816. /**
  13817. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13818. */
  13819. velocityIterations: number;
  13820. /**
  13821. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13822. */
  13823. /**
  13824. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13825. */
  13826. positionIterations: number;
  13827. /**
  13828. * The unique id of the physics imposter
  13829. * set by the physics engine when adding this impostor to the array
  13830. */
  13831. uniqueId: number;
  13832. /**
  13833. * @hidden
  13834. */
  13835. soft: boolean;
  13836. /**
  13837. * @hidden
  13838. */
  13839. segments: number;
  13840. private _joints;
  13841. /**
  13842. * Initializes the physics imposter
  13843. * @param object The physics-enabled object used as the physics imposter
  13844. * @param type The type of the physics imposter
  13845. * @param _options The options for the physics imposter
  13846. * @param _scene The Babylon scene
  13847. */
  13848. constructor(
  13849. /**
  13850. * The physics-enabled object used as the physics imposter
  13851. */
  13852. object: IPhysicsEnabledObject,
  13853. /**
  13854. * The type of the physics imposter
  13855. */
  13856. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13857. /**
  13858. * This function will completly initialize this impostor.
  13859. * It will create a new body - but only if this mesh has no parent.
  13860. * If it has, this impostor will not be used other than to define the impostor
  13861. * of the child mesh.
  13862. * @hidden
  13863. */
  13864. _init(): void;
  13865. private _getPhysicsParent;
  13866. /**
  13867. * Should a new body be generated.
  13868. * @returns boolean specifying if body initialization is required
  13869. */
  13870. isBodyInitRequired(): boolean;
  13871. /**
  13872. * Sets the updated scaling
  13873. * @param updated Specifies if the scaling is updated
  13874. */
  13875. setScalingUpdated(): void;
  13876. /**
  13877. * Force a regeneration of this or the parent's impostor's body.
  13878. * Use under cautious - This will remove all joints already implemented.
  13879. */
  13880. forceUpdate(): void;
  13881. /**
  13882. * Gets the body that holds this impostor. Either its own, or its parent.
  13883. */
  13884. /**
  13885. * Set the physics body. Used mainly by the physics engine/plugin
  13886. */
  13887. physicsBody: any;
  13888. /**
  13889. * Get the parent of the physics imposter
  13890. * @returns Physics imposter or null
  13891. */
  13892. /**
  13893. * Sets the parent of the physics imposter
  13894. */
  13895. parent: Nullable<PhysicsImpostor>;
  13896. /**
  13897. * Resets the update flags
  13898. */
  13899. resetUpdateFlags(): void;
  13900. /**
  13901. * Gets the object extend size
  13902. * @returns the object extend size
  13903. */
  13904. getObjectExtendSize(): Vector3;
  13905. /**
  13906. * Gets the object center
  13907. * @returns The object center
  13908. */
  13909. getObjectCenter(): Vector3;
  13910. /**
  13911. * Get a specific parametes from the options parameter
  13912. * @param paramName The object parameter name
  13913. * @returns The object parameter
  13914. */
  13915. getParam(paramName: string): any;
  13916. /**
  13917. * Sets a specific parameter in the options given to the physics plugin
  13918. * @param paramName The parameter name
  13919. * @param value The value of the parameter
  13920. */
  13921. setParam(paramName: string, value: number): void;
  13922. /**
  13923. * Specifically change the body's mass option. Won't recreate the physics body object
  13924. * @param mass The mass of the physics imposter
  13925. */
  13926. setMass(mass: number): void;
  13927. /**
  13928. * Gets the linear velocity
  13929. * @returns linear velocity or null
  13930. */
  13931. getLinearVelocity(): Nullable<Vector3>;
  13932. /**
  13933. * Sets the linear velocity
  13934. * @param velocity linear velocity or null
  13935. */
  13936. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13937. /**
  13938. * Gets the angular velocity
  13939. * @returns angular velocity or null
  13940. */
  13941. getAngularVelocity(): Nullable<Vector3>;
  13942. /**
  13943. * Sets the angular velocity
  13944. * @param velocity The velocity or null
  13945. */
  13946. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13947. /**
  13948. * Execute a function with the physics plugin native code
  13949. * Provide a function the will have two variables - the world object and the physics body object
  13950. * @param func The function to execute with the physics plugin native code
  13951. */
  13952. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13953. /**
  13954. * Register a function that will be executed before the physics world is stepping forward
  13955. * @param func The function to execute before the physics world is stepped forward
  13956. */
  13957. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13958. /**
  13959. * Unregister a function that will be executed before the physics world is stepping forward
  13960. * @param func The function to execute before the physics world is stepped forward
  13961. */
  13962. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13963. /**
  13964. * Register a function that will be executed after the physics step
  13965. * @param func The function to execute after physics step
  13966. */
  13967. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13968. /**
  13969. * Unregisters a function that will be executed after the physics step
  13970. * @param func The function to execute after physics step
  13971. */
  13972. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13973. /**
  13974. * register a function that will be executed when this impostor collides against a different body
  13975. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13976. * @param func Callback that is executed on collision
  13977. */
  13978. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13979. /**
  13980. * Unregisters the physics imposter on contact
  13981. * @param collideAgainst The physics object to collide against
  13982. * @param func Callback to execute on collision
  13983. */
  13984. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13985. private _tmpQuat;
  13986. private _tmpQuat2;
  13987. /**
  13988. * Get the parent rotation
  13989. * @returns The parent rotation
  13990. */
  13991. getParentsRotation(): Quaternion;
  13992. /**
  13993. * this function is executed by the physics engine.
  13994. */
  13995. beforeStep: () => void;
  13996. /**
  13997. * this function is executed by the physics engine
  13998. */
  13999. afterStep: () => void;
  14000. /**
  14001. * Legacy collision detection event support
  14002. */
  14003. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  14004. /**
  14005. * event and body object due to cannon's event-based architecture.
  14006. */
  14007. onCollide: (e: {
  14008. body: any;
  14009. }) => void;
  14010. /**
  14011. * Apply a force
  14012. * @param force The force to apply
  14013. * @param contactPoint The contact point for the force
  14014. * @returns The physics imposter
  14015. */
  14016. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14017. /**
  14018. * Apply an impulse
  14019. * @param force The impulse force
  14020. * @param contactPoint The contact point for the impulse force
  14021. * @returns The physics imposter
  14022. */
  14023. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14024. /**
  14025. * A help function to create a joint
  14026. * @param otherImpostor A physics imposter used to create a joint
  14027. * @param jointType The type of joint
  14028. * @param jointData The data for the joint
  14029. * @returns The physics imposter
  14030. */
  14031. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14032. /**
  14033. * Add a joint to this impostor with a different impostor
  14034. * @param otherImpostor A physics imposter used to add a joint
  14035. * @param joint The joint to add
  14036. * @returns The physics imposter
  14037. */
  14038. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14039. /**
  14040. * Add an anchor to a cloth impostor
  14041. * @param otherImpostor rigid impostor to anchor to
  14042. * @param width ratio across width from 0 to 1
  14043. * @param height ratio up height from 0 to 1
  14044. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14045. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14046. * @returns impostor the soft imposter
  14047. */
  14048. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14049. /**
  14050. * Add a hook to a rope impostor
  14051. * @param otherImpostor rigid impostor to anchor to
  14052. * @param length ratio across rope from 0 to 1
  14053. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14054. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14055. * @returns impostor the rope imposter
  14056. */
  14057. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14058. /**
  14059. * Will keep this body still, in a sleep mode.
  14060. * @returns the physics imposter
  14061. */
  14062. sleep(): PhysicsImpostor;
  14063. /**
  14064. * Wake the body up.
  14065. * @returns The physics imposter
  14066. */
  14067. wakeUp(): PhysicsImpostor;
  14068. /**
  14069. * Clones the physics imposter
  14070. * @param newObject The physics imposter clones to this physics-enabled object
  14071. * @returns A nullable physics imposter
  14072. */
  14073. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14074. /**
  14075. * Disposes the physics imposter
  14076. */
  14077. dispose(): void;
  14078. /**
  14079. * Sets the delta position
  14080. * @param position The delta position amount
  14081. */
  14082. setDeltaPosition(position: Vector3): void;
  14083. /**
  14084. * Sets the delta rotation
  14085. * @param rotation The delta rotation amount
  14086. */
  14087. setDeltaRotation(rotation: Quaternion): void;
  14088. /**
  14089. * Gets the box size of the physics imposter and stores the result in the input parameter
  14090. * @param result Stores the box size
  14091. * @returns The physics imposter
  14092. */
  14093. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14094. /**
  14095. * Gets the radius of the physics imposter
  14096. * @returns Radius of the physics imposter
  14097. */
  14098. getRadius(): number;
  14099. /**
  14100. * Sync a bone with this impostor
  14101. * @param bone The bone to sync to the impostor.
  14102. * @param boneMesh The mesh that the bone is influencing.
  14103. * @param jointPivot The pivot of the joint / bone in local space.
  14104. * @param distToJoint Optional distance from the impostor to the joint.
  14105. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14106. */
  14107. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14108. /**
  14109. * Sync impostor to a bone
  14110. * @param bone The bone that the impostor will be synced to.
  14111. * @param boneMesh The mesh that the bone is influencing.
  14112. * @param jointPivot The pivot of the joint / bone in local space.
  14113. * @param distToJoint Optional distance from the impostor to the joint.
  14114. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14115. * @param boneAxis Optional vector3 axis the bone is aligned with
  14116. */
  14117. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14118. /**
  14119. * No-Imposter type
  14120. */
  14121. static NoImpostor: number;
  14122. /**
  14123. * Sphere-Imposter type
  14124. */
  14125. static SphereImpostor: number;
  14126. /**
  14127. * Box-Imposter type
  14128. */
  14129. static BoxImpostor: number;
  14130. /**
  14131. * Plane-Imposter type
  14132. */
  14133. static PlaneImpostor: number;
  14134. /**
  14135. * Mesh-imposter type
  14136. */
  14137. static MeshImpostor: number;
  14138. /**
  14139. * Capsule-Impostor type (Ammo.js plugin only)
  14140. */
  14141. static CapsuleImpostor: number;
  14142. /**
  14143. * Cylinder-Imposter type
  14144. */
  14145. static CylinderImpostor: number;
  14146. /**
  14147. * Particle-Imposter type
  14148. */
  14149. static ParticleImpostor: number;
  14150. /**
  14151. * Heightmap-Imposter type
  14152. */
  14153. static HeightmapImpostor: number;
  14154. /**
  14155. * ConvexHull-Impostor type (Ammo.js plugin only)
  14156. */
  14157. static ConvexHullImpostor: number;
  14158. /**
  14159. * Rope-Imposter type
  14160. */
  14161. static RopeImpostor: number;
  14162. /**
  14163. * Cloth-Imposter type
  14164. */
  14165. static ClothImpostor: number;
  14166. /**
  14167. * Softbody-Imposter type
  14168. */
  14169. static SoftbodyImpostor: number;
  14170. }
  14171. }
  14172. declare module "babylonjs/Meshes/mesh" {
  14173. import { Observable } from "babylonjs/Misc/observable";
  14174. import { IAnimatable } from "babylonjs/Misc/tools";
  14175. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14176. import { Camera } from "babylonjs/Cameras/camera";
  14177. import { Scene } from "babylonjs/scene";
  14178. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14179. import { Engine } from "babylonjs/Engines/engine";
  14180. import { Node } from "babylonjs/node";
  14181. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14182. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14183. import { Buffer } from "babylonjs/Meshes/buffer";
  14184. import { Geometry } from "babylonjs/Meshes/geometry";
  14185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14187. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14188. import { Effect } from "babylonjs/Materials/effect";
  14189. import { Material } from "babylonjs/Materials/material";
  14190. import { Skeleton } from "babylonjs/Bones/skeleton";
  14191. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14192. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14193. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14194. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14195. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14196. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14197. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14198. /**
  14199. * @hidden
  14200. **/
  14201. export class _CreationDataStorage {
  14202. closePath?: boolean;
  14203. closeArray?: boolean;
  14204. idx: number[];
  14205. dashSize: number;
  14206. gapSize: number;
  14207. path3D: Path3D;
  14208. pathArray: Vector3[][];
  14209. arc: number;
  14210. radius: number;
  14211. cap: number;
  14212. tessellation: number;
  14213. }
  14214. /**
  14215. * @hidden
  14216. **/
  14217. class _InstanceDataStorage {
  14218. visibleInstances: any;
  14219. batchCache: _InstancesBatch;
  14220. instancesBufferSize: number;
  14221. instancesBuffer: Nullable<Buffer>;
  14222. instancesData: Float32Array;
  14223. overridenInstanceCount: number;
  14224. isFrozen: boolean;
  14225. previousBatch: Nullable<_InstancesBatch>;
  14226. hardwareInstancedRendering: boolean;
  14227. sideOrientation: number;
  14228. }
  14229. /**
  14230. * @hidden
  14231. **/
  14232. export class _InstancesBatch {
  14233. mustReturn: boolean;
  14234. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14235. renderSelf: boolean[];
  14236. hardwareInstancedRendering: boolean[];
  14237. }
  14238. /**
  14239. * Class used to represent renderable models
  14240. */
  14241. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14242. /**
  14243. * Mesh side orientation : usually the external or front surface
  14244. */
  14245. static readonly FRONTSIDE: number;
  14246. /**
  14247. * Mesh side orientation : usually the internal or back surface
  14248. */
  14249. static readonly BACKSIDE: number;
  14250. /**
  14251. * Mesh side orientation : both internal and external or front and back surfaces
  14252. */
  14253. static readonly DOUBLESIDE: number;
  14254. /**
  14255. * Mesh side orientation : by default, `FRONTSIDE`
  14256. */
  14257. static readonly DEFAULTSIDE: number;
  14258. /**
  14259. * Mesh cap setting : no cap
  14260. */
  14261. static readonly NO_CAP: number;
  14262. /**
  14263. * Mesh cap setting : one cap at the beginning of the mesh
  14264. */
  14265. static readonly CAP_START: number;
  14266. /**
  14267. * Mesh cap setting : one cap at the end of the mesh
  14268. */
  14269. static readonly CAP_END: number;
  14270. /**
  14271. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14272. */
  14273. static readonly CAP_ALL: number;
  14274. /**
  14275. * Mesh pattern setting : no flip or rotate
  14276. */
  14277. static readonly NO_FLIP: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14280. */
  14281. static readonly FLIP_TILE: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14284. */
  14285. static readonly ROTATE_TILE: number;
  14286. /**
  14287. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14288. */
  14289. static readonly FLIP_ROW: number;
  14290. /**
  14291. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14292. */
  14293. static readonly ROTATE_ROW: number;
  14294. /**
  14295. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14296. */
  14297. static readonly FLIP_N_ROTATE_TILE: number;
  14298. /**
  14299. * Mesh pattern setting : rotate pattern and rotate
  14300. */
  14301. static readonly FLIP_N_ROTATE_ROW: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14304. */
  14305. static readonly CENTER: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on left
  14308. */
  14309. static readonly LEFT: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on right
  14312. */
  14313. static readonly RIGHT: number;
  14314. /**
  14315. * Mesh tile positioning : part tiles on top
  14316. */
  14317. static readonly TOP: number;
  14318. /**
  14319. * Mesh tile positioning : part tiles on bottom
  14320. */
  14321. static readonly BOTTOM: number;
  14322. /**
  14323. * Gets the default side orientation.
  14324. * @param orientation the orientation to value to attempt to get
  14325. * @returns the default orientation
  14326. * @hidden
  14327. */
  14328. static _GetDefaultSideOrientation(orientation?: number): number;
  14329. private _internalMeshDataInfo;
  14330. /**
  14331. * An event triggered before rendering the mesh
  14332. */
  14333. readonly onBeforeRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before binding the mesh
  14336. */
  14337. readonly onBeforeBindObservable: Observable<Mesh>;
  14338. /**
  14339. * An event triggered after rendering the mesh
  14340. */
  14341. readonly onAfterRenderObservable: Observable<Mesh>;
  14342. /**
  14343. * An event triggered before drawing the mesh
  14344. */
  14345. readonly onBeforeDrawObservable: Observable<Mesh>;
  14346. private _onBeforeDrawObserver;
  14347. /**
  14348. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14349. */
  14350. onBeforeDraw: () => void;
  14351. /**
  14352. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14353. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14354. */
  14355. delayLoadState: number;
  14356. /**
  14357. * Gets the list of instances created from this mesh
  14358. * it is not supposed to be modified manually.
  14359. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14360. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14361. */
  14362. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14363. /**
  14364. * Gets the file containing delay loading data for this mesh
  14365. */
  14366. delayLoadingFile: string;
  14367. /** @hidden */
  14368. _binaryInfo: any;
  14369. /**
  14370. * User defined function used to change how LOD level selection is done
  14371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14372. */
  14373. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14374. /**
  14375. * Gets or sets the morph target manager
  14376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14377. */
  14378. morphTargetManager: Nullable<MorphTargetManager>;
  14379. /** @hidden */
  14380. _creationDataStorage: Nullable<_CreationDataStorage>;
  14381. /** @hidden */
  14382. _geometry: Nullable<Geometry>;
  14383. /** @hidden */
  14384. _delayInfo: Array<string>;
  14385. /** @hidden */
  14386. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14387. /** @hidden */
  14388. _instanceDataStorage: _InstanceDataStorage;
  14389. private _effectiveMaterial;
  14390. /** @hidden */
  14391. _shouldGenerateFlatShading: boolean;
  14392. /** @hidden */
  14393. _originalBuilderSideOrientation: number;
  14394. /**
  14395. * Use this property to change the original side orientation defined at construction time
  14396. */
  14397. overrideMaterialSideOrientation: Nullable<number>;
  14398. /**
  14399. * Gets the source mesh (the one used to clone this one from)
  14400. */
  14401. readonly source: Nullable<Mesh>;
  14402. /**
  14403. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14404. */
  14405. isUnIndexed: boolean;
  14406. /**
  14407. * @constructor
  14408. * @param name The value used by scene.getMeshByName() to do a lookup.
  14409. * @param scene The scene to add this mesh to.
  14410. * @param parent The parent of this mesh, if it has one
  14411. * @param source An optional Mesh from which geometry is shared, cloned.
  14412. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14413. * When false, achieved by calling a clone(), also passing False.
  14414. * This will make creation of children, recursive.
  14415. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14416. */
  14417. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14418. /**
  14419. * Gets the class name
  14420. * @returns the string "Mesh".
  14421. */
  14422. getClassName(): string;
  14423. /** @hidden */
  14424. readonly _isMesh: boolean;
  14425. /**
  14426. * Returns a description of this mesh
  14427. * @param fullDetails define if full details about this mesh must be used
  14428. * @returns a descriptive string representing this mesh
  14429. */
  14430. toString(fullDetails?: boolean): string;
  14431. /** @hidden */
  14432. _unBindEffect(): void;
  14433. /**
  14434. * Gets a boolean indicating if this mesh has LOD
  14435. */
  14436. readonly hasLODLevels: boolean;
  14437. /**
  14438. * Gets the list of MeshLODLevel associated with the current mesh
  14439. * @returns an array of MeshLODLevel
  14440. */
  14441. getLODLevels(): MeshLODLevel[];
  14442. private _sortLODLevels;
  14443. /**
  14444. * Add a mesh as LOD level triggered at the given distance.
  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. * @param mesh The mesh to be added as LOD level (can be null)
  14448. * @return This mesh (for chaining)
  14449. */
  14450. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14451. /**
  14452. * Returns the LOD level mesh at the passed distance or null if not found.
  14453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14454. * @param distance The distance from the center of the object to show this level
  14455. * @returns a Mesh or `null`
  14456. */
  14457. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14458. /**
  14459. * Remove a mesh from the LOD array
  14460. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14461. * @param mesh defines the mesh to be removed
  14462. * @return This mesh (for chaining)
  14463. */
  14464. removeLODLevel(mesh: Mesh): Mesh;
  14465. /**
  14466. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14467. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14468. * @param camera defines the camera to use to compute distance
  14469. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14470. * @return This mesh (for chaining)
  14471. */
  14472. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14473. /**
  14474. * Gets the mesh internal Geometry object
  14475. */
  14476. readonly geometry: Nullable<Geometry>;
  14477. /**
  14478. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14479. * @returns the total number of vertices
  14480. */
  14481. getTotalVertices(): number;
  14482. /**
  14483. * Returns the content of an associated vertex buffer
  14484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14485. * - VertexBuffer.PositionKind
  14486. * - VertexBuffer.UVKind
  14487. * - VertexBuffer.UV2Kind
  14488. * - VertexBuffer.UV3Kind
  14489. * - VertexBuffer.UV4Kind
  14490. * - VertexBuffer.UV5Kind
  14491. * - VertexBuffer.UV6Kind
  14492. * - VertexBuffer.ColorKind
  14493. * - VertexBuffer.MatricesIndicesKind
  14494. * - VertexBuffer.MatricesIndicesExtraKind
  14495. * - VertexBuffer.MatricesWeightsKind
  14496. * - VertexBuffer.MatricesWeightsExtraKind
  14497. * @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
  14498. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14499. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14500. */
  14501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14502. /**
  14503. * Returns the mesh VertexBuffer object from the requested `kind`
  14504. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14505. * - VertexBuffer.PositionKind
  14506. * - VertexBuffer.NormalKind
  14507. * - VertexBuffer.UVKind
  14508. * - VertexBuffer.UV2Kind
  14509. * - VertexBuffer.UV3Kind
  14510. * - VertexBuffer.UV4Kind
  14511. * - VertexBuffer.UV5Kind
  14512. * - VertexBuffer.UV6Kind
  14513. * - VertexBuffer.ColorKind
  14514. * - VertexBuffer.MatricesIndicesKind
  14515. * - VertexBuffer.MatricesIndicesExtraKind
  14516. * - VertexBuffer.MatricesWeightsKind
  14517. * - VertexBuffer.MatricesWeightsExtraKind
  14518. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14519. */
  14520. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14521. /**
  14522. * Tests if a specific vertex buffer is associated with this mesh
  14523. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14524. * - VertexBuffer.PositionKind
  14525. * - VertexBuffer.NormalKind
  14526. * - VertexBuffer.UVKind
  14527. * - VertexBuffer.UV2Kind
  14528. * - VertexBuffer.UV3Kind
  14529. * - VertexBuffer.UV4Kind
  14530. * - VertexBuffer.UV5Kind
  14531. * - VertexBuffer.UV6Kind
  14532. * - VertexBuffer.ColorKind
  14533. * - VertexBuffer.MatricesIndicesKind
  14534. * - VertexBuffer.MatricesIndicesExtraKind
  14535. * - VertexBuffer.MatricesWeightsKind
  14536. * - VertexBuffer.MatricesWeightsExtraKind
  14537. * @returns a boolean
  14538. */
  14539. isVerticesDataPresent(kind: string): boolean;
  14540. /**
  14541. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14543. * - VertexBuffer.PositionKind
  14544. * - VertexBuffer.UVKind
  14545. * - VertexBuffer.UV2Kind
  14546. * - VertexBuffer.UV3Kind
  14547. * - VertexBuffer.UV4Kind
  14548. * - VertexBuffer.UV5Kind
  14549. * - VertexBuffer.UV6Kind
  14550. * - VertexBuffer.ColorKind
  14551. * - VertexBuffer.MatricesIndicesKind
  14552. * - VertexBuffer.MatricesIndicesExtraKind
  14553. * - VertexBuffer.MatricesWeightsKind
  14554. * - VertexBuffer.MatricesWeightsExtraKind
  14555. * @returns a boolean
  14556. */
  14557. isVertexBufferUpdatable(kind: string): boolean;
  14558. /**
  14559. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14561. * - VertexBuffer.PositionKind
  14562. * - VertexBuffer.NormalKind
  14563. * - VertexBuffer.UVKind
  14564. * - VertexBuffer.UV2Kind
  14565. * - VertexBuffer.UV3Kind
  14566. * - VertexBuffer.UV4Kind
  14567. * - VertexBuffer.UV5Kind
  14568. * - VertexBuffer.UV6Kind
  14569. * - VertexBuffer.ColorKind
  14570. * - VertexBuffer.MatricesIndicesKind
  14571. * - VertexBuffer.MatricesIndicesExtraKind
  14572. * - VertexBuffer.MatricesWeightsKind
  14573. * - VertexBuffer.MatricesWeightsExtraKind
  14574. * @returns an array of strings
  14575. */
  14576. getVerticesDataKinds(): string[];
  14577. /**
  14578. * Returns a positive integer : the total number of indices in this mesh geometry.
  14579. * @returns the numner of indices or zero if the mesh has no geometry.
  14580. */
  14581. getTotalIndices(): number;
  14582. /**
  14583. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14584. * @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.
  14585. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14586. * @returns the indices array or an empty array if the mesh has no geometry
  14587. */
  14588. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14589. readonly isBlocked: boolean;
  14590. /**
  14591. * Determine if the current mesh is ready to be rendered
  14592. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14593. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14594. * @returns true if all associated assets are ready (material, textures, shaders)
  14595. */
  14596. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14597. /**
  14598. * 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.
  14599. */
  14600. readonly areNormalsFrozen: boolean;
  14601. /**
  14602. * 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.
  14603. * @returns the current mesh
  14604. */
  14605. freezeNormals(): Mesh;
  14606. /**
  14607. * 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
  14608. * @returns the current mesh
  14609. */
  14610. unfreezeNormals(): Mesh;
  14611. /**
  14612. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14613. */
  14614. overridenInstanceCount: number;
  14615. /** @hidden */
  14616. _preActivate(): Mesh;
  14617. /** @hidden */
  14618. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14619. /** @hidden */
  14620. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14621. /**
  14622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14623. * This means the mesh underlying bounding box and sphere are recomputed.
  14624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14625. * @returns the current mesh
  14626. */
  14627. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14628. /** @hidden */
  14629. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14630. /**
  14631. * This function will subdivide the mesh into multiple submeshes
  14632. * @param count defines the expected number of submeshes
  14633. */
  14634. subdivide(count: number): void;
  14635. /**
  14636. * Copy a FloatArray into a specific associated vertex buffer
  14637. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14638. * - VertexBuffer.PositionKind
  14639. * - VertexBuffer.UVKind
  14640. * - VertexBuffer.UV2Kind
  14641. * - VertexBuffer.UV3Kind
  14642. * - VertexBuffer.UV4Kind
  14643. * - VertexBuffer.UV5Kind
  14644. * - VertexBuffer.UV6Kind
  14645. * - VertexBuffer.ColorKind
  14646. * - VertexBuffer.MatricesIndicesKind
  14647. * - VertexBuffer.MatricesIndicesExtraKind
  14648. * - VertexBuffer.MatricesWeightsKind
  14649. * - VertexBuffer.MatricesWeightsExtraKind
  14650. * @param data defines the data source
  14651. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14652. * @param stride defines the data stride size (can be null)
  14653. * @returns the current mesh
  14654. */
  14655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14656. /**
  14657. * Flags an associated vertex buffer as updatable
  14658. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14659. * - VertexBuffer.PositionKind
  14660. * - VertexBuffer.UVKind
  14661. * - VertexBuffer.UV2Kind
  14662. * - VertexBuffer.UV3Kind
  14663. * - VertexBuffer.UV4Kind
  14664. * - VertexBuffer.UV5Kind
  14665. * - VertexBuffer.UV6Kind
  14666. * - VertexBuffer.ColorKind
  14667. * - VertexBuffer.MatricesIndicesKind
  14668. * - VertexBuffer.MatricesIndicesExtraKind
  14669. * - VertexBuffer.MatricesWeightsKind
  14670. * - VertexBuffer.MatricesWeightsExtraKind
  14671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14672. */
  14673. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14674. /**
  14675. * Sets the mesh global Vertex Buffer
  14676. * @param buffer defines the buffer to use
  14677. * @returns the current mesh
  14678. */
  14679. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14680. /**
  14681. * Update a specific associated vertex buffer
  14682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14683. * - VertexBuffer.PositionKind
  14684. * - VertexBuffer.UVKind
  14685. * - VertexBuffer.UV2Kind
  14686. * - VertexBuffer.UV3Kind
  14687. * - VertexBuffer.UV4Kind
  14688. * - VertexBuffer.UV5Kind
  14689. * - VertexBuffer.UV6Kind
  14690. * - VertexBuffer.ColorKind
  14691. * - VertexBuffer.MatricesIndicesKind
  14692. * - VertexBuffer.MatricesIndicesExtraKind
  14693. * - VertexBuffer.MatricesWeightsKind
  14694. * - VertexBuffer.MatricesWeightsExtraKind
  14695. * @param data defines the data source
  14696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14697. * @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)
  14698. * @returns the current mesh
  14699. */
  14700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14701. /**
  14702. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14703. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14704. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14705. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14706. * @returns the current mesh
  14707. */
  14708. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14709. /**
  14710. * Creates a un-shared specific occurence of the geometry for the mesh.
  14711. * @returns the current mesh
  14712. */
  14713. makeGeometryUnique(): Mesh;
  14714. /**
  14715. * Set the index buffer of this mesh
  14716. * @param indices defines the source data
  14717. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14718. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14719. * @returns the current mesh
  14720. */
  14721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14722. /**
  14723. * Update the current index buffer
  14724. * @param indices defines the source data
  14725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14726. * @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)
  14727. * @returns the current mesh
  14728. */
  14729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14730. /**
  14731. * Invert the geometry to move from a right handed system to a left handed one.
  14732. * @returns the current mesh
  14733. */
  14734. toLeftHanded(): Mesh;
  14735. /** @hidden */
  14736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14737. /** @hidden */
  14738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14739. /**
  14740. * Registers for this mesh a javascript function called just before the rendering process
  14741. * @param func defines the function to call before rendering this mesh
  14742. * @returns the current mesh
  14743. */
  14744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14745. /**
  14746. * Disposes a previously registered javascript function called before the rendering
  14747. * @param func defines the function to remove
  14748. * @returns the current mesh
  14749. */
  14750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14751. /**
  14752. * Registers for this mesh a javascript function called just after the rendering is complete
  14753. * @param func defines the function to call after rendering this mesh
  14754. * @returns the current mesh
  14755. */
  14756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14757. /**
  14758. * Disposes a previously registered javascript function called after the rendering.
  14759. * @param func defines the function to remove
  14760. * @returns the current mesh
  14761. */
  14762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14763. /** @hidden */
  14764. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14765. /** @hidden */
  14766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14767. /** @hidden */
  14768. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14769. /** @hidden */
  14770. _rebuild(): void;
  14771. /** @hidden */
  14772. _freeze(): void;
  14773. /** @hidden */
  14774. _unFreeze(): void;
  14775. /**
  14776. * 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
  14777. * @param subMesh defines the subMesh to render
  14778. * @param enableAlphaMode defines if alpha mode can be changed
  14779. * @returns the current mesh
  14780. */
  14781. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14782. private _onBeforeDraw;
  14783. /**
  14784. * Renormalize the mesh and patch it up if there are no weights
  14785. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14786. * However in the case of zero weights then we set just a single influence to 1.
  14787. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14788. */
  14789. cleanMatrixWeights(): void;
  14790. private normalizeSkinFourWeights;
  14791. private normalizeSkinWeightsAndExtra;
  14792. /**
  14793. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14794. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14795. * the user know there was an issue with importing the mesh
  14796. * @returns a validation object with skinned, valid and report string
  14797. */
  14798. validateSkinning(): {
  14799. skinned: boolean;
  14800. valid: boolean;
  14801. report: string;
  14802. };
  14803. /** @hidden */
  14804. _checkDelayState(): Mesh;
  14805. private _queueLoad;
  14806. /**
  14807. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14808. * A mesh is in the frustum if its bounding box intersects the frustum
  14809. * @param frustumPlanes defines the frustum to test
  14810. * @returns true if the mesh is in the frustum planes
  14811. */
  14812. isInFrustum(frustumPlanes: Plane[]): boolean;
  14813. /**
  14814. * Sets the mesh material by the material or multiMaterial `id` property
  14815. * @param id is a string identifying the material or the multiMaterial
  14816. * @returns the current mesh
  14817. */
  14818. setMaterialByID(id: string): Mesh;
  14819. /**
  14820. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14821. * @returns an array of IAnimatable
  14822. */
  14823. getAnimatables(): IAnimatable[];
  14824. /**
  14825. * Modifies the mesh geometry according to the passed transformation matrix.
  14826. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14827. * The mesh normals are modified using the same transformation.
  14828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14829. * @param transform defines the transform matrix to use
  14830. * @see http://doc.babylonjs.com/resources/baking_transformations
  14831. * @returns the current mesh
  14832. */
  14833. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14834. /**
  14835. * Modifies the mesh geometry according to its own current World Matrix.
  14836. * The mesh World Matrix is then reset.
  14837. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14838. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14839. * @see http://doc.babylonjs.com/resources/baking_transformations
  14840. * @returns the current mesh
  14841. */
  14842. bakeCurrentTransformIntoVertices(): Mesh;
  14843. /** @hidden */
  14844. readonly _positions: Nullable<Vector3[]>;
  14845. /** @hidden */
  14846. _resetPointsArrayCache(): Mesh;
  14847. /** @hidden */
  14848. _generatePointsArray(): boolean;
  14849. /**
  14850. * Returns a new Mesh object generated from the current mesh properties.
  14851. * This method must not get confused with createInstance()
  14852. * @param name is a string, the name given to the new mesh
  14853. * @param newParent can be any Node object (default `null`)
  14854. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14855. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14856. * @returns a new mesh
  14857. */
  14858. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14859. /**
  14860. * Releases resources associated with this mesh.
  14861. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14862. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14863. */
  14864. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14865. /**
  14866. * Modifies the mesh geometry according to a displacement map.
  14867. * 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.
  14868. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14869. * @param url is a string, the URL from the image file is to be downloaded.
  14870. * @param minHeight is the lower limit of the displacement.
  14871. * @param maxHeight is the upper limit of the displacement.
  14872. * @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.
  14873. * @param uvOffset is an optional vector2 used to offset UV.
  14874. * @param uvScale is an optional vector2 used to scale UV.
  14875. * @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.
  14876. * @returns the Mesh.
  14877. */
  14878. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14879. /**
  14880. * Modifies the mesh geometry according to a displacementMap buffer.
  14881. * 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.
  14882. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14883. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14884. * @param heightMapWidth is the width of the buffer image.
  14885. * @param heightMapHeight is the height of the buffer image.
  14886. * @param minHeight is the lower limit of the displacement.
  14887. * @param maxHeight is the upper limit of the displacement.
  14888. * @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.
  14889. * @param uvOffset is an optional vector2 used to offset UV.
  14890. * @param uvScale is an optional vector2 used to scale UV.
  14891. * @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.
  14892. * @returns the Mesh.
  14893. */
  14894. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14895. /**
  14896. * Modify the mesh to get a flat shading rendering.
  14897. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14898. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14899. * @returns current mesh
  14900. */
  14901. convertToFlatShadedMesh(): Mesh;
  14902. /**
  14903. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14904. * In other words, more vertices, no more indices and a single bigger VBO.
  14905. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14906. * @returns current mesh
  14907. */
  14908. convertToUnIndexedMesh(): Mesh;
  14909. /**
  14910. * Inverses facet orientations.
  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 flipNormals will also inverts the normals
  14913. * @returns current mesh
  14914. */
  14915. flipFaces(flipNormals?: boolean): Mesh;
  14916. /**
  14917. * Increase the number of facets and hence vertices in a mesh
  14918. * Vertex normals are interpolated from existing vertex normals
  14919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14920. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14921. */
  14922. increaseVertices(numberPerEdge: number): void;
  14923. /**
  14924. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14925. * This will undo any application of covertToFlatShadedMesh
  14926. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14927. */
  14928. forceSharedVertices(): void;
  14929. /** @hidden */
  14930. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14931. /** @hidden */
  14932. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14933. /**
  14934. * Creates a new InstancedMesh object from the mesh model.
  14935. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14936. * @param name defines the name of the new instance
  14937. * @returns a new InstancedMesh
  14938. */
  14939. createInstance(name: string): InstancedMesh;
  14940. /**
  14941. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14942. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14943. * @returns the current mesh
  14944. */
  14945. synchronizeInstances(): Mesh;
  14946. /**
  14947. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14948. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14949. * This should be used together with the simplification to avoid disappearing triangles.
  14950. * @param successCallback an optional success callback to be called after the optimization finished.
  14951. * @returns the current mesh
  14952. */
  14953. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14954. /**
  14955. * Serialize current mesh
  14956. * @param serializationObject defines the object which will receive the serialization data
  14957. */
  14958. serialize(serializationObject: any): void;
  14959. /** @hidden */
  14960. _syncGeometryWithMorphTargetManager(): void;
  14961. /** @hidden */
  14962. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14963. /**
  14964. * Returns a new Mesh object parsed from the source provided.
  14965. * @param parsedMesh is the source
  14966. * @param scene defines the hosting scene
  14967. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14968. * @returns a new Mesh
  14969. */
  14970. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14971. /**
  14972. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14973. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14974. * @param name defines the name of the mesh to create
  14975. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14976. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14977. * @param closePath creates a seam between the first and the last points of each path of the path array
  14978. * @param offset is taken in account only if the `pathArray` is containing a single path
  14979. * @param scene defines the hosting scene
  14980. * @param updatable defines if the mesh must be flagged as updatable
  14981. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14982. * @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)
  14983. * @returns a new Mesh
  14984. */
  14985. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14986. /**
  14987. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14988. * @param name defines the name of the mesh to create
  14989. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14990. * @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
  14991. * @param scene defines the hosting scene
  14992. * @param updatable defines if the mesh must be flagged as updatable
  14993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14994. * @returns a new Mesh
  14995. */
  14996. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14997. /**
  14998. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14999. * @param name defines the name of the mesh to create
  15000. * @param size sets the size (float) of each box side (default 1)
  15001. * @param scene defines the hosting scene
  15002. * @param updatable defines if the mesh must be flagged as updatable
  15003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15004. * @returns a new Mesh
  15005. */
  15006. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15007. /**
  15008. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15009. * @param name defines the name of the mesh to create
  15010. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15011. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15012. * @param scene defines the hosting scene
  15013. * @param updatable defines if the mesh must be flagged as updatable
  15014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15015. * @returns a new Mesh
  15016. */
  15017. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15018. /**
  15019. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15020. * @param name defines the name of the mesh to create
  15021. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15022. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15023. * @param scene defines the hosting scene
  15024. * @returns a new Mesh
  15025. */
  15026. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15027. /**
  15028. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15029. * @param name defines the name of the mesh to create
  15030. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15031. * @param diameterTop set the top cap diameter (floats, default 1)
  15032. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15033. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15034. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15035. * @param scene defines the hosting scene
  15036. * @param updatable defines if the mesh must be flagged as updatable
  15037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15038. * @returns a new Mesh
  15039. */
  15040. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15041. /**
  15042. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15043. * @param name defines the name of the mesh to create
  15044. * @param diameter sets the diameter size (float) of the torus (default 1)
  15045. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15046. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15047. * @param scene defines the hosting scene
  15048. * @param updatable defines if the mesh must be flagged as updatable
  15049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15050. * @returns a new Mesh
  15051. */
  15052. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15053. /**
  15054. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15055. * @param name defines the name of the mesh to create
  15056. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15057. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15058. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15059. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15060. * @param p the number of windings on X axis (positive integers, default 2)
  15061. * @param q the number of windings on Y axis (positive integers, default 3)
  15062. * @param scene defines the hosting scene
  15063. * @param updatable defines if the mesh must be flagged as updatable
  15064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15065. * @returns a new Mesh
  15066. */
  15067. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15068. /**
  15069. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15070. * @param name defines the name of the mesh to create
  15071. * @param points is an array successive Vector3
  15072. * @param scene defines the hosting scene
  15073. * @param updatable defines if the mesh must be flagged as updatable
  15074. * @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).
  15075. * @returns a new Mesh
  15076. */
  15077. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15078. /**
  15079. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15080. * @param name defines the name of the mesh to create
  15081. * @param points is an array successive Vector3
  15082. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15083. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15084. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15085. * @param scene defines the hosting scene
  15086. * @param updatable defines if the mesh must be flagged as updatable
  15087. * @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)
  15088. * @returns a new Mesh
  15089. */
  15090. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15091. /**
  15092. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15094. * 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.
  15095. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15096. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15097. * Remember you can only change the shape positions, not their number when updating a polygon.
  15098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15099. * @param name defines the name of the mesh to create
  15100. * @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
  15101. * @param scene defines the hosting scene
  15102. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15103. * @param updatable defines if the mesh must be flagged as updatable
  15104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15105. * @param earcutInjection can be used to inject your own earcut reference
  15106. * @returns a new Mesh
  15107. */
  15108. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15109. /**
  15110. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15112. * @param name defines the name of the mesh to create
  15113. * @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
  15114. * @param depth defines the height of extrusion
  15115. * @param scene defines the hosting scene
  15116. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15117. * @param updatable defines if the mesh must be flagged as updatable
  15118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15119. * @param earcutInjection can be used to inject your own earcut reference
  15120. * @returns a new Mesh
  15121. */
  15122. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15123. /**
  15124. * Creates an extruded shape mesh.
  15125. * 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
  15126. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15127. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15128. * @param name defines the name of the mesh to create
  15129. * @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
  15130. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15131. * @param scale is the value to scale the shape
  15132. * @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
  15133. * @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
  15134. * @param scene defines the hosting scene
  15135. * @param updatable defines if the mesh must be flagged as updatable
  15136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15137. * @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)
  15138. * @returns a new Mesh
  15139. */
  15140. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15141. /**
  15142. * Creates an custom extruded shape mesh.
  15143. * The custom extrusion is a parametric shape.
  15144. * It has no predefined shape. Its final shape will depend on the input parameters.
  15145. * Please consider using the same method from the MeshBuilder class instead
  15146. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15147. * @param name defines the name of the mesh to create
  15148. * @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
  15149. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15150. * @param scaleFunction is a custom Javascript function called on each path point
  15151. * @param rotationFunction is a custom Javascript function called on each path point
  15152. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15153. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15154. * @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
  15155. * @param scene defines the hosting scene
  15156. * @param updatable defines if the mesh must be flagged as updatable
  15157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15158. * @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)
  15159. * @returns a new Mesh
  15160. */
  15161. 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;
  15162. /**
  15163. * Creates lathe mesh.
  15164. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15165. * Please consider using the same method from the MeshBuilder class instead
  15166. * @param name defines the name of the mesh to create
  15167. * @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
  15168. * @param radius is the radius value of the lathe
  15169. * @param tessellation is the side number of the lathe.
  15170. * @param scene defines the hosting scene
  15171. * @param updatable defines if the mesh must be flagged as updatable
  15172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15173. * @returns a new Mesh
  15174. */
  15175. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15176. /**
  15177. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15178. * @param name defines the name of the mesh to create
  15179. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15180. * @param scene defines the hosting scene
  15181. * @param updatable defines if the mesh must be flagged as updatable
  15182. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15183. * @returns a new Mesh
  15184. */
  15185. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15186. /**
  15187. * Creates a ground mesh.
  15188. * Please consider using the same method from the MeshBuilder class instead
  15189. * @param name defines the name of the mesh to create
  15190. * @param width set the width of the ground
  15191. * @param height set the height of the ground
  15192. * @param subdivisions sets the number of subdivisions per side
  15193. * @param scene defines the hosting scene
  15194. * @param updatable defines if the mesh must be flagged as updatable
  15195. * @returns a new Mesh
  15196. */
  15197. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15198. /**
  15199. * Creates a tiled ground mesh.
  15200. * Please consider using the same method from the MeshBuilder class instead
  15201. * @param name defines the name of the mesh to create
  15202. * @param xmin set the ground minimum X coordinate
  15203. * @param zmin set the ground minimum Y coordinate
  15204. * @param xmax set the ground maximum X coordinate
  15205. * @param zmax set the ground maximum Z coordinate
  15206. * @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
  15207. * @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
  15208. * @param scene defines the hosting scene
  15209. * @param updatable defines if the mesh must be flagged as updatable
  15210. * @returns a new Mesh
  15211. */
  15212. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15213. w: number;
  15214. h: number;
  15215. }, precision: {
  15216. w: number;
  15217. h: number;
  15218. }, scene: Scene, updatable?: boolean): Mesh;
  15219. /**
  15220. * Creates a ground mesh from a height map.
  15221. * Please consider using the same method from the MeshBuilder class instead
  15222. * @see http://doc.babylonjs.com/babylon101/height_map
  15223. * @param name defines the name of the mesh to create
  15224. * @param url sets the URL of the height map image resource
  15225. * @param width set the ground width size
  15226. * @param height set the ground height size
  15227. * @param subdivisions sets the number of subdivision per side
  15228. * @param minHeight is the minimum altitude on the ground
  15229. * @param maxHeight is the maximum altitude on the ground
  15230. * @param scene defines the hosting scene
  15231. * @param updatable defines if the mesh must be flagged as updatable
  15232. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15233. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15234. * @returns a new Mesh
  15235. */
  15236. 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;
  15237. /**
  15238. * Creates a tube mesh.
  15239. * The tube is a parametric shape.
  15240. * It has no predefined shape. Its final shape will depend on the input parameters.
  15241. * Please consider using the same method from the MeshBuilder class instead
  15242. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15243. * @param name defines the name of the mesh to create
  15244. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15245. * @param radius sets the tube radius size
  15246. * @param tessellation is the number of sides on the tubular surface
  15247. * @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
  15248. * @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
  15249. * @param scene defines the hosting scene
  15250. * @param updatable defines if the mesh must be flagged as updatable
  15251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15252. * @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)
  15253. * @returns a new Mesh
  15254. */
  15255. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15256. (i: number, distance: number): number;
  15257. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15258. /**
  15259. * Creates a polyhedron mesh.
  15260. * Please consider using the same method from the MeshBuilder class instead.
  15261. * * 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
  15262. * * The parameter `size` (positive float, default 1) sets the polygon size
  15263. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15264. * * 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`
  15265. * * 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
  15266. * * 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)`)
  15267. * * 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
  15268. * * 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
  15269. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15270. * * If you create a double-sided mesh, you can choose what parts of 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
  15271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15272. * @param name defines the name of the mesh to create
  15273. * @param options defines the options used to create the mesh
  15274. * @param scene defines the hosting scene
  15275. * @returns a new Mesh
  15276. */
  15277. static CreatePolyhedron(name: string, options: {
  15278. type?: number;
  15279. size?: number;
  15280. sizeX?: number;
  15281. sizeY?: number;
  15282. sizeZ?: number;
  15283. custom?: any;
  15284. faceUV?: Vector4[];
  15285. faceColors?: Color4[];
  15286. updatable?: boolean;
  15287. sideOrientation?: number;
  15288. }, scene: Scene): Mesh;
  15289. /**
  15290. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15291. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15292. * * 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`)
  15293. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15294. * * 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
  15295. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15296. * * If you create a double-sided mesh, you can choose what parts of 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
  15297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15298. * @param name defines the name of the mesh
  15299. * @param options defines the options used to create the mesh
  15300. * @param scene defines the hosting scene
  15301. * @returns a new Mesh
  15302. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15303. */
  15304. static CreateIcoSphere(name: string, options: {
  15305. radius?: number;
  15306. flat?: boolean;
  15307. subdivisions?: number;
  15308. sideOrientation?: number;
  15309. updatable?: boolean;
  15310. }, scene: Scene): Mesh;
  15311. /**
  15312. * Creates a decal mesh.
  15313. * Please consider using the same method from the MeshBuilder class instead.
  15314. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15315. * @param name defines the name of the mesh
  15316. * @param sourceMesh defines the mesh receiving the decal
  15317. * @param position sets the position of the decal in world coordinates
  15318. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15319. * @param size sets the decal scaling
  15320. * @param angle sets the angle to rotate the decal
  15321. * @returns a new Mesh
  15322. */
  15323. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15324. /**
  15325. * Prepare internal position array for software CPU skinning
  15326. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15327. */
  15328. setPositionsForCPUSkinning(): Float32Array;
  15329. /**
  15330. * Prepare internal normal array for software CPU skinning
  15331. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15332. */
  15333. setNormalsForCPUSkinning(): Float32Array;
  15334. /**
  15335. * Updates the vertex buffer by applying transformation from the bones
  15336. * @param skeleton defines the skeleton to apply to current mesh
  15337. * @returns the current mesh
  15338. */
  15339. applySkeleton(skeleton: Skeleton): Mesh;
  15340. /**
  15341. * 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
  15342. * @param meshes defines the list of meshes to scan
  15343. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15344. */
  15345. static MinMax(meshes: AbstractMesh[]): {
  15346. min: Vector3;
  15347. max: Vector3;
  15348. };
  15349. /**
  15350. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15351. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15352. * @returns a vector3
  15353. */
  15354. static Center(meshesOrMinMaxVector: {
  15355. min: Vector3;
  15356. max: Vector3;
  15357. } | AbstractMesh[]): Vector3;
  15358. /**
  15359. * Merge the array of meshes into a single mesh for performance reasons.
  15360. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15361. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15362. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15363. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15364. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15365. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15366. * @returns a new mesh
  15367. */
  15368. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15369. /** @hidden */
  15370. addInstance(instance: InstancedMesh): void;
  15371. /** @hidden */
  15372. removeInstance(instance: InstancedMesh): void;
  15373. }
  15374. }
  15375. declare module "babylonjs/Actions/action" {
  15376. import { Observable } from "babylonjs/Misc/observable";
  15377. import { Condition } from "babylonjs/Actions/condition";
  15378. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15379. import { ActionManager } from "babylonjs/Actions/actionManager";
  15380. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15381. /**
  15382. * Interface used to define Action
  15383. */
  15384. export interface IAction {
  15385. /**
  15386. * Trigger for the action
  15387. */
  15388. trigger: number;
  15389. /** Options of the trigger */
  15390. triggerOptions: any;
  15391. /**
  15392. * Gets the trigger parameters
  15393. * @returns the trigger parameters
  15394. */
  15395. getTriggerParameter(): any;
  15396. /**
  15397. * Internal only - executes current action event
  15398. * @hidden
  15399. */
  15400. _executeCurrent(evt?: ActionEvent): void;
  15401. /**
  15402. * Serialize placeholder for child classes
  15403. * @param parent of child
  15404. * @returns the serialized object
  15405. */
  15406. serialize(parent: any): any;
  15407. /**
  15408. * Internal only
  15409. * @hidden
  15410. */
  15411. _prepare(): void;
  15412. /**
  15413. * Internal only - manager for action
  15414. * @hidden
  15415. */
  15416. _actionManager: AbstractActionManager;
  15417. /**
  15418. * Adds action to chain of actions, may be a DoNothingAction
  15419. * @param action defines the next action to execute
  15420. * @returns The action passed in
  15421. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15422. */
  15423. then(action: IAction): IAction;
  15424. }
  15425. /**
  15426. * The action to be carried out following a trigger
  15427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15428. */
  15429. export class Action implements IAction {
  15430. /** the trigger, with or without parameters, for the action */
  15431. triggerOptions: any;
  15432. /**
  15433. * Trigger for the action
  15434. */
  15435. trigger: number;
  15436. /**
  15437. * Internal only - manager for action
  15438. * @hidden
  15439. */
  15440. _actionManager: ActionManager;
  15441. private _nextActiveAction;
  15442. private _child;
  15443. private _condition?;
  15444. private _triggerParameter;
  15445. /**
  15446. * An event triggered prior to action being executed.
  15447. */
  15448. onBeforeExecuteObservable: Observable<Action>;
  15449. /**
  15450. * Creates a new Action
  15451. * @param triggerOptions the trigger, with or without parameters, for the action
  15452. * @param condition an optional determinant of action
  15453. */
  15454. constructor(
  15455. /** the trigger, with or without parameters, for the action */
  15456. triggerOptions: any, condition?: Condition);
  15457. /**
  15458. * Internal only
  15459. * @hidden
  15460. */
  15461. _prepare(): void;
  15462. /**
  15463. * Gets the trigger parameters
  15464. * @returns the trigger parameters
  15465. */
  15466. getTriggerParameter(): any;
  15467. /**
  15468. * Internal only - executes current action event
  15469. * @hidden
  15470. */
  15471. _executeCurrent(evt?: ActionEvent): void;
  15472. /**
  15473. * Execute placeholder for child classes
  15474. * @param evt optional action event
  15475. */
  15476. execute(evt?: ActionEvent): void;
  15477. /**
  15478. * Skips to next active action
  15479. */
  15480. skipToNextActiveAction(): void;
  15481. /**
  15482. * Adds action to chain of actions, may be a DoNothingAction
  15483. * @param action defines the next action to execute
  15484. * @returns The action passed in
  15485. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15486. */
  15487. then(action: Action): Action;
  15488. /**
  15489. * Internal only
  15490. * @hidden
  15491. */
  15492. _getProperty(propertyPath: string): string;
  15493. /**
  15494. * Internal only
  15495. * @hidden
  15496. */
  15497. _getEffectiveTarget(target: any, propertyPath: string): any;
  15498. /**
  15499. * Serialize placeholder for child classes
  15500. * @param parent of child
  15501. * @returns the serialized object
  15502. */
  15503. serialize(parent: any): any;
  15504. /**
  15505. * Internal only called by serialize
  15506. * @hidden
  15507. */
  15508. protected _serialize(serializedAction: any, parent?: any): any;
  15509. /**
  15510. * Internal only
  15511. * @hidden
  15512. */
  15513. static _SerializeValueAsString: (value: any) => string;
  15514. /**
  15515. * Internal only
  15516. * @hidden
  15517. */
  15518. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15519. name: string;
  15520. targetType: string;
  15521. value: string;
  15522. };
  15523. }
  15524. }
  15525. declare module "babylonjs/Actions/condition" {
  15526. import { ActionManager } from "babylonjs/Actions/actionManager";
  15527. /**
  15528. * A Condition applied to an Action
  15529. */
  15530. export class Condition {
  15531. /**
  15532. * Internal only - manager for action
  15533. * @hidden
  15534. */
  15535. _actionManager: ActionManager;
  15536. /**
  15537. * Internal only
  15538. * @hidden
  15539. */
  15540. _evaluationId: number;
  15541. /**
  15542. * Internal only
  15543. * @hidden
  15544. */
  15545. _currentResult: boolean;
  15546. /**
  15547. * Creates a new Condition
  15548. * @param actionManager the manager of the action the condition is applied to
  15549. */
  15550. constructor(actionManager: ActionManager);
  15551. /**
  15552. * Check if the current condition is valid
  15553. * @returns a boolean
  15554. */
  15555. isValid(): boolean;
  15556. /**
  15557. * Internal only
  15558. * @hidden
  15559. */
  15560. _getProperty(propertyPath: string): string;
  15561. /**
  15562. * Internal only
  15563. * @hidden
  15564. */
  15565. _getEffectiveTarget(target: any, propertyPath: string): any;
  15566. /**
  15567. * Serialize placeholder for child classes
  15568. * @returns the serialized object
  15569. */
  15570. serialize(): any;
  15571. /**
  15572. * Internal only
  15573. * @hidden
  15574. */
  15575. protected _serialize(serializedCondition: any): any;
  15576. }
  15577. /**
  15578. * Defines specific conditional operators as extensions of Condition
  15579. */
  15580. export class ValueCondition extends Condition {
  15581. /** path to specify the property of the target the conditional operator uses */
  15582. propertyPath: string;
  15583. /** the value compared by the conditional operator against the current value of the property */
  15584. value: any;
  15585. /** the conditional operator, default ValueCondition.IsEqual */
  15586. operator: number;
  15587. /**
  15588. * Internal only
  15589. * @hidden
  15590. */
  15591. private static _IsEqual;
  15592. /**
  15593. * Internal only
  15594. * @hidden
  15595. */
  15596. private static _IsDifferent;
  15597. /**
  15598. * Internal only
  15599. * @hidden
  15600. */
  15601. private static _IsGreater;
  15602. /**
  15603. * Internal only
  15604. * @hidden
  15605. */
  15606. private static _IsLesser;
  15607. /**
  15608. * returns the number for IsEqual
  15609. */
  15610. static readonly IsEqual: number;
  15611. /**
  15612. * Returns the number for IsDifferent
  15613. */
  15614. static readonly IsDifferent: number;
  15615. /**
  15616. * Returns the number for IsGreater
  15617. */
  15618. static readonly IsGreater: number;
  15619. /**
  15620. * Returns the number for IsLesser
  15621. */
  15622. static readonly IsLesser: number;
  15623. /**
  15624. * Internal only The action manager for the condition
  15625. * @hidden
  15626. */
  15627. _actionManager: ActionManager;
  15628. /**
  15629. * Internal only
  15630. * @hidden
  15631. */
  15632. private _target;
  15633. /**
  15634. * Internal only
  15635. * @hidden
  15636. */
  15637. private _effectiveTarget;
  15638. /**
  15639. * Internal only
  15640. * @hidden
  15641. */
  15642. private _property;
  15643. /**
  15644. * Creates a new ValueCondition
  15645. * @param actionManager manager for the action the condition applies to
  15646. * @param target for the action
  15647. * @param propertyPath path to specify the property of the target the conditional operator uses
  15648. * @param value the value compared by the conditional operator against the current value of the property
  15649. * @param operator the conditional operator, default ValueCondition.IsEqual
  15650. */
  15651. constructor(actionManager: ActionManager, target: any,
  15652. /** path to specify the property of the target the conditional operator uses */
  15653. propertyPath: string,
  15654. /** the value compared by the conditional operator against the current value of the property */
  15655. value: any,
  15656. /** the conditional operator, default ValueCondition.IsEqual */
  15657. operator?: number);
  15658. /**
  15659. * Compares the given value with the property value for the specified conditional operator
  15660. * @returns the result of the comparison
  15661. */
  15662. isValid(): boolean;
  15663. /**
  15664. * Serialize the ValueCondition into a JSON compatible object
  15665. * @returns serialization object
  15666. */
  15667. serialize(): any;
  15668. /**
  15669. * Gets the name of the conditional operator for the ValueCondition
  15670. * @param operator the conditional operator
  15671. * @returns the name
  15672. */
  15673. static GetOperatorName(operator: number): string;
  15674. }
  15675. /**
  15676. * Defines a predicate condition as an extension of Condition
  15677. */
  15678. export class PredicateCondition extends Condition {
  15679. /** defines the predicate function used to validate the condition */
  15680. predicate: () => boolean;
  15681. /**
  15682. * Internal only - manager for action
  15683. * @hidden
  15684. */
  15685. _actionManager: ActionManager;
  15686. /**
  15687. * Creates a new PredicateCondition
  15688. * @param actionManager manager for the action the condition applies to
  15689. * @param predicate defines the predicate function used to validate the condition
  15690. */
  15691. constructor(actionManager: ActionManager,
  15692. /** defines the predicate function used to validate the condition */
  15693. predicate: () => boolean);
  15694. /**
  15695. * @returns the validity of the predicate condition
  15696. */
  15697. isValid(): boolean;
  15698. }
  15699. /**
  15700. * Defines a state condition as an extension of Condition
  15701. */
  15702. export class StateCondition extends Condition {
  15703. /** Value to compare with target state */
  15704. value: string;
  15705. /**
  15706. * Internal only - manager for action
  15707. * @hidden
  15708. */
  15709. _actionManager: ActionManager;
  15710. /**
  15711. * Internal only
  15712. * @hidden
  15713. */
  15714. private _target;
  15715. /**
  15716. * Creates a new StateCondition
  15717. * @param actionManager manager for the action the condition applies to
  15718. * @param target of the condition
  15719. * @param value to compare with target state
  15720. */
  15721. constructor(actionManager: ActionManager, target: any,
  15722. /** Value to compare with target state */
  15723. value: string);
  15724. /**
  15725. * Gets a boolean indicating if the current condition is met
  15726. * @returns the validity of the state
  15727. */
  15728. isValid(): boolean;
  15729. /**
  15730. * Serialize the StateCondition into a JSON compatible object
  15731. * @returns serialization object
  15732. */
  15733. serialize(): any;
  15734. }
  15735. }
  15736. declare module "babylonjs/Actions/directActions" {
  15737. import { Action } from "babylonjs/Actions/action";
  15738. import { Condition } from "babylonjs/Actions/condition";
  15739. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15740. /**
  15741. * This defines an action responsible to toggle a boolean once triggered.
  15742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15743. */
  15744. export class SwitchBooleanAction extends Action {
  15745. /**
  15746. * The path to the boolean property in the target object
  15747. */
  15748. propertyPath: string;
  15749. private _target;
  15750. private _effectiveTarget;
  15751. private _property;
  15752. /**
  15753. * Instantiate the action
  15754. * @param triggerOptions defines the trigger options
  15755. * @param target defines the object containing the boolean
  15756. * @param propertyPath defines the path to the boolean property in the target object
  15757. * @param condition defines the trigger related conditions
  15758. */
  15759. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15760. /** @hidden */
  15761. _prepare(): void;
  15762. /**
  15763. * Execute the action toggle the boolean value.
  15764. */
  15765. execute(): void;
  15766. /**
  15767. * Serializes the actions and its related information.
  15768. * @param parent defines the object to serialize in
  15769. * @returns the serialized object
  15770. */
  15771. serialize(parent: any): any;
  15772. }
  15773. /**
  15774. * This defines an action responsible to set a the state field of the target
  15775. * to a desired value once triggered.
  15776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15777. */
  15778. export class SetStateAction extends Action {
  15779. /**
  15780. * The value to store in the state field.
  15781. */
  15782. value: string;
  15783. private _target;
  15784. /**
  15785. * Instantiate the action
  15786. * @param triggerOptions defines the trigger options
  15787. * @param target defines the object containing the state property
  15788. * @param value defines the value to store in the state field
  15789. * @param condition defines the trigger related conditions
  15790. */
  15791. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15792. /**
  15793. * Execute the action and store the value on the target state property.
  15794. */
  15795. execute(): void;
  15796. /**
  15797. * Serializes the actions and its related information.
  15798. * @param parent defines the object to serialize in
  15799. * @returns the serialized object
  15800. */
  15801. serialize(parent: any): any;
  15802. }
  15803. /**
  15804. * This defines an action responsible to set a property of the target
  15805. * to a desired value once triggered.
  15806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15807. */
  15808. export class SetValueAction extends Action {
  15809. /**
  15810. * The path of the property to set in the target.
  15811. */
  15812. propertyPath: string;
  15813. /**
  15814. * The value to set in the property
  15815. */
  15816. value: any;
  15817. private _target;
  15818. private _effectiveTarget;
  15819. private _property;
  15820. /**
  15821. * Instantiate the action
  15822. * @param triggerOptions defines the trigger options
  15823. * @param target defines the object containing the property
  15824. * @param propertyPath defines the path of the property to set in the target
  15825. * @param value defines the value to set in the property
  15826. * @param condition defines the trigger related conditions
  15827. */
  15828. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15829. /** @hidden */
  15830. _prepare(): void;
  15831. /**
  15832. * Execute the action and set the targetted property to the desired value.
  15833. */
  15834. execute(): void;
  15835. /**
  15836. * Serializes the actions and its related information.
  15837. * @param parent defines the object to serialize in
  15838. * @returns the serialized object
  15839. */
  15840. serialize(parent: any): any;
  15841. }
  15842. /**
  15843. * This defines an action responsible to increment the target value
  15844. * to a desired value once triggered.
  15845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15846. */
  15847. export class IncrementValueAction extends Action {
  15848. /**
  15849. * The path of the property to increment in the target.
  15850. */
  15851. propertyPath: string;
  15852. /**
  15853. * The value we should increment the property by.
  15854. */
  15855. value: any;
  15856. private _target;
  15857. private _effectiveTarget;
  15858. private _property;
  15859. /**
  15860. * Instantiate the action
  15861. * @param triggerOptions defines the trigger options
  15862. * @param target defines the object containing the property
  15863. * @param propertyPath defines the path of the property to increment in the target
  15864. * @param value defines the value value we should increment the property by
  15865. * @param condition defines the trigger related conditions
  15866. */
  15867. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15868. /** @hidden */
  15869. _prepare(): void;
  15870. /**
  15871. * Execute the action and increment the target of the value amount.
  15872. */
  15873. execute(): void;
  15874. /**
  15875. * Serializes the actions and its related information.
  15876. * @param parent defines the object to serialize in
  15877. * @returns the serialized object
  15878. */
  15879. serialize(parent: any): any;
  15880. }
  15881. /**
  15882. * This defines an action responsible to start an animation once triggered.
  15883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15884. */
  15885. export class PlayAnimationAction extends Action {
  15886. /**
  15887. * Where the animation should start (animation frame)
  15888. */
  15889. from: number;
  15890. /**
  15891. * Where the animation should stop (animation frame)
  15892. */
  15893. to: number;
  15894. /**
  15895. * Define if the animation should loop or stop after the first play.
  15896. */
  15897. loop?: boolean;
  15898. private _target;
  15899. /**
  15900. * Instantiate the action
  15901. * @param triggerOptions defines the trigger options
  15902. * @param target defines the target animation or animation name
  15903. * @param from defines from where the animation should start (animation frame)
  15904. * @param end defines where the animation should stop (animation frame)
  15905. * @param loop defines if the animation should loop or stop after the first play
  15906. * @param condition defines the trigger related conditions
  15907. */
  15908. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15909. /** @hidden */
  15910. _prepare(): void;
  15911. /**
  15912. * Execute the action and play the animation.
  15913. */
  15914. execute(): void;
  15915. /**
  15916. * Serializes the actions and its related information.
  15917. * @param parent defines the object to serialize in
  15918. * @returns the serialized object
  15919. */
  15920. serialize(parent: any): any;
  15921. }
  15922. /**
  15923. * This defines an action responsible to stop an animation once triggered.
  15924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15925. */
  15926. export class StopAnimationAction extends Action {
  15927. private _target;
  15928. /**
  15929. * Instantiate the action
  15930. * @param triggerOptions defines the trigger options
  15931. * @param target defines the target animation or animation name
  15932. * @param condition defines the trigger related conditions
  15933. */
  15934. constructor(triggerOptions: any, target: any, condition?: Condition);
  15935. /** @hidden */
  15936. _prepare(): void;
  15937. /**
  15938. * Execute the action and stop the animation.
  15939. */
  15940. execute(): void;
  15941. /**
  15942. * Serializes the actions and its related information.
  15943. * @param parent defines the object to serialize in
  15944. * @returns the serialized object
  15945. */
  15946. serialize(parent: any): any;
  15947. }
  15948. /**
  15949. * This defines an action responsible that does nothing once triggered.
  15950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15951. */
  15952. export class DoNothingAction extends Action {
  15953. /**
  15954. * Instantiate the action
  15955. * @param triggerOptions defines the trigger options
  15956. * @param condition defines the trigger related conditions
  15957. */
  15958. constructor(triggerOptions?: any, condition?: Condition);
  15959. /**
  15960. * Execute the action and do nothing.
  15961. */
  15962. execute(): void;
  15963. /**
  15964. * Serializes the actions and its related information.
  15965. * @param parent defines the object to serialize in
  15966. * @returns the serialized object
  15967. */
  15968. serialize(parent: any): any;
  15969. }
  15970. /**
  15971. * This defines an action responsible to trigger several actions once triggered.
  15972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15973. */
  15974. export class CombineAction extends Action {
  15975. /**
  15976. * The list of aggregated animations to run.
  15977. */
  15978. children: Action[];
  15979. /**
  15980. * Instantiate the action
  15981. * @param triggerOptions defines the trigger options
  15982. * @param children defines the list of aggregated animations to run
  15983. * @param condition defines the trigger related conditions
  15984. */
  15985. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15986. /** @hidden */
  15987. _prepare(): void;
  15988. /**
  15989. * Execute the action and executes all the aggregated actions.
  15990. */
  15991. execute(evt: ActionEvent): void;
  15992. /**
  15993. * Serializes the actions and its related information.
  15994. * @param parent defines the object to serialize in
  15995. * @returns the serialized object
  15996. */
  15997. serialize(parent: any): any;
  15998. }
  15999. /**
  16000. * This defines an action responsible to run code (external event) once triggered.
  16001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16002. */
  16003. export class ExecuteCodeAction extends Action {
  16004. /**
  16005. * The callback function to run.
  16006. */
  16007. func: (evt: ActionEvent) => void;
  16008. /**
  16009. * Instantiate the action
  16010. * @param triggerOptions defines the trigger options
  16011. * @param func defines the callback function to run
  16012. * @param condition defines the trigger related conditions
  16013. */
  16014. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16015. /**
  16016. * Execute the action and run the attached code.
  16017. */
  16018. execute(evt: ActionEvent): void;
  16019. }
  16020. /**
  16021. * This defines an action responsible to set the parent property of the target once triggered.
  16022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16023. */
  16024. export class SetParentAction extends Action {
  16025. private _parent;
  16026. private _target;
  16027. /**
  16028. * Instantiate the action
  16029. * @param triggerOptions defines the trigger options
  16030. * @param target defines the target containing the parent property
  16031. * @param parent defines from where the animation should start (animation frame)
  16032. * @param condition defines the trigger related conditions
  16033. */
  16034. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16035. /** @hidden */
  16036. _prepare(): void;
  16037. /**
  16038. * Execute the action and set the parent property.
  16039. */
  16040. execute(): void;
  16041. /**
  16042. * Serializes the actions and its related information.
  16043. * @param parent defines the object to serialize in
  16044. * @returns the serialized object
  16045. */
  16046. serialize(parent: any): any;
  16047. }
  16048. }
  16049. declare module "babylonjs/Actions/actionManager" {
  16050. import { Nullable } from "babylonjs/types";
  16051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16052. import { Scene } from "babylonjs/scene";
  16053. import { IAction } from "babylonjs/Actions/action";
  16054. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16055. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16056. /**
  16057. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16058. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16060. */
  16061. export class ActionManager extends AbstractActionManager {
  16062. /**
  16063. * Nothing
  16064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16065. */
  16066. static readonly NothingTrigger: number;
  16067. /**
  16068. * On pick
  16069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16070. */
  16071. static readonly OnPickTrigger: number;
  16072. /**
  16073. * On left pick
  16074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16075. */
  16076. static readonly OnLeftPickTrigger: number;
  16077. /**
  16078. * On right pick
  16079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16080. */
  16081. static readonly OnRightPickTrigger: number;
  16082. /**
  16083. * On center pick
  16084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16085. */
  16086. static readonly OnCenterPickTrigger: number;
  16087. /**
  16088. * On pick down
  16089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16090. */
  16091. static readonly OnPickDownTrigger: number;
  16092. /**
  16093. * On double pick
  16094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16095. */
  16096. static readonly OnDoublePickTrigger: number;
  16097. /**
  16098. * On pick up
  16099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16100. */
  16101. static readonly OnPickUpTrigger: number;
  16102. /**
  16103. * On pick out.
  16104. * This trigger will only be raised if you also declared a OnPickDown
  16105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16106. */
  16107. static readonly OnPickOutTrigger: number;
  16108. /**
  16109. * On long press
  16110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16111. */
  16112. static readonly OnLongPressTrigger: number;
  16113. /**
  16114. * On pointer over
  16115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16116. */
  16117. static readonly OnPointerOverTrigger: number;
  16118. /**
  16119. * On pointer out
  16120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16121. */
  16122. static readonly OnPointerOutTrigger: number;
  16123. /**
  16124. * On every frame
  16125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16126. */
  16127. static readonly OnEveryFrameTrigger: number;
  16128. /**
  16129. * On intersection enter
  16130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16131. */
  16132. static readonly OnIntersectionEnterTrigger: number;
  16133. /**
  16134. * On intersection exit
  16135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16136. */
  16137. static readonly OnIntersectionExitTrigger: number;
  16138. /**
  16139. * On key down
  16140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16141. */
  16142. static readonly OnKeyDownTrigger: number;
  16143. /**
  16144. * On key up
  16145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16146. */
  16147. static readonly OnKeyUpTrigger: number;
  16148. private _scene;
  16149. /**
  16150. * Creates a new action manager
  16151. * @param scene defines the hosting scene
  16152. */
  16153. constructor(scene: Scene);
  16154. /**
  16155. * Releases all associated resources
  16156. */
  16157. dispose(): void;
  16158. /**
  16159. * Gets hosting scene
  16160. * @returns the hosting scene
  16161. */
  16162. getScene(): Scene;
  16163. /**
  16164. * Does this action manager handles actions of any of the given triggers
  16165. * @param triggers defines the triggers to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers(triggers: number[]): boolean;
  16169. /**
  16170. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16171. * speed.
  16172. * @param triggerA defines the trigger to be tested
  16173. * @param triggerB defines the trigger to be tested
  16174. * @return a boolean indicating whether one (or more) of the triggers is handled
  16175. */
  16176. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16177. /**
  16178. * Does this action manager handles actions of a given trigger
  16179. * @param trigger defines the trigger to be tested
  16180. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16181. * @return whether the trigger is handled
  16182. */
  16183. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16184. /**
  16185. * Does this action manager has pointer triggers
  16186. */
  16187. readonly hasPointerTriggers: boolean;
  16188. /**
  16189. * Does this action manager has pick triggers
  16190. */
  16191. readonly hasPickTriggers: boolean;
  16192. /**
  16193. * Registers an action to this action manager
  16194. * @param action defines the action to be registered
  16195. * @return the action amended (prepared) after registration
  16196. */
  16197. registerAction(action: IAction): Nullable<IAction>;
  16198. /**
  16199. * Unregisters an action to this action manager
  16200. * @param action defines the action to be unregistered
  16201. * @return a boolean indicating whether the action has been unregistered
  16202. */
  16203. unregisterAction(action: IAction): Boolean;
  16204. /**
  16205. * Process a specific trigger
  16206. * @param trigger defines the trigger to process
  16207. * @param evt defines the event details to be processed
  16208. */
  16209. processTrigger(trigger: number, evt?: IActionEvent): void;
  16210. /** @hidden */
  16211. _getEffectiveTarget(target: any, propertyPath: string): any;
  16212. /** @hidden */
  16213. _getProperty(propertyPath: string): string;
  16214. /**
  16215. * Serialize this manager to a JSON object
  16216. * @param name defines the property name to store this manager
  16217. * @returns a JSON representation of this manager
  16218. */
  16219. serialize(name: string): any;
  16220. /**
  16221. * Creates a new ActionManager from a JSON data
  16222. * @param parsedActions defines the JSON data to read from
  16223. * @param object defines the hosting mesh
  16224. * @param scene defines the hosting scene
  16225. */
  16226. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16227. /**
  16228. * Get a trigger name by index
  16229. * @param trigger defines the trigger index
  16230. * @returns a trigger name
  16231. */
  16232. static GetTriggerName(trigger: number): string;
  16233. }
  16234. }
  16235. declare module "babylonjs/Culling/ray" {
  16236. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16237. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16239. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16240. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16241. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16242. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16243. /**
  16244. * Class representing a ray with position and direction
  16245. */
  16246. export class Ray {
  16247. /** origin point */
  16248. origin: Vector3;
  16249. /** direction */
  16250. direction: Vector3;
  16251. /** length of the ray */
  16252. length: number;
  16253. private static readonly TmpVector3;
  16254. private _tmpRay;
  16255. /**
  16256. * Creates a new ray
  16257. * @param origin origin point
  16258. * @param direction direction
  16259. * @param length length of the ray
  16260. */
  16261. constructor(
  16262. /** origin point */
  16263. origin: Vector3,
  16264. /** direction */
  16265. direction: Vector3,
  16266. /** length of the ray */
  16267. length?: number);
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param minimum bound of the box
  16271. * @param maximum bound of the box
  16272. * @param intersectionTreshold extra extend to be added to the box in all direction
  16273. * @returns if the box was hit
  16274. */
  16275. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16276. /**
  16277. * Checks if the ray intersects a box
  16278. * @param box the bounding box to check
  16279. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16280. * @returns if the box was hit
  16281. */
  16282. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16283. /**
  16284. * If the ray hits a sphere
  16285. * @param sphere the bounding sphere to check
  16286. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16287. * @returns true if it hits the sphere
  16288. */
  16289. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16290. /**
  16291. * If the ray hits a triange
  16292. * @param vertex0 triangle vertex
  16293. * @param vertex1 triangle vertex
  16294. * @param vertex2 triangle vertex
  16295. * @returns intersection information if hit
  16296. */
  16297. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16298. /**
  16299. * Checks if ray intersects a plane
  16300. * @param plane the plane to check
  16301. * @returns the distance away it was hit
  16302. */
  16303. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16304. /**
  16305. * Calculate the intercept of a ray on a given axis
  16306. * @param axis to check 'x' | 'y' | 'z'
  16307. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  16308. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  16309. */
  16310. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  16311. /**
  16312. * Checks if ray intersects a mesh
  16313. * @param mesh the mesh to check
  16314. * @param fastCheck if only the bounding box should checked
  16315. * @returns picking info of the intersecton
  16316. */
  16317. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16318. /**
  16319. * Checks if ray intersects a mesh
  16320. * @param meshes the meshes to check
  16321. * @param fastCheck if only the bounding box should checked
  16322. * @param results array to store result in
  16323. * @returns Array of picking infos
  16324. */
  16325. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16326. private _comparePickingInfo;
  16327. private static smallnum;
  16328. private static rayl;
  16329. /**
  16330. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16331. * @param sega the first point of the segment to test the intersection against
  16332. * @param segb the second point of the segment to test the intersection against
  16333. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16334. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16335. */
  16336. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16337. /**
  16338. * Update the ray from viewport position
  16339. * @param x position
  16340. * @param y y position
  16341. * @param viewportWidth viewport width
  16342. * @param viewportHeight viewport height
  16343. * @param world world matrix
  16344. * @param view view matrix
  16345. * @param projection projection matrix
  16346. * @returns this ray updated
  16347. */
  16348. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16349. /**
  16350. * Creates a ray with origin and direction of 0,0,0
  16351. * @returns the new ray
  16352. */
  16353. static Zero(): Ray;
  16354. /**
  16355. * Creates a new ray from screen space and viewport
  16356. * @param x position
  16357. * @param y y position
  16358. * @param viewportWidth viewport width
  16359. * @param viewportHeight viewport height
  16360. * @param world world matrix
  16361. * @param view view matrix
  16362. * @param projection projection matrix
  16363. * @returns new ray
  16364. */
  16365. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16366. /**
  16367. * 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
  16368. * transformed to the given world matrix.
  16369. * @param origin The origin point
  16370. * @param end The end point
  16371. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16372. * @returns the new ray
  16373. */
  16374. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16375. /**
  16376. * Transforms a ray by a matrix
  16377. * @param ray ray to transform
  16378. * @param matrix matrix to apply
  16379. * @returns the resulting new ray
  16380. */
  16381. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16382. /**
  16383. * Transforms a ray by a matrix
  16384. * @param ray ray to transform
  16385. * @param matrix matrix to apply
  16386. * @param result ray to store result in
  16387. */
  16388. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16389. /**
  16390. * Unproject a ray from screen space to object space
  16391. * @param sourceX defines the screen space x coordinate to use
  16392. * @param sourceY defines the screen space y coordinate to use
  16393. * @param viewportWidth defines the current width of the viewport
  16394. * @param viewportHeight defines the current height of the viewport
  16395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16396. * @param view defines the view matrix to use
  16397. * @param projection defines the projection matrix to use
  16398. */
  16399. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16400. }
  16401. /**
  16402. * Type used to define predicate used to select faces when a mesh intersection is detected
  16403. */
  16404. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16405. module "babylonjs/scene" {
  16406. interface Scene {
  16407. /** @hidden */
  16408. _tempPickingRay: Nullable<Ray>;
  16409. /** @hidden */
  16410. _cachedRayForTransform: Ray;
  16411. /** @hidden */
  16412. _pickWithRayInverseMatrix: Matrix;
  16413. /** @hidden */
  16414. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16415. /** @hidden */
  16416. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16417. }
  16418. }
  16419. }
  16420. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16421. import { Nullable } from "babylonjs/types";
  16422. import { Observable } from "babylonjs/Misc/observable";
  16423. import { Scene } from "babylonjs/scene";
  16424. import { Sprite } from "babylonjs/Sprites/sprite";
  16425. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16426. import { Ray } from "babylonjs/Culling/ray";
  16427. import { Camera } from "babylonjs/Cameras/camera";
  16428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16429. import { ISceneComponent } from "babylonjs/sceneComponent";
  16430. module "babylonjs/scene" {
  16431. interface Scene {
  16432. /** @hidden */
  16433. _pointerOverSprite: Nullable<Sprite>;
  16434. /** @hidden */
  16435. _pickedDownSprite: Nullable<Sprite>;
  16436. /** @hidden */
  16437. _tempSpritePickingRay: Nullable<Ray>;
  16438. /**
  16439. * All of the sprite managers added to this scene
  16440. * @see http://doc.babylonjs.com/babylon101/sprites
  16441. */
  16442. spriteManagers: Array<ISpriteManager>;
  16443. /**
  16444. * An event triggered when sprites rendering is about to start
  16445. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16446. */
  16447. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16448. /**
  16449. * An event triggered when sprites rendering is done
  16450. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16451. */
  16452. onAfterSpritesRenderingObservable: Observable<Scene>;
  16453. /** @hidden */
  16454. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16455. /** Launch a ray to try to pick a sprite in the scene
  16456. * @param x position on screen
  16457. * @param y position on screen
  16458. * @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
  16459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16460. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16461. * @returns a PickingInfo
  16462. */
  16463. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16464. /** Use the given ray to pick a sprite in the scene
  16465. * @param ray The ray (in world space) to use to pick meshes
  16466. * @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
  16467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16468. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16469. * @returns a PickingInfo
  16470. */
  16471. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16472. /**
  16473. * Force the sprite under the pointer
  16474. * @param sprite defines the sprite to use
  16475. */
  16476. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16477. /**
  16478. * Gets the sprite under the pointer
  16479. * @returns a Sprite or null if no sprite is under the pointer
  16480. */
  16481. getPointerOverSprite(): Nullable<Sprite>;
  16482. }
  16483. }
  16484. /**
  16485. * Defines the sprite scene component responsible to manage sprites
  16486. * in a given scene.
  16487. */
  16488. export class SpriteSceneComponent implements ISceneComponent {
  16489. /**
  16490. * The component name helpfull to identify the component in the list of scene components.
  16491. */
  16492. readonly name: string;
  16493. /**
  16494. * The scene the component belongs to.
  16495. */
  16496. scene: Scene;
  16497. /** @hidden */
  16498. private _spritePredicate;
  16499. /**
  16500. * Creates a new instance of the component for the given scene
  16501. * @param scene Defines the scene to register the component in
  16502. */
  16503. constructor(scene: Scene);
  16504. /**
  16505. * Registers the component in a given scene
  16506. */
  16507. register(): void;
  16508. /**
  16509. * Rebuilds the elements related to this component in case of
  16510. * context lost for instance.
  16511. */
  16512. rebuild(): void;
  16513. /**
  16514. * Disposes the component and the associated ressources.
  16515. */
  16516. dispose(): void;
  16517. private _pickSpriteButKeepRay;
  16518. private _pointerMove;
  16519. private _pointerDown;
  16520. private _pointerUp;
  16521. }
  16522. }
  16523. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16524. /** @hidden */
  16525. export var fogFragmentDeclaration: {
  16526. name: string;
  16527. shader: string;
  16528. };
  16529. }
  16530. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16531. /** @hidden */
  16532. export var fogFragment: {
  16533. name: string;
  16534. shader: string;
  16535. };
  16536. }
  16537. declare module "babylonjs/Shaders/sprites.fragment" {
  16538. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16539. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16540. /** @hidden */
  16541. export var spritesPixelShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16547. /** @hidden */
  16548. export var fogVertexDeclaration: {
  16549. name: string;
  16550. shader: string;
  16551. };
  16552. }
  16553. declare module "babylonjs/Shaders/sprites.vertex" {
  16554. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16555. /** @hidden */
  16556. export var spritesVertexShader: {
  16557. name: string;
  16558. shader: string;
  16559. };
  16560. }
  16561. declare module "babylonjs/Sprites/spriteManager" {
  16562. import { IDisposable, Scene } from "babylonjs/scene";
  16563. import { Nullable } from "babylonjs/types";
  16564. import { Observable } from "babylonjs/Misc/observable";
  16565. import { Sprite } from "babylonjs/Sprites/sprite";
  16566. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16567. import { Camera } from "babylonjs/Cameras/camera";
  16568. import { Texture } from "babylonjs/Materials/Textures/texture";
  16569. import "babylonjs/Shaders/sprites.fragment";
  16570. import "babylonjs/Shaders/sprites.vertex";
  16571. import { Ray } from "babylonjs/Culling/ray";
  16572. /**
  16573. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16574. */
  16575. export interface ISpriteManager extends IDisposable {
  16576. /**
  16577. * Restricts the camera to viewing objects with the same layerMask.
  16578. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16579. */
  16580. layerMask: number;
  16581. /**
  16582. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16583. */
  16584. isPickable: boolean;
  16585. /**
  16586. * Specifies the rendering group id for this mesh (0 by default)
  16587. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16588. */
  16589. renderingGroupId: number;
  16590. /**
  16591. * Defines the list of sprites managed by the manager.
  16592. */
  16593. sprites: Array<Sprite>;
  16594. /**
  16595. * Tests the intersection of a sprite with a specific ray.
  16596. * @param ray The ray we are sending to test the collision
  16597. * @param camera The camera space we are sending rays in
  16598. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16599. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16600. * @returns picking info or null.
  16601. */
  16602. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16603. /**
  16604. * Renders the list of sprites on screen.
  16605. */
  16606. render(): void;
  16607. }
  16608. /**
  16609. * Class used to manage multiple sprites on the same spritesheet
  16610. * @see http://doc.babylonjs.com/babylon101/sprites
  16611. */
  16612. export class SpriteManager implements ISpriteManager {
  16613. /** defines the manager's name */
  16614. name: string;
  16615. /** Gets the list of sprites */
  16616. sprites: Sprite[];
  16617. /** Gets or sets the rendering group id (0 by default) */
  16618. renderingGroupId: number;
  16619. /** Gets or sets camera layer mask */
  16620. layerMask: number;
  16621. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16622. fogEnabled: boolean;
  16623. /** Gets or sets a boolean indicating if the sprites are pickable */
  16624. isPickable: boolean;
  16625. /** Defines the default width of a cell in the spritesheet */
  16626. cellWidth: number;
  16627. /** Defines the default height of a cell in the spritesheet */
  16628. cellHeight: number;
  16629. /**
  16630. * An event triggered when the manager is disposed.
  16631. */
  16632. onDisposeObservable: Observable<SpriteManager>;
  16633. private _onDisposeObserver;
  16634. /**
  16635. * Callback called when the manager is disposed
  16636. */
  16637. onDispose: () => void;
  16638. private _capacity;
  16639. private _spriteTexture;
  16640. private _epsilon;
  16641. private _scene;
  16642. private _vertexData;
  16643. private _buffer;
  16644. private _vertexBuffers;
  16645. private _indexBuffer;
  16646. private _effectBase;
  16647. private _effectFog;
  16648. /**
  16649. * Gets or sets the spritesheet texture
  16650. */
  16651. texture: Texture;
  16652. /**
  16653. * Creates a new sprite manager
  16654. * @param name defines the manager's name
  16655. * @param imgUrl defines the sprite sheet url
  16656. * @param capacity defines the maximum allowed number of sprites
  16657. * @param cellSize defines the size of a sprite cell
  16658. * @param scene defines the hosting scene
  16659. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16660. * @param samplingMode defines the smapling mode to use with spritesheet
  16661. */
  16662. constructor(
  16663. /** defines the manager's name */
  16664. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16665. private _appendSpriteVertex;
  16666. /**
  16667. * Intersects the sprites with a ray
  16668. * @param ray defines the ray to intersect with
  16669. * @param camera defines the current active camera
  16670. * @param predicate defines a predicate used to select candidate sprites
  16671. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16672. * @returns null if no hit or a PickingInfo
  16673. */
  16674. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16675. /**
  16676. * Render all child sprites
  16677. */
  16678. render(): void;
  16679. /**
  16680. * Release associated resources
  16681. */
  16682. dispose(): void;
  16683. }
  16684. }
  16685. declare module "babylonjs/Sprites/sprite" {
  16686. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16687. import { Nullable } from "babylonjs/types";
  16688. import { ActionManager } from "babylonjs/Actions/actionManager";
  16689. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16690. /**
  16691. * Class used to represent a sprite
  16692. * @see http://doc.babylonjs.com/babylon101/sprites
  16693. */
  16694. export class Sprite {
  16695. /** defines the name */
  16696. name: string;
  16697. /** Gets or sets the current world position */
  16698. position: Vector3;
  16699. /** Gets or sets the main color */
  16700. color: Color4;
  16701. /** Gets or sets the width */
  16702. width: number;
  16703. /** Gets or sets the height */
  16704. height: number;
  16705. /** Gets or sets rotation angle */
  16706. angle: number;
  16707. /** Gets or sets the cell index in the sprite sheet */
  16708. cellIndex: number;
  16709. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16710. invertU: number;
  16711. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16712. invertV: number;
  16713. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16714. disposeWhenFinishedAnimating: boolean;
  16715. /** Gets the list of attached animations */
  16716. animations: Animation[];
  16717. /** Gets or sets a boolean indicating if the sprite can be picked */
  16718. isPickable: boolean;
  16719. /**
  16720. * Gets or sets the associated action manager
  16721. */
  16722. actionManager: Nullable<ActionManager>;
  16723. private _animationStarted;
  16724. private _loopAnimation;
  16725. private _fromIndex;
  16726. private _toIndex;
  16727. private _delay;
  16728. private _direction;
  16729. private _manager;
  16730. private _time;
  16731. private _onAnimationEnd;
  16732. /**
  16733. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16734. */
  16735. isVisible: boolean;
  16736. /**
  16737. * Gets or sets the sprite size
  16738. */
  16739. size: number;
  16740. /**
  16741. * Creates a new Sprite
  16742. * @param name defines the name
  16743. * @param manager defines the manager
  16744. */
  16745. constructor(
  16746. /** defines the name */
  16747. name: string, manager: ISpriteManager);
  16748. /**
  16749. * Starts an animation
  16750. * @param from defines the initial key
  16751. * @param to defines the end key
  16752. * @param loop defines if the animation must loop
  16753. * @param delay defines the start delay (in ms)
  16754. * @param onAnimationEnd defines a callback to call when animation ends
  16755. */
  16756. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16757. /** Stops current animation (if any) */
  16758. stopAnimation(): void;
  16759. /** @hidden */
  16760. _animate(deltaTime: number): void;
  16761. /** Release associated resources */
  16762. dispose(): void;
  16763. }
  16764. }
  16765. declare module "babylonjs/Collisions/pickingInfo" {
  16766. import { Nullable } from "babylonjs/types";
  16767. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16769. import { Sprite } from "babylonjs/Sprites/sprite";
  16770. import { Ray } from "babylonjs/Culling/ray";
  16771. /**
  16772. * Information about the result of picking within a scene
  16773. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16774. */
  16775. export class PickingInfo {
  16776. /** @hidden */
  16777. _pickingUnavailable: boolean;
  16778. /**
  16779. * If the pick collided with an object
  16780. */
  16781. hit: boolean;
  16782. /**
  16783. * Distance away where the pick collided
  16784. */
  16785. distance: number;
  16786. /**
  16787. * The location of pick collision
  16788. */
  16789. pickedPoint: Nullable<Vector3>;
  16790. /**
  16791. * The mesh corresponding the the pick collision
  16792. */
  16793. pickedMesh: Nullable<AbstractMesh>;
  16794. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16795. bu: number;
  16796. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16797. bv: number;
  16798. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16799. faceId: number;
  16800. /** Id of the the submesh that was picked */
  16801. subMeshId: number;
  16802. /** If a sprite was picked, this will be the sprite the pick collided with */
  16803. pickedSprite: Nullable<Sprite>;
  16804. /**
  16805. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16806. */
  16807. originMesh: Nullable<AbstractMesh>;
  16808. /**
  16809. * The ray that was used to perform the picking.
  16810. */
  16811. ray: Nullable<Ray>;
  16812. /**
  16813. * Gets the normal correspodning to the face the pick collided with
  16814. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16815. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16816. * @returns The normal correspodning to the face the pick collided with
  16817. */
  16818. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16819. /**
  16820. * Gets the texture coordinates of where the pick occured
  16821. * @returns the vector containing the coordnates of the texture
  16822. */
  16823. getTextureCoordinates(): Nullable<Vector2>;
  16824. }
  16825. }
  16826. declare module "babylonjs/Events/pointerEvents" {
  16827. import { Nullable } from "babylonjs/types";
  16828. import { Vector2 } from "babylonjs/Maths/math";
  16829. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16830. import { Ray } from "babylonjs/Culling/ray";
  16831. /**
  16832. * Gather the list of pointer event types as constants.
  16833. */
  16834. export class PointerEventTypes {
  16835. /**
  16836. * 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.
  16837. */
  16838. static readonly POINTERDOWN: number;
  16839. /**
  16840. * The pointerup event is fired when a pointer is no longer active.
  16841. */
  16842. static readonly POINTERUP: number;
  16843. /**
  16844. * The pointermove event is fired when a pointer changes coordinates.
  16845. */
  16846. static readonly POINTERMOVE: number;
  16847. /**
  16848. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16849. */
  16850. static readonly POINTERWHEEL: number;
  16851. /**
  16852. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16853. */
  16854. static readonly POINTERPICK: number;
  16855. /**
  16856. * The pointertap event is fired when a the object has been touched and released without drag.
  16857. */
  16858. static readonly POINTERTAP: number;
  16859. /**
  16860. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16861. */
  16862. static readonly POINTERDOUBLETAP: number;
  16863. }
  16864. /**
  16865. * Base class of pointer info types.
  16866. */
  16867. export class PointerInfoBase {
  16868. /**
  16869. * Defines the type of event (PointerEventTypes)
  16870. */
  16871. type: number;
  16872. /**
  16873. * Defines the related dom event
  16874. */
  16875. event: PointerEvent | MouseWheelEvent;
  16876. /**
  16877. * Instantiates the base class of pointers info.
  16878. * @param type Defines the type of event (PointerEventTypes)
  16879. * @param event Defines the related dom event
  16880. */
  16881. constructor(
  16882. /**
  16883. * Defines the type of event (PointerEventTypes)
  16884. */
  16885. type: number,
  16886. /**
  16887. * Defines the related dom event
  16888. */
  16889. event: PointerEvent | MouseWheelEvent);
  16890. }
  16891. /**
  16892. * This class is used to store pointer related info for the onPrePointerObservable event.
  16893. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16894. */
  16895. export class PointerInfoPre extends PointerInfoBase {
  16896. /**
  16897. * Ray from a pointer if availible (eg. 6dof controller)
  16898. */
  16899. ray: Nullable<Ray>;
  16900. /**
  16901. * Defines the local position of the pointer on the canvas.
  16902. */
  16903. localPosition: Vector2;
  16904. /**
  16905. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16906. */
  16907. skipOnPointerObservable: boolean;
  16908. /**
  16909. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16910. * @param type Defines the type of event (PointerEventTypes)
  16911. * @param event Defines the related dom event
  16912. * @param localX Defines the local x coordinates of the pointer when the event occured
  16913. * @param localY Defines the local y coordinates of the pointer when the event occured
  16914. */
  16915. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16916. }
  16917. /**
  16918. * This type contains all the data related to a pointer event in Babylon.js.
  16919. * 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.
  16920. */
  16921. export class PointerInfo extends PointerInfoBase {
  16922. /**
  16923. * Defines the picking info associated to the info (if any)\
  16924. */
  16925. pickInfo: Nullable<PickingInfo>;
  16926. /**
  16927. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16928. * @param type Defines the type of event (PointerEventTypes)
  16929. * @param event Defines the related dom event
  16930. * @param pickInfo Defines the picking info associated to the info (if any)\
  16931. */
  16932. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16933. /**
  16934. * Defines the picking info associated to the info (if any)\
  16935. */
  16936. pickInfo: Nullable<PickingInfo>);
  16937. }
  16938. /**
  16939. * Data relating to a touch event on the screen.
  16940. */
  16941. export interface PointerTouch {
  16942. /**
  16943. * X coordinate of touch.
  16944. */
  16945. x: number;
  16946. /**
  16947. * Y coordinate of touch.
  16948. */
  16949. y: number;
  16950. /**
  16951. * Id of touch. Unique for each finger.
  16952. */
  16953. pointerId: number;
  16954. /**
  16955. * Event type passed from DOM.
  16956. */
  16957. type: any;
  16958. }
  16959. }
  16960. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16961. import { Observable } from "babylonjs/Misc/observable";
  16962. import { Nullable } from "babylonjs/types";
  16963. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16964. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16965. /**
  16966. * Manage the mouse inputs to control the movement of a free camera.
  16967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16968. */
  16969. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16970. /**
  16971. * Define if touch is enabled in the mouse input
  16972. */
  16973. touchEnabled: boolean;
  16974. /**
  16975. * Defines the camera the input is attached to.
  16976. */
  16977. camera: FreeCamera;
  16978. /**
  16979. * Defines the buttons associated with the input to handle camera move.
  16980. */
  16981. buttons: number[];
  16982. /**
  16983. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16984. */
  16985. angularSensibility: number;
  16986. private _pointerInput;
  16987. private _onMouseMove;
  16988. private _observer;
  16989. private previousPosition;
  16990. /**
  16991. * Observable for when a pointer move event occurs containing the move offset
  16992. */
  16993. onPointerMovedObservable: Observable<{
  16994. offsetX: number;
  16995. offsetY: number;
  16996. }>;
  16997. /**
  16998. * @hidden
  16999. * If the camera should be rotated automatically based on pointer movement
  17000. */
  17001. _allowCameraRotation: boolean;
  17002. /**
  17003. * Manage the mouse inputs to control the movement of a free camera.
  17004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17005. * @param touchEnabled Defines if touch is enabled or not
  17006. */
  17007. constructor(
  17008. /**
  17009. * Define if touch is enabled in the mouse input
  17010. */
  17011. touchEnabled?: boolean);
  17012. /**
  17013. * Attach the input controls to a specific dom element to get the input from.
  17014. * @param element Defines the element the controls should be listened from
  17015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17016. */
  17017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17018. /**
  17019. * Called on JS contextmenu event.
  17020. * Override this method to provide functionality.
  17021. */
  17022. protected onContextMenu(evt: PointerEvent): void;
  17023. /**
  17024. * Detach the current controls from the specified dom element.
  17025. * @param element Defines the element to stop listening the inputs from
  17026. */
  17027. detachControl(element: Nullable<HTMLElement>): void;
  17028. /**
  17029. * Gets the class name of the current intput.
  17030. * @returns the class name
  17031. */
  17032. getClassName(): string;
  17033. /**
  17034. * Get the friendly name associated with the input class.
  17035. * @returns the input friendly name
  17036. */
  17037. getSimpleName(): string;
  17038. }
  17039. }
  17040. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17041. import { Nullable } from "babylonjs/types";
  17042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17043. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17044. /**
  17045. * Manage the touch inputs to control the movement of a free camera.
  17046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17047. */
  17048. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17049. /**
  17050. * Defines the camera the input is attached to.
  17051. */
  17052. camera: FreeCamera;
  17053. /**
  17054. * Defines the touch sensibility for rotation.
  17055. * The higher the faster.
  17056. */
  17057. touchAngularSensibility: number;
  17058. /**
  17059. * Defines the touch sensibility for move.
  17060. * The higher the faster.
  17061. */
  17062. touchMoveSensibility: number;
  17063. private _offsetX;
  17064. private _offsetY;
  17065. private _pointerPressed;
  17066. private _pointerInput;
  17067. private _observer;
  17068. private _onLostFocus;
  17069. /**
  17070. * Attach the input controls to a specific dom element to get the input from.
  17071. * @param element Defines the element the controls should be listened from
  17072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17073. */
  17074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17075. /**
  17076. * Detach the current controls from the specified dom element.
  17077. * @param element Defines the element to stop listening the inputs from
  17078. */
  17079. detachControl(element: Nullable<HTMLElement>): void;
  17080. /**
  17081. * Update the current camera state depending on the inputs that have been used this frame.
  17082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17083. */
  17084. checkInputs(): void;
  17085. /**
  17086. * Gets the class name of the current intput.
  17087. * @returns the class name
  17088. */
  17089. getClassName(): string;
  17090. /**
  17091. * Get the friendly name associated with the input class.
  17092. * @returns the input friendly name
  17093. */
  17094. getSimpleName(): string;
  17095. }
  17096. }
  17097. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17099. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17100. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17101. import { Nullable } from "babylonjs/types";
  17102. /**
  17103. * Default Inputs manager for the FreeCamera.
  17104. * It groups all the default supported inputs for ease of use.
  17105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17106. */
  17107. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17108. /**
  17109. * @hidden
  17110. */
  17111. _mouseInput: Nullable<FreeCameraMouseInput>;
  17112. /**
  17113. * Instantiates a new FreeCameraInputsManager.
  17114. * @param camera Defines the camera the inputs belong to
  17115. */
  17116. constructor(camera: FreeCamera);
  17117. /**
  17118. * Add keyboard input support to the input manager.
  17119. * @returns the current input manager
  17120. */
  17121. addKeyboard(): FreeCameraInputsManager;
  17122. /**
  17123. * Add mouse input support to the input manager.
  17124. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17125. * @returns the current input manager
  17126. */
  17127. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17128. /**
  17129. * Removes the mouse input support from the manager
  17130. * @returns the current input manager
  17131. */
  17132. removeMouse(): FreeCameraInputsManager;
  17133. /**
  17134. * Add touch input support to the input manager.
  17135. * @returns the current input manager
  17136. */
  17137. addTouch(): FreeCameraInputsManager;
  17138. /**
  17139. * Remove all attached input methods from a camera
  17140. */
  17141. clear(): void;
  17142. }
  17143. }
  17144. declare module "babylonjs/Cameras/freeCamera" {
  17145. import { Vector3 } from "babylonjs/Maths/math";
  17146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17147. import { Scene } from "babylonjs/scene";
  17148. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17149. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17150. /**
  17151. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17152. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17153. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17154. */
  17155. export class FreeCamera extends TargetCamera {
  17156. /**
  17157. * Define the collision ellipsoid of the camera.
  17158. * This is helpful to simulate a camera body like the player body around the camera
  17159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17160. */
  17161. ellipsoid: Vector3;
  17162. /**
  17163. * Define an offset for the position of the ellipsoid around the camera.
  17164. * This can be helpful to determine the center of the body near the gravity center of the body
  17165. * instead of its head.
  17166. */
  17167. ellipsoidOffset: Vector3;
  17168. /**
  17169. * Enable or disable collisions of the camera with the rest of the scene objects.
  17170. */
  17171. checkCollisions: boolean;
  17172. /**
  17173. * Enable or disable gravity on the camera.
  17174. */
  17175. applyGravity: boolean;
  17176. /**
  17177. * Define the input manager associated to the camera.
  17178. */
  17179. inputs: FreeCameraInputsManager;
  17180. /**
  17181. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17182. * Higher values reduce sensitivity.
  17183. */
  17184. /**
  17185. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17186. * Higher values reduce sensitivity.
  17187. */
  17188. angularSensibility: number;
  17189. /**
  17190. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17191. */
  17192. keysUp: number[];
  17193. /**
  17194. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17195. */
  17196. keysDown: number[];
  17197. /**
  17198. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17199. */
  17200. keysLeft: number[];
  17201. /**
  17202. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17203. */
  17204. keysRight: number[];
  17205. /**
  17206. * Event raised when the camera collide with a mesh in the scene.
  17207. */
  17208. onCollide: (collidedMesh: AbstractMesh) => void;
  17209. private _collider;
  17210. private _needMoveForGravity;
  17211. private _oldPosition;
  17212. private _diffPosition;
  17213. private _newPosition;
  17214. /** @hidden */
  17215. _localDirection: Vector3;
  17216. /** @hidden */
  17217. _transformedDirection: Vector3;
  17218. /**
  17219. * Instantiates a Free Camera.
  17220. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17221. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17223. * @param name Define the name of the camera in the scene
  17224. * @param position Define the start position of the camera in the scene
  17225. * @param scene Define the scene the camera belongs to
  17226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17227. */
  17228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17229. /**
  17230. * Attached controls to the current camera.
  17231. * @param element Defines the element the controls should be listened from
  17232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17233. */
  17234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17235. /**
  17236. * Detach the current controls from the camera.
  17237. * The camera will stop reacting to inputs.
  17238. * @param element Defines the element to stop listening the inputs from
  17239. */
  17240. detachControl(element: HTMLElement): void;
  17241. private _collisionMask;
  17242. /**
  17243. * Define a collision mask to limit the list of object the camera can collide with
  17244. */
  17245. collisionMask: number;
  17246. /** @hidden */
  17247. _collideWithWorld(displacement: Vector3): void;
  17248. private _onCollisionPositionChange;
  17249. /** @hidden */
  17250. _checkInputs(): void;
  17251. /** @hidden */
  17252. _decideIfNeedsToMove(): boolean;
  17253. /** @hidden */
  17254. _updatePosition(): void;
  17255. /**
  17256. * Destroy the camera and release the current resources hold by it.
  17257. */
  17258. dispose(): void;
  17259. /**
  17260. * Gets the current object class name.
  17261. * @return the class name
  17262. */
  17263. getClassName(): string;
  17264. }
  17265. }
  17266. declare module "babylonjs/Gamepads/gamepad" {
  17267. import { Observable } from "babylonjs/Misc/observable";
  17268. /**
  17269. * Represents a gamepad control stick position
  17270. */
  17271. export class StickValues {
  17272. /**
  17273. * The x component of the control stick
  17274. */
  17275. x: number;
  17276. /**
  17277. * The y component of the control stick
  17278. */
  17279. y: number;
  17280. /**
  17281. * Initializes the gamepad x and y control stick values
  17282. * @param x The x component of the gamepad control stick value
  17283. * @param y The y component of the gamepad control stick value
  17284. */
  17285. constructor(
  17286. /**
  17287. * The x component of the control stick
  17288. */
  17289. x: number,
  17290. /**
  17291. * The y component of the control stick
  17292. */
  17293. y: number);
  17294. }
  17295. /**
  17296. * An interface which manages callbacks for gamepad button changes
  17297. */
  17298. export interface GamepadButtonChanges {
  17299. /**
  17300. * Called when a gamepad has been changed
  17301. */
  17302. changed: boolean;
  17303. /**
  17304. * Called when a gamepad press event has been triggered
  17305. */
  17306. pressChanged: boolean;
  17307. /**
  17308. * Called when a touch event has been triggered
  17309. */
  17310. touchChanged: boolean;
  17311. /**
  17312. * Called when a value has changed
  17313. */
  17314. valueChanged: boolean;
  17315. }
  17316. /**
  17317. * Represents a gamepad
  17318. */
  17319. export class Gamepad {
  17320. /**
  17321. * The id of the gamepad
  17322. */
  17323. id: string;
  17324. /**
  17325. * The index of the gamepad
  17326. */
  17327. index: number;
  17328. /**
  17329. * The browser gamepad
  17330. */
  17331. browserGamepad: any;
  17332. /**
  17333. * Specifies what type of gamepad this represents
  17334. */
  17335. type: number;
  17336. private _leftStick;
  17337. private _rightStick;
  17338. /** @hidden */
  17339. _isConnected: boolean;
  17340. private _leftStickAxisX;
  17341. private _leftStickAxisY;
  17342. private _rightStickAxisX;
  17343. private _rightStickAxisY;
  17344. /**
  17345. * Triggered when the left control stick has been changed
  17346. */
  17347. private _onleftstickchanged;
  17348. /**
  17349. * Triggered when the right control stick has been changed
  17350. */
  17351. private _onrightstickchanged;
  17352. /**
  17353. * Represents a gamepad controller
  17354. */
  17355. static GAMEPAD: number;
  17356. /**
  17357. * Represents a generic controller
  17358. */
  17359. static GENERIC: number;
  17360. /**
  17361. * Represents an XBox controller
  17362. */
  17363. static XBOX: number;
  17364. /**
  17365. * Represents a pose-enabled controller
  17366. */
  17367. static POSE_ENABLED: number;
  17368. /**
  17369. * Specifies whether the left control stick should be Y-inverted
  17370. */
  17371. protected _invertLeftStickY: boolean;
  17372. /**
  17373. * Specifies if the gamepad has been connected
  17374. */
  17375. readonly isConnected: boolean;
  17376. /**
  17377. * Initializes the gamepad
  17378. * @param id The id of the gamepad
  17379. * @param index The index of the gamepad
  17380. * @param browserGamepad The browser gamepad
  17381. * @param leftStickX The x component of the left joystick
  17382. * @param leftStickY The y component of the left joystick
  17383. * @param rightStickX The x component of the right joystick
  17384. * @param rightStickY The y component of the right joystick
  17385. */
  17386. constructor(
  17387. /**
  17388. * The id of the gamepad
  17389. */
  17390. id: string,
  17391. /**
  17392. * The index of the gamepad
  17393. */
  17394. index: number,
  17395. /**
  17396. * The browser gamepad
  17397. */
  17398. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17399. /**
  17400. * Callback triggered when the left joystick has changed
  17401. * @param callback
  17402. */
  17403. onleftstickchanged(callback: (values: StickValues) => void): void;
  17404. /**
  17405. * Callback triggered when the right joystick has changed
  17406. * @param callback
  17407. */
  17408. onrightstickchanged(callback: (values: StickValues) => void): void;
  17409. /**
  17410. * Gets the left joystick
  17411. */
  17412. /**
  17413. * Sets the left joystick values
  17414. */
  17415. leftStick: StickValues;
  17416. /**
  17417. * Gets the right joystick
  17418. */
  17419. /**
  17420. * Sets the right joystick value
  17421. */
  17422. rightStick: StickValues;
  17423. /**
  17424. * Updates the gamepad joystick positions
  17425. */
  17426. update(): void;
  17427. /**
  17428. * Disposes the gamepad
  17429. */
  17430. dispose(): void;
  17431. }
  17432. /**
  17433. * Represents a generic gamepad
  17434. */
  17435. export class GenericPad extends Gamepad {
  17436. private _buttons;
  17437. private _onbuttondown;
  17438. private _onbuttonup;
  17439. /**
  17440. * Observable triggered when a button has been pressed
  17441. */
  17442. onButtonDownObservable: Observable<number>;
  17443. /**
  17444. * Observable triggered when a button has been released
  17445. */
  17446. onButtonUpObservable: Observable<number>;
  17447. /**
  17448. * Callback triggered when a button has been pressed
  17449. * @param callback Called when a button has been pressed
  17450. */
  17451. onbuttondown(callback: (buttonPressed: number) => void): void;
  17452. /**
  17453. * Callback triggered when a button has been released
  17454. * @param callback Called when a button has been released
  17455. */
  17456. onbuttonup(callback: (buttonReleased: number) => void): void;
  17457. /**
  17458. * Initializes the generic gamepad
  17459. * @param id The id of the generic gamepad
  17460. * @param index The index of the generic gamepad
  17461. * @param browserGamepad The browser gamepad
  17462. */
  17463. constructor(id: string, index: number, browserGamepad: any);
  17464. private _setButtonValue;
  17465. /**
  17466. * Updates the generic gamepad
  17467. */
  17468. update(): void;
  17469. /**
  17470. * Disposes the generic gamepad
  17471. */
  17472. dispose(): void;
  17473. }
  17474. }
  17475. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17476. import { Observable } from "babylonjs/Misc/observable";
  17477. import { Nullable } from "babylonjs/types";
  17478. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17481. import { Ray } from "babylonjs/Culling/ray";
  17482. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17483. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17484. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17485. /**
  17486. * Defines the types of pose enabled controllers that are supported
  17487. */
  17488. export enum PoseEnabledControllerType {
  17489. /**
  17490. * HTC Vive
  17491. */
  17492. VIVE = 0,
  17493. /**
  17494. * Oculus Rift
  17495. */
  17496. OCULUS = 1,
  17497. /**
  17498. * Windows mixed reality
  17499. */
  17500. WINDOWS = 2,
  17501. /**
  17502. * Samsung gear VR
  17503. */
  17504. GEAR_VR = 3,
  17505. /**
  17506. * Google Daydream
  17507. */
  17508. DAYDREAM = 4,
  17509. /**
  17510. * Generic
  17511. */
  17512. GENERIC = 5
  17513. }
  17514. /**
  17515. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17516. */
  17517. export interface MutableGamepadButton {
  17518. /**
  17519. * Value of the button/trigger
  17520. */
  17521. value: number;
  17522. /**
  17523. * If the button/trigger is currently touched
  17524. */
  17525. touched: boolean;
  17526. /**
  17527. * If the button/trigger is currently pressed
  17528. */
  17529. pressed: boolean;
  17530. }
  17531. /**
  17532. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17533. * @hidden
  17534. */
  17535. export interface ExtendedGamepadButton extends GamepadButton {
  17536. /**
  17537. * If the button/trigger is currently pressed
  17538. */
  17539. readonly pressed: boolean;
  17540. /**
  17541. * If the button/trigger is currently touched
  17542. */
  17543. readonly touched: boolean;
  17544. /**
  17545. * Value of the button/trigger
  17546. */
  17547. readonly value: number;
  17548. }
  17549. /** @hidden */
  17550. export interface _GamePadFactory {
  17551. /**
  17552. * Returns wether or not the current gamepad can be created for this type of controller.
  17553. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17554. * @returns true if it can be created, otherwise false
  17555. */
  17556. canCreate(gamepadInfo: any): boolean;
  17557. /**
  17558. * Creates a new instance of the Gamepad.
  17559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17560. * @returns the new gamepad instance
  17561. */
  17562. create(gamepadInfo: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17566. */
  17567. export class PoseEnabledControllerHelper {
  17568. /** @hidden */
  17569. static _ControllerFactories: _GamePadFactory[];
  17570. /** @hidden */
  17571. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17572. /**
  17573. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17574. * @param vrGamepad the gamepad to initialized
  17575. * @returns a vr controller of the type the gamepad identified as
  17576. */
  17577. static InitiateController(vrGamepad: any): Gamepad;
  17578. }
  17579. /**
  17580. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17581. */
  17582. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17583. private _deviceRoomPosition;
  17584. private _deviceRoomRotationQuaternion;
  17585. /**
  17586. * The device position in babylon space
  17587. */
  17588. devicePosition: Vector3;
  17589. /**
  17590. * The device rotation in babylon space
  17591. */
  17592. deviceRotationQuaternion: Quaternion;
  17593. /**
  17594. * The scale factor of the device in babylon space
  17595. */
  17596. deviceScaleFactor: number;
  17597. /**
  17598. * (Likely devicePosition should be used instead) The device position in its room space
  17599. */
  17600. position: Vector3;
  17601. /**
  17602. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17603. */
  17604. rotationQuaternion: Quaternion;
  17605. /**
  17606. * The type of controller (Eg. Windows mixed reality)
  17607. */
  17608. controllerType: PoseEnabledControllerType;
  17609. protected _calculatedPosition: Vector3;
  17610. private _calculatedRotation;
  17611. /**
  17612. * The raw pose from the device
  17613. */
  17614. rawPose: DevicePose;
  17615. private _trackPosition;
  17616. private _maxRotationDistFromHeadset;
  17617. private _draggedRoomRotation;
  17618. /**
  17619. * @hidden
  17620. */
  17621. _disableTrackPosition(fixedPosition: Vector3): void;
  17622. /**
  17623. * Internal, the mesh attached to the controller
  17624. * @hidden
  17625. */
  17626. _mesh: Nullable<AbstractMesh>;
  17627. private _poseControlledCamera;
  17628. private _leftHandSystemQuaternion;
  17629. /**
  17630. * Internal, matrix used to convert room space to babylon space
  17631. * @hidden
  17632. */
  17633. _deviceToWorld: Matrix;
  17634. /**
  17635. * Node to be used when casting a ray from the controller
  17636. * @hidden
  17637. */
  17638. _pointingPoseNode: Nullable<TransformNode>;
  17639. /**
  17640. * Name of the child mesh that can be used to cast a ray from the controller
  17641. */
  17642. static readonly POINTING_POSE: string;
  17643. /**
  17644. * Creates a new PoseEnabledController from a gamepad
  17645. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17646. */
  17647. constructor(browserGamepad: any);
  17648. private _workingMatrix;
  17649. /**
  17650. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17651. */
  17652. update(): void;
  17653. /**
  17654. * Updates only the pose device and mesh without doing any button event checking
  17655. */
  17656. protected _updatePoseAndMesh(): void;
  17657. /**
  17658. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17659. * @param poseData raw pose fromthe device
  17660. */
  17661. updateFromDevice(poseData: DevicePose): void;
  17662. /**
  17663. * @hidden
  17664. */
  17665. _meshAttachedObservable: Observable<AbstractMesh>;
  17666. /**
  17667. * Attaches a mesh to the controller
  17668. * @param mesh the mesh to be attached
  17669. */
  17670. attachToMesh(mesh: AbstractMesh): void;
  17671. /**
  17672. * Attaches the controllers mesh to a camera
  17673. * @param camera the camera the mesh should be attached to
  17674. */
  17675. attachToPoseControlledCamera(camera: TargetCamera): void;
  17676. /**
  17677. * Disposes of the controller
  17678. */
  17679. dispose(): void;
  17680. /**
  17681. * The mesh that is attached to the controller
  17682. */
  17683. readonly mesh: Nullable<AbstractMesh>;
  17684. /**
  17685. * Gets the ray of the controller in the direction the controller is pointing
  17686. * @param length the length the resulting ray should be
  17687. * @returns a ray in the direction the controller is pointing
  17688. */
  17689. getForwardRay(length?: number): Ray;
  17690. }
  17691. }
  17692. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17693. import { Observable } from "babylonjs/Misc/observable";
  17694. import { Scene } from "babylonjs/scene";
  17695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17696. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17697. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17698. /**
  17699. * Defines the WebVRController object that represents controllers tracked in 3D space
  17700. */
  17701. export abstract class WebVRController extends PoseEnabledController {
  17702. /**
  17703. * Internal, the default controller model for the controller
  17704. */
  17705. protected _defaultModel: AbstractMesh;
  17706. /**
  17707. * Fired when the trigger state has changed
  17708. */
  17709. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17710. /**
  17711. * Fired when the main button state has changed
  17712. */
  17713. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17714. /**
  17715. * Fired when the secondary button state has changed
  17716. */
  17717. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17718. /**
  17719. * Fired when the pad state has changed
  17720. */
  17721. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17722. /**
  17723. * Fired when controllers stick values have changed
  17724. */
  17725. onPadValuesChangedObservable: Observable<StickValues>;
  17726. /**
  17727. * Array of button availible on the controller
  17728. */
  17729. protected _buttons: Array<MutableGamepadButton>;
  17730. private _onButtonStateChange;
  17731. /**
  17732. * Fired when a controller button's state has changed
  17733. * @param callback the callback containing the button that was modified
  17734. */
  17735. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17736. /**
  17737. * X and Y axis corresponding to the controllers joystick
  17738. */
  17739. pad: StickValues;
  17740. /**
  17741. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17742. */
  17743. hand: string;
  17744. /**
  17745. * The default controller model for the controller
  17746. */
  17747. readonly defaultModel: AbstractMesh;
  17748. /**
  17749. * Creates a new WebVRController from a gamepad
  17750. * @param vrGamepad the gamepad that the WebVRController should be created from
  17751. */
  17752. constructor(vrGamepad: any);
  17753. /**
  17754. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17755. */
  17756. update(): void;
  17757. /**
  17758. * Function to be called when a button is modified
  17759. */
  17760. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17761. /**
  17762. * Loads a mesh and attaches it to the controller
  17763. * @param scene the scene the mesh should be added to
  17764. * @param meshLoaded callback for when the mesh has been loaded
  17765. */
  17766. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17767. private _setButtonValue;
  17768. private _changes;
  17769. private _checkChanges;
  17770. /**
  17771. * Disposes of th webVRCOntroller
  17772. */
  17773. dispose(): void;
  17774. }
  17775. }
  17776. declare module "babylonjs/Lights/hemisphericLight" {
  17777. import { Nullable } from "babylonjs/types";
  17778. import { Scene } from "babylonjs/scene";
  17779. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17780. import { Effect } from "babylonjs/Materials/effect";
  17781. import { Light } from "babylonjs/Lights/light";
  17782. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17783. /**
  17784. * The HemisphericLight simulates the ambient environment light,
  17785. * so the passed direction is the light reflection direction, not the incoming direction.
  17786. */
  17787. export class HemisphericLight extends Light {
  17788. /**
  17789. * The groundColor is the light in the opposite direction to the one specified during creation.
  17790. * 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.
  17791. */
  17792. groundColor: Color3;
  17793. /**
  17794. * The light reflection direction, not the incoming direction.
  17795. */
  17796. direction: Vector3;
  17797. /**
  17798. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17799. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17800. * The HemisphericLight can't cast shadows.
  17801. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17802. * @param name The friendly name of the light
  17803. * @param direction The direction of the light reflection
  17804. * @param scene The scene the light belongs to
  17805. */
  17806. constructor(name: string, direction: Vector3, scene: Scene);
  17807. protected _buildUniformLayout(): void;
  17808. /**
  17809. * Returns the string "HemisphericLight".
  17810. * @return The class name
  17811. */
  17812. getClassName(): string;
  17813. /**
  17814. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17815. * Returns the updated direction.
  17816. * @param target The target the direction should point to
  17817. * @return The computed direction
  17818. */
  17819. setDirectionToTarget(target: Vector3): Vector3;
  17820. /**
  17821. * Returns the shadow generator associated to the light.
  17822. * @returns Always null for hemispheric lights because it does not support shadows.
  17823. */
  17824. getShadowGenerator(): Nullable<IShadowGenerator>;
  17825. /**
  17826. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17827. * @param effect The effect to update
  17828. * @param lightIndex The index of the light in the effect to update
  17829. * @returns The hemispheric light
  17830. */
  17831. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17832. /**
  17833. * Computes the world matrix of the node
  17834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17835. * @param useWasUpdatedFlag defines a reserved property
  17836. * @returns the world matrix
  17837. */
  17838. computeWorldMatrix(): Matrix;
  17839. /**
  17840. * Returns the integer 3.
  17841. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17842. */
  17843. getTypeID(): number;
  17844. /**
  17845. * Prepares the list of defines specific to the light type.
  17846. * @param defines the list of defines
  17847. * @param lightIndex defines the index of the light for the effect
  17848. */
  17849. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17850. }
  17851. }
  17852. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17853. /** @hidden */
  17854. export var vrMultiviewToSingleviewPixelShader: {
  17855. name: string;
  17856. shader: string;
  17857. };
  17858. }
  17859. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17861. import { Scene } from "babylonjs/scene";
  17862. /**
  17863. * Renders to multiple views with a single draw call
  17864. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17865. */
  17866. export class MultiviewRenderTarget extends RenderTargetTexture {
  17867. /**
  17868. * Creates a multiview render target
  17869. * @param scene scene used with the render target
  17870. * @param size the size of the render target (used for each view)
  17871. */
  17872. constructor(scene: Scene, size?: number | {
  17873. width: number;
  17874. height: number;
  17875. } | {
  17876. ratio: number;
  17877. });
  17878. /**
  17879. * @hidden
  17880. * @param faceIndex the face index, if its a cube texture
  17881. */
  17882. _bindFrameBuffer(faceIndex?: number): void;
  17883. /**
  17884. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17885. * @returns the view count
  17886. */
  17887. getViewCount(): number;
  17888. }
  17889. }
  17890. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17891. import { Camera } from "babylonjs/Cameras/camera";
  17892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17893. import { Nullable } from "babylonjs/types";
  17894. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17895. import { Matrix } from "babylonjs/Maths/math";
  17896. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17897. module "babylonjs/Engines/engine" {
  17898. interface Engine {
  17899. /**
  17900. * Creates a new multiview render target
  17901. * @param width defines the width of the texture
  17902. * @param height defines the height of the texture
  17903. * @returns the created multiview texture
  17904. */
  17905. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17906. /**
  17907. * Binds a multiview framebuffer to be drawn to
  17908. * @param multiviewTexture texture to bind
  17909. */
  17910. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17911. }
  17912. }
  17913. module "babylonjs/Cameras/camera" {
  17914. interface Camera {
  17915. /**
  17916. * @hidden
  17917. * 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)
  17918. */
  17919. _useMultiviewToSingleView: boolean;
  17920. /**
  17921. * @hidden
  17922. * 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)
  17923. */
  17924. _multiviewTexture: Nullable<RenderTargetTexture>;
  17925. /**
  17926. * @hidden
  17927. * ensures the multiview texture of the camera exists and has the specified width/height
  17928. * @param width height to set on the multiview texture
  17929. * @param height width to set on the multiview texture
  17930. */
  17931. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17932. }
  17933. }
  17934. module "babylonjs/scene" {
  17935. interface Scene {
  17936. /** @hidden */
  17937. _transformMatrixR: Matrix;
  17938. /** @hidden */
  17939. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17940. /** @hidden */
  17941. _createMultiviewUbo(): void;
  17942. /** @hidden */
  17943. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17944. /** @hidden */
  17945. _renderMultiviewToSingleView(camera: Camera): void;
  17946. }
  17947. }
  17948. }
  17949. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17950. import { Camera } from "babylonjs/Cameras/camera";
  17951. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17952. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17953. import "babylonjs/Engines/Extensions/engine.multiview";
  17954. /**
  17955. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17956. * This will not be used for webXR as it supports displaying texture arrays directly
  17957. */
  17958. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17959. /**
  17960. * Initializes a VRMultiviewToSingleview
  17961. * @param name name of the post process
  17962. * @param camera camera to be applied to
  17963. * @param scaleFactor scaling factor to the size of the output texture
  17964. */
  17965. constructor(name: string, camera: Camera, scaleFactor: number);
  17966. }
  17967. }
  17968. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17969. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17970. import { Nullable } from "babylonjs/types";
  17971. import { Size } from "babylonjs/Maths/math";
  17972. import { Observable } from "babylonjs/Misc/observable";
  17973. module "babylonjs/Engines/engine" {
  17974. interface Engine {
  17975. /** @hidden */
  17976. _vrDisplay: any;
  17977. /** @hidden */
  17978. _vrSupported: boolean;
  17979. /** @hidden */
  17980. _oldSize: Size;
  17981. /** @hidden */
  17982. _oldHardwareScaleFactor: number;
  17983. /** @hidden */
  17984. _vrExclusivePointerMode: boolean;
  17985. /** @hidden */
  17986. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17987. /** @hidden */
  17988. _onVRDisplayPointerRestricted: () => void;
  17989. /** @hidden */
  17990. _onVRDisplayPointerUnrestricted: () => void;
  17991. /** @hidden */
  17992. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17993. /** @hidden */
  17994. _onVrDisplayDisconnect: Nullable<() => void>;
  17995. /** @hidden */
  17996. _onVrDisplayPresentChange: Nullable<() => void>;
  17997. /**
  17998. * Observable signaled when VR display mode changes
  17999. */
  18000. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  18001. /**
  18002. * Observable signaled when VR request present is complete
  18003. */
  18004. onVRRequestPresentComplete: Observable<boolean>;
  18005. /**
  18006. * Observable signaled when VR request present starts
  18007. */
  18008. onVRRequestPresentStart: Observable<Engine>;
  18009. /**
  18010. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  18011. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  18012. */
  18013. isInVRExclusivePointerMode: boolean;
  18014. /**
  18015. * Gets a boolean indicating if a webVR device was detected
  18016. * @returns true if a webVR device was detected
  18017. */
  18018. isVRDevicePresent(): boolean;
  18019. /**
  18020. * Gets the current webVR device
  18021. * @returns the current webVR device (or null)
  18022. */
  18023. getVRDevice(): any;
  18024. /**
  18025. * Initializes a webVR display and starts listening to display change events
  18026. * The onVRDisplayChangedObservable will be notified upon these changes
  18027. * @returns A promise containing a VRDisplay and if vr is supported
  18028. */
  18029. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18030. /** @hidden */
  18031. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18032. /**
  18033. * Call this function to switch to webVR mode
  18034. * Will do nothing if webVR is not supported or if there is no webVR device
  18035. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18036. */
  18037. enableVR(): void;
  18038. /** @hidden */
  18039. _onVRFullScreenTriggered(): void;
  18040. }
  18041. }
  18042. }
  18043. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18044. import { Nullable } from "babylonjs/types";
  18045. import { Observable } from "babylonjs/Misc/observable";
  18046. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18047. import { Scene } from "babylonjs/scene";
  18048. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18049. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18050. import { Node } from "babylonjs/node";
  18051. import { Ray } from "babylonjs/Culling/ray";
  18052. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18053. import "babylonjs/Engines/Extensions/engine.webVR";
  18054. /**
  18055. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18056. * IMPORTANT!! The data is right-hand data.
  18057. * @export
  18058. * @interface DevicePose
  18059. */
  18060. export interface DevicePose {
  18061. /**
  18062. * The position of the device, values in array are [x,y,z].
  18063. */
  18064. readonly position: Nullable<Float32Array>;
  18065. /**
  18066. * The linearVelocity of the device, values in array are [x,y,z].
  18067. */
  18068. readonly linearVelocity: Nullable<Float32Array>;
  18069. /**
  18070. * The linearAcceleration of the device, values in array are [x,y,z].
  18071. */
  18072. readonly linearAcceleration: Nullable<Float32Array>;
  18073. /**
  18074. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18075. */
  18076. readonly orientation: Nullable<Float32Array>;
  18077. /**
  18078. * The angularVelocity of the device, values in array are [x,y,z].
  18079. */
  18080. readonly angularVelocity: Nullable<Float32Array>;
  18081. /**
  18082. * The angularAcceleration of the device, values in array are [x,y,z].
  18083. */
  18084. readonly angularAcceleration: Nullable<Float32Array>;
  18085. }
  18086. /**
  18087. * Interface representing a pose controlled object in Babylon.
  18088. * A pose controlled object has both regular pose values as well as pose values
  18089. * from an external device such as a VR head mounted display
  18090. */
  18091. export interface PoseControlled {
  18092. /**
  18093. * The position of the object in babylon space.
  18094. */
  18095. position: Vector3;
  18096. /**
  18097. * The rotation quaternion of the object in babylon space.
  18098. */
  18099. rotationQuaternion: Quaternion;
  18100. /**
  18101. * The position of the device in babylon space.
  18102. */
  18103. devicePosition?: Vector3;
  18104. /**
  18105. * The rotation quaternion of the device in babylon space.
  18106. */
  18107. deviceRotationQuaternion: Quaternion;
  18108. /**
  18109. * The raw pose coming from the device.
  18110. */
  18111. rawPose: Nullable<DevicePose>;
  18112. /**
  18113. * The scale of the device to be used when translating from device space to babylon space.
  18114. */
  18115. deviceScaleFactor: number;
  18116. /**
  18117. * Updates the poseControlled values based on the input device pose.
  18118. * @param poseData the pose data to update the object with
  18119. */
  18120. updateFromDevice(poseData: DevicePose): void;
  18121. }
  18122. /**
  18123. * Set of options to customize the webVRCamera
  18124. */
  18125. export interface WebVROptions {
  18126. /**
  18127. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18128. */
  18129. trackPosition?: boolean;
  18130. /**
  18131. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18132. */
  18133. positionScale?: number;
  18134. /**
  18135. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18136. */
  18137. displayName?: string;
  18138. /**
  18139. * Should the native controller meshes be initialized. (default: true)
  18140. */
  18141. controllerMeshes?: boolean;
  18142. /**
  18143. * Creating a default HemiLight only on controllers. (default: true)
  18144. */
  18145. defaultLightingOnControllers?: boolean;
  18146. /**
  18147. * If you don't want to use the default VR button of the helper. (default: false)
  18148. */
  18149. useCustomVRButton?: boolean;
  18150. /**
  18151. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18152. */
  18153. customVRButton?: HTMLButtonElement;
  18154. /**
  18155. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18156. */
  18157. rayLength?: number;
  18158. /**
  18159. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18160. */
  18161. defaultHeight?: number;
  18162. /**
  18163. * If multiview should be used if availible (default: false)
  18164. */
  18165. useMultiview?: boolean;
  18166. }
  18167. /**
  18168. * This represents a WebVR camera.
  18169. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18170. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18171. */
  18172. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18173. private webVROptions;
  18174. /**
  18175. * @hidden
  18176. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18177. */
  18178. _vrDevice: any;
  18179. /**
  18180. * The rawPose of the vrDevice.
  18181. */
  18182. rawPose: Nullable<DevicePose>;
  18183. private _onVREnabled;
  18184. private _specsVersion;
  18185. private _attached;
  18186. private _frameData;
  18187. protected _descendants: Array<Node>;
  18188. private _deviceRoomPosition;
  18189. /** @hidden */
  18190. _deviceRoomRotationQuaternion: Quaternion;
  18191. private _standingMatrix;
  18192. /**
  18193. * Represents device position in babylon space.
  18194. */
  18195. devicePosition: Vector3;
  18196. /**
  18197. * Represents device rotation in babylon space.
  18198. */
  18199. deviceRotationQuaternion: Quaternion;
  18200. /**
  18201. * The scale of the device to be used when translating from device space to babylon space.
  18202. */
  18203. deviceScaleFactor: number;
  18204. private _deviceToWorld;
  18205. private _worldToDevice;
  18206. /**
  18207. * References to the webVR controllers for the vrDevice.
  18208. */
  18209. controllers: Array<WebVRController>;
  18210. /**
  18211. * Emits an event when a controller is attached.
  18212. */
  18213. onControllersAttachedObservable: Observable<WebVRController[]>;
  18214. /**
  18215. * Emits an event when a controller's mesh has been loaded;
  18216. */
  18217. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18218. /**
  18219. * Emits an event when the HMD's pose has been updated.
  18220. */
  18221. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18222. private _poseSet;
  18223. /**
  18224. * If the rig cameras be used as parent instead of this camera.
  18225. */
  18226. rigParenting: boolean;
  18227. private _lightOnControllers;
  18228. private _defaultHeight?;
  18229. /**
  18230. * Instantiates a WebVRFreeCamera.
  18231. * @param name The name of the WebVRFreeCamera
  18232. * @param position The starting anchor position for the camera
  18233. * @param scene The scene the camera belongs to
  18234. * @param webVROptions a set of customizable options for the webVRCamera
  18235. */
  18236. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18237. /**
  18238. * Gets the device distance from the ground in meters.
  18239. * @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.
  18240. */
  18241. deviceDistanceToRoomGround(): number;
  18242. /**
  18243. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18244. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18245. */
  18246. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18247. /**
  18248. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18249. * @returns A promise with a boolean set to if the standing matrix is supported.
  18250. */
  18251. useStandingMatrixAsync(): Promise<boolean>;
  18252. /**
  18253. * Disposes the camera
  18254. */
  18255. dispose(): void;
  18256. /**
  18257. * Gets a vrController by name.
  18258. * @param name The name of the controller to retreive
  18259. * @returns the controller matching the name specified or null if not found
  18260. */
  18261. getControllerByName(name: string): Nullable<WebVRController>;
  18262. private _leftController;
  18263. /**
  18264. * The controller corresponding to the users left hand.
  18265. */
  18266. readonly leftController: Nullable<WebVRController>;
  18267. private _rightController;
  18268. /**
  18269. * The controller corresponding to the users right hand.
  18270. */
  18271. readonly rightController: Nullable<WebVRController>;
  18272. /**
  18273. * Casts a ray forward from the vrCamera's gaze.
  18274. * @param length Length of the ray (default: 100)
  18275. * @returns the ray corresponding to the gaze
  18276. */
  18277. getForwardRay(length?: number): Ray;
  18278. /**
  18279. * @hidden
  18280. * Updates the camera based on device's frame data
  18281. */
  18282. _checkInputs(): void;
  18283. /**
  18284. * Updates the poseControlled values based on the input device pose.
  18285. * @param poseData Pose coming from the device
  18286. */
  18287. updateFromDevice(poseData: DevicePose): void;
  18288. private _htmlElementAttached;
  18289. private _detachIfAttached;
  18290. /**
  18291. * WebVR's attach control will start broadcasting frames to the device.
  18292. * Note that in certain browsers (chrome for example) this function must be called
  18293. * within a user-interaction callback. Example:
  18294. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18295. *
  18296. * @param element html element to attach the vrDevice to
  18297. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18298. */
  18299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18300. /**
  18301. * Detaches the camera from the html element and disables VR
  18302. *
  18303. * @param element html element to detach from
  18304. */
  18305. detachControl(element: HTMLElement): void;
  18306. /**
  18307. * @returns the name of this class
  18308. */
  18309. getClassName(): string;
  18310. /**
  18311. * Calls resetPose on the vrDisplay
  18312. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18313. */
  18314. resetToCurrentRotation(): void;
  18315. /**
  18316. * @hidden
  18317. * Updates the rig cameras (left and right eye)
  18318. */
  18319. _updateRigCameras(): void;
  18320. private _workingVector;
  18321. private _oneVector;
  18322. private _workingMatrix;
  18323. private updateCacheCalled;
  18324. private _correctPositionIfNotTrackPosition;
  18325. /**
  18326. * @hidden
  18327. * Updates the cached values of the camera
  18328. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18329. */
  18330. _updateCache(ignoreParentClass?: boolean): void;
  18331. /**
  18332. * @hidden
  18333. * Get current device position in babylon world
  18334. */
  18335. _computeDevicePosition(): void;
  18336. /**
  18337. * Updates the current device position and rotation in the babylon world
  18338. */
  18339. update(): void;
  18340. /**
  18341. * @hidden
  18342. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18343. * @returns an identity matrix
  18344. */
  18345. _getViewMatrix(): Matrix;
  18346. private _tmpMatrix;
  18347. /**
  18348. * This function is called by the two RIG cameras.
  18349. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18350. * @hidden
  18351. */
  18352. _getWebVRViewMatrix(): Matrix;
  18353. /** @hidden */
  18354. _getWebVRProjectionMatrix(): Matrix;
  18355. private _onGamepadConnectedObserver;
  18356. private _onGamepadDisconnectedObserver;
  18357. private _updateCacheWhenTrackingDisabledObserver;
  18358. /**
  18359. * Initializes the controllers and their meshes
  18360. */
  18361. initControllers(): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/PostProcesses/postProcess" {
  18365. import { Nullable } from "babylonjs/types";
  18366. import { SmartArray } from "babylonjs/Misc/smartArray";
  18367. import { Observable } from "babylonjs/Misc/observable";
  18368. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18369. import { Camera } from "babylonjs/Cameras/camera";
  18370. import { Effect } from "babylonjs/Materials/effect";
  18371. import "babylonjs/Shaders/postprocess.vertex";
  18372. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18374. import { Engine } from "babylonjs/Engines/engine";
  18375. /**
  18376. * Size options for a post process
  18377. */
  18378. export type PostProcessOptions = {
  18379. width: number;
  18380. height: number;
  18381. };
  18382. /**
  18383. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18384. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18385. */
  18386. export class PostProcess {
  18387. /** Name of the PostProcess. */
  18388. name: string;
  18389. /**
  18390. * Gets or sets the unique id of the post process
  18391. */
  18392. uniqueId: number;
  18393. /**
  18394. * Width of the texture to apply the post process on
  18395. */
  18396. width: number;
  18397. /**
  18398. * Height of the texture to apply the post process on
  18399. */
  18400. height: number;
  18401. /**
  18402. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18403. * @hidden
  18404. */
  18405. _outputTexture: Nullable<InternalTexture>;
  18406. /**
  18407. * Sampling mode used by the shader
  18408. * See https://doc.babylonjs.com/classes/3.1/texture
  18409. */
  18410. renderTargetSamplingMode: number;
  18411. /**
  18412. * Clear color to use when screen clearing
  18413. */
  18414. clearColor: Color4;
  18415. /**
  18416. * If the buffer needs to be cleared before applying the post process. (default: true)
  18417. * Should be set to false if shader will overwrite all previous pixels.
  18418. */
  18419. autoClear: boolean;
  18420. /**
  18421. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18422. */
  18423. alphaMode: number;
  18424. /**
  18425. * Sets the setAlphaBlendConstants of the babylon engine
  18426. */
  18427. alphaConstants: Color4;
  18428. /**
  18429. * Animations to be used for the post processing
  18430. */
  18431. animations: import("babylonjs/Animations/animation").Animation[];
  18432. /**
  18433. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18434. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18435. */
  18436. enablePixelPerfectMode: boolean;
  18437. /**
  18438. * Force the postprocess to be applied without taking in account viewport
  18439. */
  18440. forceFullscreenViewport: boolean;
  18441. /**
  18442. * List of inspectable custom properties (used by the Inspector)
  18443. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18444. */
  18445. inspectableCustomProperties: IInspectable[];
  18446. /**
  18447. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18448. *
  18449. * | Value | Type | Description |
  18450. * | ----- | ----------------------------------- | ----------- |
  18451. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18452. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18453. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18454. *
  18455. */
  18456. scaleMode: number;
  18457. /**
  18458. * Force textures to be a power of two (default: false)
  18459. */
  18460. alwaysForcePOT: boolean;
  18461. private _samples;
  18462. /**
  18463. * Number of sample textures (default: 1)
  18464. */
  18465. samples: number;
  18466. /**
  18467. * Modify the scale of the post process to be the same as the viewport (default: false)
  18468. */
  18469. adaptScaleToCurrentViewport: boolean;
  18470. private _camera;
  18471. private _scene;
  18472. private _engine;
  18473. private _options;
  18474. private _reusable;
  18475. private _textureType;
  18476. /**
  18477. * Smart array of input and output textures for the post process.
  18478. * @hidden
  18479. */
  18480. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18481. /**
  18482. * The index in _textures that corresponds to the output texture.
  18483. * @hidden
  18484. */
  18485. _currentRenderTextureInd: number;
  18486. private _effect;
  18487. private _samplers;
  18488. private _fragmentUrl;
  18489. private _vertexUrl;
  18490. private _parameters;
  18491. private _scaleRatio;
  18492. protected _indexParameters: any;
  18493. private _shareOutputWithPostProcess;
  18494. private _texelSize;
  18495. private _forcedOutputTexture;
  18496. /**
  18497. * Returns the fragment url or shader name used in the post process.
  18498. * @returns the fragment url or name in the shader store.
  18499. */
  18500. getEffectName(): string;
  18501. /**
  18502. * An event triggered when the postprocess is activated.
  18503. */
  18504. onActivateObservable: Observable<Camera>;
  18505. private _onActivateObserver;
  18506. /**
  18507. * A function that is added to the onActivateObservable
  18508. */
  18509. onActivate: Nullable<(camera: Camera) => void>;
  18510. /**
  18511. * An event triggered when the postprocess changes its size.
  18512. */
  18513. onSizeChangedObservable: Observable<PostProcess>;
  18514. private _onSizeChangedObserver;
  18515. /**
  18516. * A function that is added to the onSizeChangedObservable
  18517. */
  18518. onSizeChanged: (postProcess: PostProcess) => void;
  18519. /**
  18520. * An event triggered when the postprocess applies its effect.
  18521. */
  18522. onApplyObservable: Observable<Effect>;
  18523. private _onApplyObserver;
  18524. /**
  18525. * A function that is added to the onApplyObservable
  18526. */
  18527. onApply: (effect: Effect) => void;
  18528. /**
  18529. * An event triggered before rendering the postprocess
  18530. */
  18531. onBeforeRenderObservable: Observable<Effect>;
  18532. private _onBeforeRenderObserver;
  18533. /**
  18534. * A function that is added to the onBeforeRenderObservable
  18535. */
  18536. onBeforeRender: (effect: Effect) => void;
  18537. /**
  18538. * An event triggered after rendering the postprocess
  18539. */
  18540. onAfterRenderObservable: Observable<Effect>;
  18541. private _onAfterRenderObserver;
  18542. /**
  18543. * A function that is added to the onAfterRenderObservable
  18544. */
  18545. onAfterRender: (efect: Effect) => void;
  18546. /**
  18547. * 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
  18548. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18549. */
  18550. inputTexture: InternalTexture;
  18551. /**
  18552. * Gets the camera which post process is applied to.
  18553. * @returns The camera the post process is applied to.
  18554. */
  18555. getCamera(): Camera;
  18556. /**
  18557. * Gets the texel size of the postprocess.
  18558. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18559. */
  18560. readonly texelSize: Vector2;
  18561. /**
  18562. * Creates a new instance PostProcess
  18563. * @param name The name of the PostProcess.
  18564. * @param fragmentUrl The url of the fragment shader to be used.
  18565. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18566. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18567. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18568. * @param camera The camera to apply the render pass to.
  18569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18570. * @param engine The engine which the post process will be applied. (default: current engine)
  18571. * @param reusable If the post process can be reused on the same frame. (default: false)
  18572. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18573. * @param textureType Type of textures used when performing the post process. (default: 0)
  18574. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18575. * @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
  18576. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18577. */
  18578. constructor(
  18579. /** Name of the PostProcess. */
  18580. 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);
  18581. /**
  18582. * Gets a string idenfifying the name of the class
  18583. * @returns "PostProcess" string
  18584. */
  18585. getClassName(): string;
  18586. /**
  18587. * Gets the engine which this post process belongs to.
  18588. * @returns The engine the post process was enabled with.
  18589. */
  18590. getEngine(): Engine;
  18591. /**
  18592. * The effect that is created when initializing the post process.
  18593. * @returns The created effect corresponding the the postprocess.
  18594. */
  18595. getEffect(): Effect;
  18596. /**
  18597. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18598. * @param postProcess The post process to share the output with.
  18599. * @returns This post process.
  18600. */
  18601. shareOutputWith(postProcess: PostProcess): PostProcess;
  18602. /**
  18603. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18604. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18605. */
  18606. useOwnOutput(): void;
  18607. /**
  18608. * Updates the effect with the current post process compile time values and recompiles the shader.
  18609. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18610. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18611. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18612. * @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
  18613. * @param onCompiled Called when the shader has been compiled.
  18614. * @param onError Called if there is an error when compiling a shader.
  18615. */
  18616. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18617. /**
  18618. * The post process is reusable if it can be used multiple times within one frame.
  18619. * @returns If the post process is reusable
  18620. */
  18621. isReusable(): boolean;
  18622. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18623. markTextureDirty(): void;
  18624. /**
  18625. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18626. * 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.
  18627. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18628. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18629. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18630. * @returns The target texture that was bound to be written to.
  18631. */
  18632. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18633. /**
  18634. * If the post process is supported.
  18635. */
  18636. readonly isSupported: boolean;
  18637. /**
  18638. * The aspect ratio of the output texture.
  18639. */
  18640. readonly aspectRatio: number;
  18641. /**
  18642. * Get a value indicating if the post-process is ready to be used
  18643. * @returns true if the post-process is ready (shader is compiled)
  18644. */
  18645. isReady(): boolean;
  18646. /**
  18647. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18648. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18649. */
  18650. apply(): Nullable<Effect>;
  18651. private _disposeTextures;
  18652. /**
  18653. * Disposes the post process.
  18654. * @param camera The camera to dispose the post process on.
  18655. */
  18656. dispose(camera?: Camera): void;
  18657. }
  18658. }
  18659. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18660. /** @hidden */
  18661. export var kernelBlurVaryingDeclaration: {
  18662. name: string;
  18663. shader: string;
  18664. };
  18665. }
  18666. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18667. /** @hidden */
  18668. export var kernelBlurFragment: {
  18669. name: string;
  18670. shader: string;
  18671. };
  18672. }
  18673. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18674. /** @hidden */
  18675. export var kernelBlurFragment2: {
  18676. name: string;
  18677. shader: string;
  18678. };
  18679. }
  18680. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18681. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18682. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18685. /** @hidden */
  18686. export var kernelBlurPixelShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18692. /** @hidden */
  18693. export var kernelBlurVertex: {
  18694. name: string;
  18695. shader: string;
  18696. };
  18697. }
  18698. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18699. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18700. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18701. /** @hidden */
  18702. export var kernelBlurVertexShader: {
  18703. name: string;
  18704. shader: string;
  18705. };
  18706. }
  18707. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18708. import { Vector2 } from "babylonjs/Maths/math";
  18709. import { Nullable } from "babylonjs/types";
  18710. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18711. import { Camera } from "babylonjs/Cameras/camera";
  18712. import { Effect } from "babylonjs/Materials/effect";
  18713. import { Engine } from "babylonjs/Engines/engine";
  18714. import "babylonjs/Shaders/kernelBlur.fragment";
  18715. import "babylonjs/Shaders/kernelBlur.vertex";
  18716. /**
  18717. * The Blur Post Process which blurs an image based on a kernel and direction.
  18718. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18719. */
  18720. export class BlurPostProcess extends PostProcess {
  18721. /** The direction in which to blur the image. */
  18722. direction: Vector2;
  18723. private blockCompilation;
  18724. protected _kernel: number;
  18725. protected _idealKernel: number;
  18726. protected _packedFloat: boolean;
  18727. private _staticDefines;
  18728. /**
  18729. * Sets the length in pixels of the blur sample region
  18730. */
  18731. /**
  18732. * Gets the length in pixels of the blur sample region
  18733. */
  18734. kernel: number;
  18735. /**
  18736. * Sets wether or not the blur needs to unpack/repack floats
  18737. */
  18738. /**
  18739. * Gets wether or not the blur is unpacking/repacking floats
  18740. */
  18741. packedFloat: boolean;
  18742. /**
  18743. * Creates a new instance BlurPostProcess
  18744. * @param name The name of the effect.
  18745. * @param direction The direction in which to blur the image.
  18746. * @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.
  18747. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18748. * @param camera The camera to apply the render pass to.
  18749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18750. * @param engine The engine which the post process will be applied. (default: current engine)
  18751. * @param reusable If the post process can be reused on the same frame. (default: false)
  18752. * @param textureType Type of textures used when performing the post process. (default: 0)
  18753. * @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)
  18754. */
  18755. constructor(name: string,
  18756. /** The direction in which to blur the image. */
  18757. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18758. /**
  18759. * Updates the effect with the current post process compile time values and recompiles the shader.
  18760. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18761. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18762. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18763. * @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
  18764. * @param onCompiled Called when the shader has been compiled.
  18765. * @param onError Called if there is an error when compiling a shader.
  18766. */
  18767. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18768. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18769. /**
  18770. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18771. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18772. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18773. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18774. * The gaps between physical kernels are compensated for in the weighting of the samples
  18775. * @param idealKernel Ideal blur kernel.
  18776. * @return Nearest best kernel.
  18777. */
  18778. protected _nearestBestKernel(idealKernel: number): number;
  18779. /**
  18780. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18781. * @param x The point on the Gaussian distribution to sample.
  18782. * @return the value of the Gaussian function at x.
  18783. */
  18784. protected _gaussianWeight(x: number): number;
  18785. /**
  18786. * Generates a string that can be used as a floating point number in GLSL.
  18787. * @param x Value to print.
  18788. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18789. * @return GLSL float string.
  18790. */
  18791. protected _glslFloat(x: number, decimalFigures?: number): string;
  18792. }
  18793. }
  18794. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18795. import { Scene } from "babylonjs/scene";
  18796. import { Plane } from "babylonjs/Maths/math";
  18797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18798. /**
  18799. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18800. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18801. * You can then easily use it as a reflectionTexture on a flat surface.
  18802. * In case the surface is not a plane, please consider relying on reflection probes.
  18803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18804. */
  18805. export class MirrorTexture extends RenderTargetTexture {
  18806. private scene;
  18807. /**
  18808. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18809. * 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.
  18810. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18811. */
  18812. mirrorPlane: Plane;
  18813. /**
  18814. * Define the blur ratio used to blur the reflection if needed.
  18815. */
  18816. blurRatio: number;
  18817. /**
  18818. * Define the adaptive blur kernel used to blur the reflection if needed.
  18819. * This will autocompute the closest best match for the `blurKernel`
  18820. */
  18821. adaptiveBlurKernel: number;
  18822. /**
  18823. * Define the blur kernel used to blur the reflection if needed.
  18824. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18825. */
  18826. blurKernel: number;
  18827. /**
  18828. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18829. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18830. */
  18831. blurKernelX: number;
  18832. /**
  18833. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18834. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18835. */
  18836. blurKernelY: number;
  18837. private _autoComputeBlurKernel;
  18838. protected _onRatioRescale(): void;
  18839. private _updateGammaSpace;
  18840. private _imageProcessingConfigChangeObserver;
  18841. private _transformMatrix;
  18842. private _mirrorMatrix;
  18843. private _savedViewMatrix;
  18844. private _blurX;
  18845. private _blurY;
  18846. private _adaptiveBlurKernel;
  18847. private _blurKernelX;
  18848. private _blurKernelY;
  18849. private _blurRatio;
  18850. /**
  18851. * Instantiates a Mirror Texture.
  18852. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18853. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18854. * You can then easily use it as a reflectionTexture on a flat surface.
  18855. * In case the surface is not a plane, please consider relying on reflection probes.
  18856. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18857. * @param name
  18858. * @param size
  18859. * @param scene
  18860. * @param generateMipMaps
  18861. * @param type
  18862. * @param samplingMode
  18863. * @param generateDepthBuffer
  18864. */
  18865. constructor(name: string, size: number | {
  18866. width: number;
  18867. height: number;
  18868. } | {
  18869. ratio: number;
  18870. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18871. private _preparePostProcesses;
  18872. /**
  18873. * Clone the mirror texture.
  18874. * @returns the cloned texture
  18875. */
  18876. clone(): MirrorTexture;
  18877. /**
  18878. * Serialize the texture to a JSON representation you could use in Parse later on
  18879. * @returns the serialized JSON representation
  18880. */
  18881. serialize(): any;
  18882. /**
  18883. * Dispose the texture and release its associated resources.
  18884. */
  18885. dispose(): void;
  18886. }
  18887. }
  18888. declare module "babylonjs/Materials/Textures/texture" {
  18889. import { Observable } from "babylonjs/Misc/observable";
  18890. import { Nullable } from "babylonjs/types";
  18891. import { Scene } from "babylonjs/scene";
  18892. import { Matrix } from "babylonjs/Maths/math";
  18893. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18894. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18895. import { Engine } from "babylonjs/Engines/engine";
  18896. /**
  18897. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18898. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18899. */
  18900. export class Texture extends BaseTexture {
  18901. /** @hidden */
  18902. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18903. /** @hidden */
  18904. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18905. /** @hidden */
  18906. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18907. /** nearest is mag = nearest and min = nearest and mip = linear */
  18908. static readonly NEAREST_SAMPLINGMODE: number;
  18909. /** nearest is mag = nearest and min = nearest and mip = linear */
  18910. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18911. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18912. static readonly BILINEAR_SAMPLINGMODE: number;
  18913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18914. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18915. /** Trilinear is mag = linear and min = linear and mip = linear */
  18916. static readonly TRILINEAR_SAMPLINGMODE: number;
  18917. /** Trilinear is mag = linear and min = linear and mip = linear */
  18918. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18919. /** mag = nearest and min = nearest and mip = nearest */
  18920. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18921. /** mag = nearest and min = linear and mip = nearest */
  18922. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18923. /** mag = nearest and min = linear and mip = linear */
  18924. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18925. /** mag = nearest and min = linear and mip = none */
  18926. static readonly NEAREST_LINEAR: number;
  18927. /** mag = nearest and min = nearest and mip = none */
  18928. static readonly NEAREST_NEAREST: number;
  18929. /** mag = linear and min = nearest and mip = nearest */
  18930. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18931. /** mag = linear and min = nearest and mip = linear */
  18932. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18933. /** mag = linear and min = linear and mip = none */
  18934. static readonly LINEAR_LINEAR: number;
  18935. /** mag = linear and min = nearest and mip = none */
  18936. static readonly LINEAR_NEAREST: number;
  18937. /** Explicit coordinates mode */
  18938. static readonly EXPLICIT_MODE: number;
  18939. /** Spherical coordinates mode */
  18940. static readonly SPHERICAL_MODE: number;
  18941. /** Planar coordinates mode */
  18942. static readonly PLANAR_MODE: number;
  18943. /** Cubic coordinates mode */
  18944. static readonly CUBIC_MODE: number;
  18945. /** Projection coordinates mode */
  18946. static readonly PROJECTION_MODE: number;
  18947. /** Inverse Cubic coordinates mode */
  18948. static readonly SKYBOX_MODE: number;
  18949. /** Inverse Cubic coordinates mode */
  18950. static readonly INVCUBIC_MODE: number;
  18951. /** Equirectangular coordinates mode */
  18952. static readonly EQUIRECTANGULAR_MODE: number;
  18953. /** Equirectangular Fixed coordinates mode */
  18954. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18955. /** Equirectangular Fixed Mirrored coordinates mode */
  18956. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18957. /** Texture is not repeating outside of 0..1 UVs */
  18958. static readonly CLAMP_ADDRESSMODE: number;
  18959. /** Texture is repeating outside of 0..1 UVs */
  18960. static readonly WRAP_ADDRESSMODE: number;
  18961. /** Texture is repeating and mirrored */
  18962. static readonly MIRROR_ADDRESSMODE: number;
  18963. /**
  18964. * 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
  18965. */
  18966. static UseSerializedUrlIfAny: boolean;
  18967. /**
  18968. * Define the url of the texture.
  18969. */
  18970. url: Nullable<string>;
  18971. /**
  18972. * Define an offset on the texture to offset the u coordinates of the UVs
  18973. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18974. */
  18975. uOffset: number;
  18976. /**
  18977. * Define an offset on the texture to offset the v coordinates of the UVs
  18978. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18979. */
  18980. vOffset: number;
  18981. /**
  18982. * Define an offset on the texture to scale the u coordinates of the UVs
  18983. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18984. */
  18985. uScale: number;
  18986. /**
  18987. * Define an offset on the texture to scale the v coordinates of the UVs
  18988. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18989. */
  18990. vScale: number;
  18991. /**
  18992. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18993. * @see http://doc.babylonjs.com/how_to/more_materials
  18994. */
  18995. uAng: number;
  18996. /**
  18997. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18998. * @see http://doc.babylonjs.com/how_to/more_materials
  18999. */
  19000. vAng: number;
  19001. /**
  19002. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  19003. * @see http://doc.babylonjs.com/how_to/more_materials
  19004. */
  19005. wAng: number;
  19006. /**
  19007. * Defines the center of rotation (U)
  19008. */
  19009. uRotationCenter: number;
  19010. /**
  19011. * Defines the center of rotation (V)
  19012. */
  19013. vRotationCenter: number;
  19014. /**
  19015. * Defines the center of rotation (W)
  19016. */
  19017. wRotationCenter: number;
  19018. /**
  19019. * Are mip maps generated for this texture or not.
  19020. */
  19021. readonly noMipmap: boolean;
  19022. /**
  19023. * List of inspectable custom properties (used by the Inspector)
  19024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19025. */
  19026. inspectableCustomProperties: Nullable<IInspectable[]>;
  19027. private _noMipmap;
  19028. /** @hidden */
  19029. _invertY: boolean;
  19030. private _rowGenerationMatrix;
  19031. private _cachedTextureMatrix;
  19032. private _projectionModeMatrix;
  19033. private _t0;
  19034. private _t1;
  19035. private _t2;
  19036. private _cachedUOffset;
  19037. private _cachedVOffset;
  19038. private _cachedUScale;
  19039. private _cachedVScale;
  19040. private _cachedUAng;
  19041. private _cachedVAng;
  19042. private _cachedWAng;
  19043. private _cachedProjectionMatrixId;
  19044. private _cachedCoordinatesMode;
  19045. /** @hidden */
  19046. protected _initialSamplingMode: number;
  19047. /** @hidden */
  19048. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19049. private _deleteBuffer;
  19050. protected _format: Nullable<number>;
  19051. private _delayedOnLoad;
  19052. private _delayedOnError;
  19053. /**
  19054. * Observable triggered once the texture has been loaded.
  19055. */
  19056. onLoadObservable: Observable<Texture>;
  19057. protected _isBlocking: boolean;
  19058. /**
  19059. * Is the texture preventing material to render while loading.
  19060. * If false, a default texture will be used instead of the loading one during the preparation step.
  19061. */
  19062. isBlocking: boolean;
  19063. /**
  19064. * Get the current sampling mode associated with the texture.
  19065. */
  19066. readonly samplingMode: number;
  19067. /**
  19068. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19069. */
  19070. readonly invertY: boolean;
  19071. /**
  19072. * Instantiates a new texture.
  19073. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19074. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19075. * @param url define the url of the picture to load as a texture
  19076. * @param scene define the scene or engine the texture will belong to
  19077. * @param noMipmap define if the texture will require mip maps or not
  19078. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19079. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19080. * @param onLoad define a callback triggered when the texture has been loaded
  19081. * @param onError define a callback triggered when an error occurred during the loading session
  19082. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19083. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19084. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19085. */
  19086. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  19087. /**
  19088. * Update the url (and optional buffer) of this texture if url was null during construction.
  19089. * @param url the url of the texture
  19090. * @param buffer the buffer of the texture (defaults to null)
  19091. * @param onLoad callback called when the texture is loaded (defaults to null)
  19092. */
  19093. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19094. /**
  19095. * Finish the loading sequence of a texture flagged as delayed load.
  19096. * @hidden
  19097. */
  19098. delayLoad(): void;
  19099. private _prepareRowForTextureGeneration;
  19100. /**
  19101. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19102. * @returns the transform matrix of the texture.
  19103. */
  19104. getTextureMatrix(): Matrix;
  19105. /**
  19106. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19107. * @returns The reflection texture transform
  19108. */
  19109. getReflectionTextureMatrix(): Matrix;
  19110. /**
  19111. * Clones the texture.
  19112. * @returns the cloned texture
  19113. */
  19114. clone(): Texture;
  19115. /**
  19116. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19117. * @returns The JSON representation of the texture
  19118. */
  19119. serialize(): any;
  19120. /**
  19121. * Get the current class name of the texture useful for serialization or dynamic coding.
  19122. * @returns "Texture"
  19123. */
  19124. getClassName(): string;
  19125. /**
  19126. * Dispose the texture and release its associated resources.
  19127. */
  19128. dispose(): void;
  19129. /**
  19130. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19131. * @param parsedTexture Define the JSON representation of the texture
  19132. * @param scene Define the scene the parsed texture should be instantiated in
  19133. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19134. * @returns The parsed texture if successful
  19135. */
  19136. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19137. /**
  19138. * Creates a texture from its base 64 representation.
  19139. * @param data Define the base64 payload without the data: prefix
  19140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19141. * @param scene Define the scene the texture should belong to
  19142. * @param noMipmap Forces the texture to not create mip map information if true
  19143. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19144. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19145. * @param onLoad define a callback triggered when the texture has been loaded
  19146. * @param onError define a callback triggered when an error occurred during the loading session
  19147. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19148. * @returns the created texture
  19149. */
  19150. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19151. /**
  19152. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19153. * @param data Define the base64 payload without the data: prefix
  19154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19155. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19156. * @param scene Define the scene the texture should belong to
  19157. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19158. * @param noMipmap Forces the texture to not create mip map information if true
  19159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19161. * @param onLoad define a callback triggered when the texture has been loaded
  19162. * @param onError define a callback triggered when an error occurred during the loading session
  19163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19164. * @returns the created texture
  19165. */
  19166. 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;
  19167. }
  19168. }
  19169. declare module "babylonjs/PostProcesses/postProcessManager" {
  19170. import { Nullable } from "babylonjs/types";
  19171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19172. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19173. import { Scene } from "babylonjs/scene";
  19174. /**
  19175. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19176. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19177. */
  19178. export class PostProcessManager {
  19179. private _scene;
  19180. private _indexBuffer;
  19181. private _vertexBuffers;
  19182. /**
  19183. * Creates a new instance PostProcess
  19184. * @param scene The scene that the post process is associated with.
  19185. */
  19186. constructor(scene: Scene);
  19187. private _prepareBuffers;
  19188. private _buildIndexBuffer;
  19189. /**
  19190. * Rebuilds the vertex buffers of the manager.
  19191. * @hidden
  19192. */
  19193. _rebuild(): void;
  19194. /**
  19195. * Prepares a frame to be run through a post process.
  19196. * @param sourceTexture The input texture to the post procesess. (default: null)
  19197. * @param postProcesses An array of post processes to be run. (default: null)
  19198. * @returns True if the post processes were able to be run.
  19199. * @hidden
  19200. */
  19201. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19202. /**
  19203. * Manually render a set of post processes to a texture.
  19204. * @param postProcesses An array of post processes to be run.
  19205. * @param targetTexture The target texture to render to.
  19206. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19207. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19208. * @param lodLevel defines which lod of the texture to render to
  19209. */
  19210. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19211. /**
  19212. * Finalize the result of the output of the postprocesses.
  19213. * @param doNotPresent If true the result will not be displayed to the screen.
  19214. * @param targetTexture The target texture to render to.
  19215. * @param faceIndex The index of the face to bind the target texture to.
  19216. * @param postProcesses The array of post processes to render.
  19217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19218. * @hidden
  19219. */
  19220. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19221. /**
  19222. * Disposes of the post process manager.
  19223. */
  19224. dispose(): void;
  19225. }
  19226. }
  19227. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19228. import { Scene } from "babylonjs/scene";
  19229. import { ISceneComponent } from "babylonjs/sceneComponent";
  19230. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19231. module "babylonjs/abstractScene" {
  19232. interface AbstractScene {
  19233. /**
  19234. * The list of procedural textures added to the scene
  19235. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19236. */
  19237. proceduralTextures: Array<ProceduralTexture>;
  19238. }
  19239. }
  19240. /**
  19241. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19242. * in a given scene.
  19243. */
  19244. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19245. /**
  19246. * The component name helpfull to identify the component in the list of scene components.
  19247. */
  19248. readonly name: string;
  19249. /**
  19250. * The scene the component belongs to.
  19251. */
  19252. scene: Scene;
  19253. /**
  19254. * Creates a new instance of the component for the given scene
  19255. * @param scene Defines the scene to register the component in
  19256. */
  19257. constructor(scene: Scene);
  19258. /**
  19259. * Registers the component in a given scene
  19260. */
  19261. register(): void;
  19262. /**
  19263. * Rebuilds the elements related to this component in case of
  19264. * context lost for instance.
  19265. */
  19266. rebuild(): void;
  19267. /**
  19268. * Disposes the component and the associated ressources.
  19269. */
  19270. dispose(): void;
  19271. private _beforeClear;
  19272. }
  19273. }
  19274. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19276. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19277. module "babylonjs/Engines/engine" {
  19278. interface Engine {
  19279. /**
  19280. * Creates a new render target cube texture
  19281. * @param size defines the size of the texture
  19282. * @param options defines the options used to create the texture
  19283. * @returns a new render target cube texture stored in an InternalTexture
  19284. */
  19285. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19286. }
  19287. }
  19288. }
  19289. declare module "babylonjs/Shaders/procedural.vertex" {
  19290. /** @hidden */
  19291. export var proceduralVertexShader: {
  19292. name: string;
  19293. shader: string;
  19294. };
  19295. }
  19296. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19297. import { Observable } from "babylonjs/Misc/observable";
  19298. import { Nullable } from "babylonjs/types";
  19299. import { Scene } from "babylonjs/scene";
  19300. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19301. import { Effect } from "babylonjs/Materials/effect";
  19302. import { Texture } from "babylonjs/Materials/Textures/texture";
  19303. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19304. import "babylonjs/Shaders/procedural.vertex";
  19305. /**
  19306. * 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.
  19307. * This is the base class of any Procedural texture and contains most of the shareable code.
  19308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19309. */
  19310. export class ProceduralTexture extends Texture {
  19311. isCube: boolean;
  19312. /**
  19313. * Define if the texture is enabled or not (disabled texture will not render)
  19314. */
  19315. isEnabled: boolean;
  19316. /**
  19317. * Define if the texture must be cleared before rendering (default is true)
  19318. */
  19319. autoClear: boolean;
  19320. /**
  19321. * Callback called when the texture is generated
  19322. */
  19323. onGenerated: () => void;
  19324. /**
  19325. * Event raised when the texture is generated
  19326. */
  19327. onGeneratedObservable: Observable<ProceduralTexture>;
  19328. /** @hidden */
  19329. _generateMipMaps: boolean;
  19330. /** @hidden **/
  19331. _effect: Effect;
  19332. /** @hidden */
  19333. _textures: {
  19334. [key: string]: Texture;
  19335. };
  19336. private _size;
  19337. private _currentRefreshId;
  19338. private _refreshRate;
  19339. private _vertexBuffers;
  19340. private _indexBuffer;
  19341. private _uniforms;
  19342. private _samplers;
  19343. private _fragment;
  19344. private _floats;
  19345. private _ints;
  19346. private _floatsArrays;
  19347. private _colors3;
  19348. private _colors4;
  19349. private _vectors2;
  19350. private _vectors3;
  19351. private _matrices;
  19352. private _fallbackTexture;
  19353. private _fallbackTextureUsed;
  19354. private _engine;
  19355. private _cachedDefines;
  19356. private _contentUpdateId;
  19357. private _contentData;
  19358. /**
  19359. * Instantiates a new procedural texture.
  19360. * 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.
  19361. * This is the base class of any Procedural texture and contains most of the shareable code.
  19362. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19363. * @param name Define the name of the texture
  19364. * @param size Define the size of the texture to create
  19365. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19366. * @param scene Define the scene the texture belongs to
  19367. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19368. * @param generateMipMaps Define if the texture should creates mip maps or not
  19369. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19370. */
  19371. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19372. /**
  19373. * The effect that is created when initializing the post process.
  19374. * @returns The created effect corresponding the the postprocess.
  19375. */
  19376. getEffect(): Effect;
  19377. /**
  19378. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19379. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19380. */
  19381. getContent(): Nullable<ArrayBufferView>;
  19382. private _createIndexBuffer;
  19383. /** @hidden */
  19384. _rebuild(): void;
  19385. /**
  19386. * Resets the texture in order to recreate its associated resources.
  19387. * This can be called in case of context loss
  19388. */
  19389. reset(): void;
  19390. protected _getDefines(): string;
  19391. /**
  19392. * Is the texture ready to be used ? (rendered at least once)
  19393. * @returns true if ready, otherwise, false.
  19394. */
  19395. isReady(): boolean;
  19396. /**
  19397. * Resets the refresh counter of the texture and start bak from scratch.
  19398. * Could be useful to regenerate the texture if it is setup to render only once.
  19399. */
  19400. resetRefreshCounter(): void;
  19401. /**
  19402. * Set the fragment shader to use in order to render the texture.
  19403. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19404. */
  19405. setFragment(fragment: any): void;
  19406. /**
  19407. * Define the refresh rate of the texture or the rendering frequency.
  19408. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19409. */
  19410. refreshRate: number;
  19411. /** @hidden */
  19412. _shouldRender(): boolean;
  19413. /**
  19414. * Get the size the texture is rendering at.
  19415. * @returns the size (texture is always squared)
  19416. */
  19417. getRenderSize(): number;
  19418. /**
  19419. * Resize the texture to new value.
  19420. * @param size Define the new size the texture should have
  19421. * @param generateMipMaps Define whether the new texture should create mip maps
  19422. */
  19423. resize(size: number, generateMipMaps: boolean): void;
  19424. private _checkUniform;
  19425. /**
  19426. * Set a texture in the shader program used to render.
  19427. * @param name Define the name of the uniform samplers as defined in the shader
  19428. * @param texture Define the texture to bind to this sampler
  19429. * @return the texture itself allowing "fluent" like uniform updates
  19430. */
  19431. setTexture(name: string, texture: Texture): ProceduralTexture;
  19432. /**
  19433. * Set a float in the shader.
  19434. * @param name Define the name of the uniform as defined in the shader
  19435. * @param value Define the value to give to the uniform
  19436. * @return the texture itself allowing "fluent" like uniform updates
  19437. */
  19438. setFloat(name: string, value: number): ProceduralTexture;
  19439. /**
  19440. * Set a int in the shader.
  19441. * @param name Define the name of the uniform as defined in the shader
  19442. * @param value Define the value to give to the uniform
  19443. * @return the texture itself allowing "fluent" like uniform updates
  19444. */
  19445. setInt(name: string, value: number): ProceduralTexture;
  19446. /**
  19447. * Set an array of floats in the shader.
  19448. * @param name Define the name of the uniform as defined in the shader
  19449. * @param value Define the value to give to the uniform
  19450. * @return the texture itself allowing "fluent" like uniform updates
  19451. */
  19452. setFloats(name: string, value: number[]): ProceduralTexture;
  19453. /**
  19454. * Set a vec3 in the shader from a Color3.
  19455. * @param name Define the name of the uniform as defined in the shader
  19456. * @param value Define the value to give to the uniform
  19457. * @return the texture itself allowing "fluent" like uniform updates
  19458. */
  19459. setColor3(name: string, value: Color3): ProceduralTexture;
  19460. /**
  19461. * Set a vec4 in the shader from a Color4.
  19462. * @param name Define the name of the uniform as defined in the shader
  19463. * @param value Define the value to give to the uniform
  19464. * @return the texture itself allowing "fluent" like uniform updates
  19465. */
  19466. setColor4(name: string, value: Color4): ProceduralTexture;
  19467. /**
  19468. * Set a vec2 in the shader from a Vector2.
  19469. * @param name Define the name of the uniform as defined in the shader
  19470. * @param value Define the value to give to the uniform
  19471. * @return the texture itself allowing "fluent" like uniform updates
  19472. */
  19473. setVector2(name: string, value: Vector2): ProceduralTexture;
  19474. /**
  19475. * Set a vec3 in the shader from a Vector3.
  19476. * @param name Define the name of the uniform as defined in the shader
  19477. * @param value Define the value to give to the uniform
  19478. * @return the texture itself allowing "fluent" like uniform updates
  19479. */
  19480. setVector3(name: string, value: Vector3): ProceduralTexture;
  19481. /**
  19482. * Set a mat4 in the shader from a MAtrix.
  19483. * @param name Define the name of the uniform as defined in the shader
  19484. * @param value Define the value to give to the uniform
  19485. * @return the texture itself allowing "fluent" like uniform updates
  19486. */
  19487. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19488. /**
  19489. * Render the texture to its associated render target.
  19490. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19491. */
  19492. render(useCameraPostProcess?: boolean): void;
  19493. /**
  19494. * Clone the texture.
  19495. * @returns the cloned texture
  19496. */
  19497. clone(): ProceduralTexture;
  19498. /**
  19499. * Dispose the texture and release its asoociated resources.
  19500. */
  19501. dispose(): void;
  19502. }
  19503. }
  19504. declare module "babylonjs/Particles/baseParticleSystem" {
  19505. import { Nullable } from "babylonjs/types";
  19506. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19508. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19509. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19510. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19511. import { Scene } from "babylonjs/scene";
  19512. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19513. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19514. import { Texture } from "babylonjs/Materials/Textures/texture";
  19515. import { Animation } from "babylonjs/Animations/animation";
  19516. /**
  19517. * This represents the base class for particle system in Babylon.
  19518. * 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.
  19519. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19520. * @example https://doc.babylonjs.com/babylon101/particles
  19521. */
  19522. export class BaseParticleSystem {
  19523. /**
  19524. * Source color is added to the destination color without alpha affecting the result
  19525. */
  19526. static BLENDMODE_ONEONE: number;
  19527. /**
  19528. * Blend current color and particle color using particle’s alpha
  19529. */
  19530. static BLENDMODE_STANDARD: number;
  19531. /**
  19532. * Add current color and particle color multiplied by particle’s alpha
  19533. */
  19534. static BLENDMODE_ADD: number;
  19535. /**
  19536. * Multiply current color with particle color
  19537. */
  19538. static BLENDMODE_MULTIPLY: number;
  19539. /**
  19540. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19541. */
  19542. static BLENDMODE_MULTIPLYADD: number;
  19543. /**
  19544. * List of animations used by the particle system.
  19545. */
  19546. animations: Animation[];
  19547. /**
  19548. * The id of the Particle system.
  19549. */
  19550. id: string;
  19551. /**
  19552. * The friendly name of the Particle system.
  19553. */
  19554. name: string;
  19555. /**
  19556. * The rendering group used by the Particle system to chose when to render.
  19557. */
  19558. renderingGroupId: number;
  19559. /**
  19560. * The emitter represents the Mesh or position we are attaching the particle system to.
  19561. */
  19562. emitter: Nullable<AbstractMesh | Vector3>;
  19563. /**
  19564. * The maximum number of particles to emit per frame
  19565. */
  19566. emitRate: number;
  19567. /**
  19568. * If you want to launch only a few particles at once, that can be done, as well.
  19569. */
  19570. manualEmitCount: number;
  19571. /**
  19572. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19573. */
  19574. updateSpeed: number;
  19575. /**
  19576. * The amount of time the particle system is running (depends of the overall update speed).
  19577. */
  19578. targetStopDuration: number;
  19579. /**
  19580. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19581. */
  19582. disposeOnStop: boolean;
  19583. /**
  19584. * Minimum power of emitting particles.
  19585. */
  19586. minEmitPower: number;
  19587. /**
  19588. * Maximum power of emitting particles.
  19589. */
  19590. maxEmitPower: number;
  19591. /**
  19592. * Minimum life time of emitting particles.
  19593. */
  19594. minLifeTime: number;
  19595. /**
  19596. * Maximum life time of emitting particles.
  19597. */
  19598. maxLifeTime: number;
  19599. /**
  19600. * Minimum Size of emitting particles.
  19601. */
  19602. minSize: number;
  19603. /**
  19604. * Maximum Size of emitting particles.
  19605. */
  19606. maxSize: number;
  19607. /**
  19608. * Minimum scale of emitting particles on X axis.
  19609. */
  19610. minScaleX: number;
  19611. /**
  19612. * Maximum scale of emitting particles on X axis.
  19613. */
  19614. maxScaleX: number;
  19615. /**
  19616. * Minimum scale of emitting particles on Y axis.
  19617. */
  19618. minScaleY: number;
  19619. /**
  19620. * Maximum scale of emitting particles on Y axis.
  19621. */
  19622. maxScaleY: number;
  19623. /**
  19624. * Gets or sets the minimal initial rotation in radians.
  19625. */
  19626. minInitialRotation: number;
  19627. /**
  19628. * Gets or sets the maximal initial rotation in radians.
  19629. */
  19630. maxInitialRotation: number;
  19631. /**
  19632. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19633. */
  19634. minAngularSpeed: number;
  19635. /**
  19636. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19637. */
  19638. maxAngularSpeed: number;
  19639. /**
  19640. * The texture used to render each particle. (this can be a spritesheet)
  19641. */
  19642. particleTexture: Nullable<Texture>;
  19643. /**
  19644. * The layer mask we are rendering the particles through.
  19645. */
  19646. layerMask: number;
  19647. /**
  19648. * This can help using your own shader to render the particle system.
  19649. * The according effect will be created
  19650. */
  19651. customShader: any;
  19652. /**
  19653. * By default particle system starts as soon as they are created. This prevents the
  19654. * automatic start to happen and let you decide when to start emitting particles.
  19655. */
  19656. preventAutoStart: boolean;
  19657. private _noiseTexture;
  19658. /**
  19659. * Gets or sets a texture used to add random noise to particle positions
  19660. */
  19661. noiseTexture: Nullable<ProceduralTexture>;
  19662. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19663. noiseStrength: Vector3;
  19664. /**
  19665. * Callback triggered when the particle animation is ending.
  19666. */
  19667. onAnimationEnd: Nullable<() => void>;
  19668. /**
  19669. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19670. */
  19671. blendMode: number;
  19672. /**
  19673. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19674. * to override the particles.
  19675. */
  19676. forceDepthWrite: boolean;
  19677. /** 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 */
  19678. preWarmCycles: number;
  19679. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19680. preWarmStepOffset: number;
  19681. /**
  19682. * 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)
  19683. */
  19684. spriteCellChangeSpeed: number;
  19685. /**
  19686. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19687. */
  19688. startSpriteCellID: number;
  19689. /**
  19690. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19691. */
  19692. endSpriteCellID: number;
  19693. /**
  19694. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19695. */
  19696. spriteCellWidth: number;
  19697. /**
  19698. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19699. */
  19700. spriteCellHeight: number;
  19701. /**
  19702. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19703. */
  19704. spriteRandomStartCell: boolean;
  19705. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19706. translationPivot: Vector2;
  19707. /** @hidden */
  19708. protected _isAnimationSheetEnabled: boolean;
  19709. /**
  19710. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19711. */
  19712. beginAnimationOnStart: boolean;
  19713. /**
  19714. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19715. */
  19716. beginAnimationFrom: number;
  19717. /**
  19718. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19719. */
  19720. beginAnimationTo: number;
  19721. /**
  19722. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19723. */
  19724. beginAnimationLoop: boolean;
  19725. /**
  19726. * Gets or sets a world offset applied to all particles
  19727. */
  19728. worldOffset: Vector3;
  19729. /**
  19730. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19731. */
  19732. isAnimationSheetEnabled: boolean;
  19733. /**
  19734. * Get hosting scene
  19735. * @returns the scene
  19736. */
  19737. getScene(): Scene;
  19738. /**
  19739. * You can use gravity if you want to give an orientation to your particles.
  19740. */
  19741. gravity: Vector3;
  19742. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19743. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19744. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19745. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19746. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19747. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19748. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19749. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19750. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19751. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19752. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19753. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19754. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19755. /**
  19756. * Defines the delay in milliseconds before starting the system (0 by default)
  19757. */
  19758. startDelay: number;
  19759. /**
  19760. * Gets the current list of drag gradients.
  19761. * You must use addDragGradient and removeDragGradient to udpate this list
  19762. * @returns the list of drag gradients
  19763. */
  19764. getDragGradients(): Nullable<Array<FactorGradient>>;
  19765. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19766. limitVelocityDamping: number;
  19767. /**
  19768. * Gets the current list of limit velocity gradients.
  19769. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19770. * @returns the list of limit velocity gradients
  19771. */
  19772. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19773. /**
  19774. * Gets the current list of color gradients.
  19775. * You must use addColorGradient and removeColorGradient to udpate this list
  19776. * @returns the list of color gradients
  19777. */
  19778. getColorGradients(): Nullable<Array<ColorGradient>>;
  19779. /**
  19780. * Gets the current list of size gradients.
  19781. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19782. * @returns the list of size gradients
  19783. */
  19784. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19785. /**
  19786. * Gets the current list of color remap gradients.
  19787. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19788. * @returns the list of color remap gradients
  19789. */
  19790. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19791. /**
  19792. * Gets the current list of alpha remap gradients.
  19793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19794. * @returns the list of alpha remap gradients
  19795. */
  19796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19797. /**
  19798. * Gets the current list of life time gradients.
  19799. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19800. * @returns the list of life time gradients
  19801. */
  19802. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19803. /**
  19804. * Gets the current list of angular speed gradients.
  19805. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19806. * @returns the list of angular speed gradients
  19807. */
  19808. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19809. /**
  19810. * Gets the current list of velocity gradients.
  19811. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19812. * @returns the list of velocity gradients
  19813. */
  19814. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19815. /**
  19816. * Gets the current list of start size gradients.
  19817. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19818. * @returns the list of start size gradients
  19819. */
  19820. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19821. /**
  19822. * Gets the current list of emit rate gradients.
  19823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19824. * @returns the list of emit rate gradients
  19825. */
  19826. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19827. /**
  19828. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19829. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19830. */
  19831. direction1: Vector3;
  19832. /**
  19833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19834. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19835. */
  19836. direction2: Vector3;
  19837. /**
  19838. * 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.
  19839. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19840. */
  19841. minEmitBox: Vector3;
  19842. /**
  19843. * 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.
  19844. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19845. */
  19846. maxEmitBox: Vector3;
  19847. /**
  19848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19849. */
  19850. color1: Color4;
  19851. /**
  19852. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19853. */
  19854. color2: Color4;
  19855. /**
  19856. * Color the particle will have at the end of its lifetime
  19857. */
  19858. colorDead: Color4;
  19859. /**
  19860. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19861. */
  19862. textureMask: Color4;
  19863. /**
  19864. * The particle emitter type defines the emitter used by the particle system.
  19865. * It can be for example box, sphere, or cone...
  19866. */
  19867. particleEmitterType: IParticleEmitterType;
  19868. /** @hidden */
  19869. _isSubEmitter: boolean;
  19870. /**
  19871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19873. */
  19874. billboardMode: number;
  19875. protected _isBillboardBased: boolean;
  19876. /**
  19877. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19878. */
  19879. isBillboardBased: boolean;
  19880. /**
  19881. * The scene the particle system belongs to.
  19882. */
  19883. protected _scene: Scene;
  19884. /**
  19885. * Local cache of defines for image processing.
  19886. */
  19887. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19888. /**
  19889. * Default configuration related to image processing available in the standard Material.
  19890. */
  19891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19892. /**
  19893. * Gets the image processing configuration used either in this material.
  19894. */
  19895. /**
  19896. * Sets the Default image processing configuration used either in the this material.
  19897. *
  19898. * If sets to null, the scene one is in use.
  19899. */
  19900. imageProcessingConfiguration: ImageProcessingConfiguration;
  19901. /**
  19902. * Attaches a new image processing configuration to the Standard Material.
  19903. * @param configuration
  19904. */
  19905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19906. /** @hidden */
  19907. protected _reset(): void;
  19908. /** @hidden */
  19909. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19910. /**
  19911. * Instantiates a particle system.
  19912. * 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.
  19913. * @param name The name of the particle system
  19914. */
  19915. constructor(name: string);
  19916. /**
  19917. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19918. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19919. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19920. * @returns the emitter
  19921. */
  19922. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19923. /**
  19924. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19925. * @param radius The radius of the hemisphere to emit from
  19926. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19927. * @returns the emitter
  19928. */
  19929. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19930. /**
  19931. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19932. * @param radius The radius of the sphere to emit from
  19933. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19934. * @returns the emitter
  19935. */
  19936. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19937. /**
  19938. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19939. * @param radius The radius of the sphere to emit from
  19940. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19941. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19942. * @returns the emitter
  19943. */
  19944. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19945. /**
  19946. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19947. * @param radius The radius of the emission cylinder
  19948. * @param height The height of the emission cylinder
  19949. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19950. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19951. * @returns the emitter
  19952. */
  19953. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19954. /**
  19955. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19956. * @param radius The radius of the cylinder to emit from
  19957. * @param height The height of the emission cylinder
  19958. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19961. * @returns the emitter
  19962. */
  19963. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19964. /**
  19965. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19966. * @param radius The radius of the cone to emit from
  19967. * @param angle The base angle of the cone
  19968. * @returns the emitter
  19969. */
  19970. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19971. /**
  19972. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19975. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19976. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19977. * @returns the emitter
  19978. */
  19979. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19980. }
  19981. }
  19982. declare module "babylonjs/Particles/subEmitter" {
  19983. import { Scene } from "babylonjs/scene";
  19984. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19985. /**
  19986. * Type of sub emitter
  19987. */
  19988. export enum SubEmitterType {
  19989. /**
  19990. * Attached to the particle over it's lifetime
  19991. */
  19992. ATTACHED = 0,
  19993. /**
  19994. * Created when the particle dies
  19995. */
  19996. END = 1
  19997. }
  19998. /**
  19999. * Sub emitter class used to emit particles from an existing particle
  20000. */
  20001. export class SubEmitter {
  20002. /**
  20003. * the particle system to be used by the sub emitter
  20004. */
  20005. particleSystem: ParticleSystem;
  20006. /**
  20007. * Type of the submitter (Default: END)
  20008. */
  20009. type: SubEmitterType;
  20010. /**
  20011. * 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)
  20012. * Note: This only is supported when using an emitter of type Mesh
  20013. */
  20014. inheritDirection: boolean;
  20015. /**
  20016. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20017. */
  20018. inheritedVelocityAmount: number;
  20019. /**
  20020. * Creates a sub emitter
  20021. * @param particleSystem the particle system to be used by the sub emitter
  20022. */
  20023. constructor(
  20024. /**
  20025. * the particle system to be used by the sub emitter
  20026. */
  20027. particleSystem: ParticleSystem);
  20028. /**
  20029. * Clones the sub emitter
  20030. * @returns the cloned sub emitter
  20031. */
  20032. clone(): SubEmitter;
  20033. /**
  20034. * Serialize current object to a JSON object
  20035. * @returns the serialized object
  20036. */
  20037. serialize(): any;
  20038. /** @hidden */
  20039. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20040. /**
  20041. * Creates a new SubEmitter from a serialized JSON version
  20042. * @param serializationObject defines the JSON object to read from
  20043. * @param scene defines the hosting scene
  20044. * @param rootUrl defines the rootUrl for data loading
  20045. * @returns a new SubEmitter
  20046. */
  20047. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20048. /** Release associated resources */
  20049. dispose(): void;
  20050. }
  20051. }
  20052. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20053. /** @hidden */
  20054. export var imageProcessingDeclaration: {
  20055. name: string;
  20056. shader: string;
  20057. };
  20058. }
  20059. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20060. /** @hidden */
  20061. export var imageProcessingFunctions: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module "babylonjs/Shaders/particles.fragment" {
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20070. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20072. /** @hidden */
  20073. export var particlesPixelShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Shaders/particles.vertex" {
  20079. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20080. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20081. /** @hidden */
  20082. export var particlesVertexShader: {
  20083. name: string;
  20084. shader: string;
  20085. };
  20086. }
  20087. declare module "babylonjs/Particles/particleSystem" {
  20088. import { Nullable } from "babylonjs/types";
  20089. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20090. import { Observable } from "babylonjs/Misc/observable";
  20091. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20092. import { Effect } from "babylonjs/Materials/effect";
  20093. import { Scene, IDisposable } from "babylonjs/scene";
  20094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20095. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20096. import { Particle } from "babylonjs/Particles/particle";
  20097. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20098. import "babylonjs/Shaders/particles.fragment";
  20099. import "babylonjs/Shaders/particles.vertex";
  20100. /**
  20101. * This represents a particle system in Babylon.
  20102. * 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.
  20103. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20104. * @example https://doc.babylonjs.com/babylon101/particles
  20105. */
  20106. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20107. /**
  20108. * Billboard mode will only apply to Y axis
  20109. */
  20110. static readonly BILLBOARDMODE_Y: number;
  20111. /**
  20112. * Billboard mode will apply to all axes
  20113. */
  20114. static readonly BILLBOARDMODE_ALL: number;
  20115. /**
  20116. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20117. */
  20118. static readonly BILLBOARDMODE_STRETCHED: number;
  20119. /**
  20120. * This function can be defined to provide custom update for active particles.
  20121. * This function will be called instead of regular update (age, position, color, etc.).
  20122. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20123. */
  20124. updateFunction: (particles: Particle[]) => void;
  20125. private _emitterWorldMatrix;
  20126. /**
  20127. * This function can be defined to specify initial direction for every new particle.
  20128. * It by default use the emitterType defined function
  20129. */
  20130. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20131. /**
  20132. * This function can be defined to specify initial position for every new particle.
  20133. * It by default use the emitterType defined function
  20134. */
  20135. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20136. /**
  20137. * @hidden
  20138. */
  20139. _inheritedVelocityOffset: Vector3;
  20140. /**
  20141. * An event triggered when the system is disposed
  20142. */
  20143. onDisposeObservable: Observable<ParticleSystem>;
  20144. private _onDisposeObserver;
  20145. /**
  20146. * Sets a callback that will be triggered when the system is disposed
  20147. */
  20148. onDispose: () => void;
  20149. private _particles;
  20150. private _epsilon;
  20151. private _capacity;
  20152. private _stockParticles;
  20153. private _newPartsExcess;
  20154. private _vertexData;
  20155. private _vertexBuffer;
  20156. private _vertexBuffers;
  20157. private _spriteBuffer;
  20158. private _indexBuffer;
  20159. private _effect;
  20160. private _customEffect;
  20161. private _cachedDefines;
  20162. private _scaledColorStep;
  20163. private _colorDiff;
  20164. private _scaledDirection;
  20165. private _scaledGravity;
  20166. private _currentRenderId;
  20167. private _alive;
  20168. private _useInstancing;
  20169. private _started;
  20170. private _stopped;
  20171. private _actualFrame;
  20172. private _scaledUpdateSpeed;
  20173. private _vertexBufferSize;
  20174. /** @hidden */
  20175. _currentEmitRateGradient: Nullable<FactorGradient>;
  20176. /** @hidden */
  20177. _currentEmitRate1: number;
  20178. /** @hidden */
  20179. _currentEmitRate2: number;
  20180. /** @hidden */
  20181. _currentStartSizeGradient: Nullable<FactorGradient>;
  20182. /** @hidden */
  20183. _currentStartSize1: number;
  20184. /** @hidden */
  20185. _currentStartSize2: number;
  20186. private readonly _rawTextureWidth;
  20187. private _rampGradientsTexture;
  20188. private _useRampGradients;
  20189. /** Gets or sets a boolean indicating that ramp gradients must be used
  20190. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20191. */
  20192. useRampGradients: boolean;
  20193. /**
  20194. * 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.
  20195. * 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: [])
  20196. */
  20197. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20198. private _subEmitters;
  20199. /**
  20200. * @hidden
  20201. * If the particle systems emitter should be disposed when the particle system is disposed
  20202. */
  20203. _disposeEmitterOnDispose: boolean;
  20204. /**
  20205. * The current active Sub-systems, this property is used by the root particle system only.
  20206. */
  20207. activeSubSystems: Array<ParticleSystem>;
  20208. private _rootParticleSystem;
  20209. /**
  20210. * Gets the current list of active particles
  20211. */
  20212. readonly particles: Particle[];
  20213. /**
  20214. * Returns the string "ParticleSystem"
  20215. * @returns a string containing the class name
  20216. */
  20217. getClassName(): string;
  20218. /**
  20219. * Instantiates a particle system.
  20220. * 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.
  20221. * @param name The name of the particle system
  20222. * @param capacity The max number of particles alive at the same time
  20223. * @param scene The scene the particle system belongs to
  20224. * @param customEffect a custom effect used to change the way particles are rendered by default
  20225. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20226. * @param epsilon Offset used to render the particles
  20227. */
  20228. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20229. private _addFactorGradient;
  20230. private _removeFactorGradient;
  20231. /**
  20232. * Adds a new life time gradient
  20233. * @param gradient defines the gradient to use (between 0 and 1)
  20234. * @param factor defines the life time factor to affect to the specified gradient
  20235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20236. * @returns the current particle system
  20237. */
  20238. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20239. /**
  20240. * Remove a specific life time gradient
  20241. * @param gradient defines the gradient to remove
  20242. * @returns the current particle system
  20243. */
  20244. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20245. /**
  20246. * Adds a new size gradient
  20247. * @param gradient defines the gradient to use (between 0 and 1)
  20248. * @param factor defines the size factor to affect to the specified gradient
  20249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20250. * @returns the current particle system
  20251. */
  20252. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20253. /**
  20254. * Remove a specific size gradient
  20255. * @param gradient defines the gradient to remove
  20256. * @returns the current particle system
  20257. */
  20258. removeSizeGradient(gradient: number): IParticleSystem;
  20259. /**
  20260. * Adds a new color remap gradient
  20261. * @param gradient defines the gradient to use (between 0 and 1)
  20262. * @param min defines the color remap minimal range
  20263. * @param max defines the color remap maximal range
  20264. * @returns the current particle system
  20265. */
  20266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20267. /**
  20268. * Remove a specific color remap gradient
  20269. * @param gradient defines the gradient to remove
  20270. * @returns the current particle system
  20271. */
  20272. removeColorRemapGradient(gradient: number): IParticleSystem;
  20273. /**
  20274. * Adds a new alpha remap gradient
  20275. * @param gradient defines the gradient to use (between 0 and 1)
  20276. * @param min defines the alpha remap minimal range
  20277. * @param max defines the alpha remap maximal range
  20278. * @returns the current particle system
  20279. */
  20280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20281. /**
  20282. * Remove a specific alpha remap gradient
  20283. * @param gradient defines the gradient to remove
  20284. * @returns the current particle system
  20285. */
  20286. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20287. /**
  20288. * Adds a new angular speed gradient
  20289. * @param gradient defines the gradient to use (between 0 and 1)
  20290. * @param factor defines the angular speed to affect to the specified gradient
  20291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20292. * @returns the current particle system
  20293. */
  20294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20295. /**
  20296. * Remove a specific angular speed gradient
  20297. * @param gradient defines the gradient to remove
  20298. * @returns the current particle system
  20299. */
  20300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20301. /**
  20302. * Adds a new velocity gradient
  20303. * @param gradient defines the gradient to use (between 0 and 1)
  20304. * @param factor defines the velocity to affect to the specified gradient
  20305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20306. * @returns the current particle system
  20307. */
  20308. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20309. /**
  20310. * Remove a specific velocity gradient
  20311. * @param gradient defines the gradient to remove
  20312. * @returns the current particle system
  20313. */
  20314. removeVelocityGradient(gradient: number): IParticleSystem;
  20315. /**
  20316. * Adds a new limit velocity gradient
  20317. * @param gradient defines the gradient to use (between 0 and 1)
  20318. * @param factor defines the limit velocity value to affect to the specified gradient
  20319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20320. * @returns the current particle system
  20321. */
  20322. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20323. /**
  20324. * Remove a specific limit velocity gradient
  20325. * @param gradient defines the gradient to remove
  20326. * @returns the current particle system
  20327. */
  20328. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20329. /**
  20330. * Adds a new drag gradient
  20331. * @param gradient defines the gradient to use (between 0 and 1)
  20332. * @param factor defines the drag value to affect to the specified gradient
  20333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20334. * @returns the current particle system
  20335. */
  20336. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20337. /**
  20338. * Remove a specific drag gradient
  20339. * @param gradient defines the gradient to remove
  20340. * @returns the current particle system
  20341. */
  20342. removeDragGradient(gradient: number): IParticleSystem;
  20343. /**
  20344. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20345. * @param gradient defines the gradient to use (between 0 and 1)
  20346. * @param factor defines the emit rate value to affect to the specified gradient
  20347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20348. * @returns the current particle system
  20349. */
  20350. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20351. /**
  20352. * Remove a specific emit rate gradient
  20353. * @param gradient defines the gradient to remove
  20354. * @returns the current particle system
  20355. */
  20356. removeEmitRateGradient(gradient: number): IParticleSystem;
  20357. /**
  20358. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20359. * @param gradient defines the gradient to use (between 0 and 1)
  20360. * @param factor defines the start size value to affect to the specified gradient
  20361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20362. * @returns the current particle system
  20363. */
  20364. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20365. /**
  20366. * Remove a specific start size gradient
  20367. * @param gradient defines the gradient to remove
  20368. * @returns the current particle system
  20369. */
  20370. removeStartSizeGradient(gradient: number): IParticleSystem;
  20371. private _createRampGradientTexture;
  20372. /**
  20373. * Gets the current list of ramp gradients.
  20374. * You must use addRampGradient and removeRampGradient to udpate this list
  20375. * @returns the list of ramp gradients
  20376. */
  20377. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20378. /**
  20379. * Adds a new ramp gradient used to remap particle colors
  20380. * @param gradient defines the gradient to use (between 0 and 1)
  20381. * @param color defines the color to affect to the specified gradient
  20382. * @returns the current particle system
  20383. */
  20384. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20385. /**
  20386. * Remove a specific ramp gradient
  20387. * @param gradient defines the gradient to remove
  20388. * @returns the current particle system
  20389. */
  20390. removeRampGradient(gradient: number): ParticleSystem;
  20391. /**
  20392. * Adds a new color gradient
  20393. * @param gradient defines the gradient to use (between 0 and 1)
  20394. * @param color1 defines the color to affect to the specified gradient
  20395. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20396. * @returns this particle system
  20397. */
  20398. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20399. /**
  20400. * Remove a specific color gradient
  20401. * @param gradient defines the gradient to remove
  20402. * @returns this particle system
  20403. */
  20404. removeColorGradient(gradient: number): IParticleSystem;
  20405. private _fetchR;
  20406. protected _reset(): void;
  20407. private _resetEffect;
  20408. private _createVertexBuffers;
  20409. private _createIndexBuffer;
  20410. /**
  20411. * Gets the maximum number of particles active at the same time.
  20412. * @returns The max number of active particles.
  20413. */
  20414. getCapacity(): number;
  20415. /**
  20416. * Gets whether there are still active particles in the system.
  20417. * @returns True if it is alive, otherwise false.
  20418. */
  20419. isAlive(): boolean;
  20420. /**
  20421. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20422. * @returns True if it has been started, otherwise false.
  20423. */
  20424. isStarted(): boolean;
  20425. private _prepareSubEmitterInternalArray;
  20426. /**
  20427. * Starts the particle system and begins to emit
  20428. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20429. */
  20430. start(delay?: number): void;
  20431. /**
  20432. * Stops the particle system.
  20433. * @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.
  20434. */
  20435. stop(stopSubEmitters?: boolean): void;
  20436. /**
  20437. * Remove all active particles
  20438. */
  20439. reset(): void;
  20440. /**
  20441. * @hidden (for internal use only)
  20442. */
  20443. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20444. /**
  20445. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20446. * Its lifetime will start back at 0.
  20447. */
  20448. recycleParticle: (particle: Particle) => void;
  20449. private _stopSubEmitters;
  20450. private _createParticle;
  20451. private _removeFromRoot;
  20452. private _emitFromParticle;
  20453. private _update;
  20454. /** @hidden */
  20455. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20456. /** @hidden */
  20457. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20458. /** @hidden */
  20459. private _getEffect;
  20460. /**
  20461. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20462. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20463. */
  20464. animate(preWarmOnly?: boolean): void;
  20465. private _appendParticleVertices;
  20466. /**
  20467. * Rebuilds the particle system.
  20468. */
  20469. rebuild(): void;
  20470. /**
  20471. * Is this system ready to be used/rendered
  20472. * @return true if the system is ready
  20473. */
  20474. isReady(): boolean;
  20475. private _render;
  20476. /**
  20477. * Renders the particle system in its current state.
  20478. * @returns the current number of particles
  20479. */
  20480. render(): number;
  20481. /**
  20482. * Disposes the particle system and free the associated resources
  20483. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20484. */
  20485. dispose(disposeTexture?: boolean): void;
  20486. /**
  20487. * Clones the particle system.
  20488. * @param name The name of the cloned object
  20489. * @param newEmitter The new emitter to use
  20490. * @returns the cloned particle system
  20491. */
  20492. clone(name: string, newEmitter: any): ParticleSystem;
  20493. /**
  20494. * Serializes the particle system to a JSON object.
  20495. * @returns the JSON object
  20496. */
  20497. serialize(): any;
  20498. /** @hidden */
  20499. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20500. /** @hidden */
  20501. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20502. /**
  20503. * Parses a JSON object to create a particle system.
  20504. * @param parsedParticleSystem The JSON object to parse
  20505. * @param scene The scene to create the particle system in
  20506. * @param rootUrl The root url to use to load external dependencies like texture
  20507. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20508. * @returns the Parsed particle system
  20509. */
  20510. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20511. }
  20512. }
  20513. declare module "babylonjs/Particles/particle" {
  20514. import { Nullable } from "babylonjs/types";
  20515. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20516. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20517. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20518. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20519. /**
  20520. * A particle represents one of the element emitted by a particle system.
  20521. * This is mainly define by its coordinates, direction, velocity and age.
  20522. */
  20523. export class Particle {
  20524. /**
  20525. * The particle system the particle belongs to.
  20526. */
  20527. particleSystem: ParticleSystem;
  20528. private static _Count;
  20529. /**
  20530. * Unique ID of the particle
  20531. */
  20532. id: number;
  20533. /**
  20534. * The world position of the particle in the scene.
  20535. */
  20536. position: Vector3;
  20537. /**
  20538. * The world direction of the particle in the scene.
  20539. */
  20540. direction: Vector3;
  20541. /**
  20542. * The color of the particle.
  20543. */
  20544. color: Color4;
  20545. /**
  20546. * The color change of the particle per step.
  20547. */
  20548. colorStep: Color4;
  20549. /**
  20550. * Defines how long will the life of the particle be.
  20551. */
  20552. lifeTime: number;
  20553. /**
  20554. * The current age of the particle.
  20555. */
  20556. age: number;
  20557. /**
  20558. * The current size of the particle.
  20559. */
  20560. size: number;
  20561. /**
  20562. * The current scale of the particle.
  20563. */
  20564. scale: Vector2;
  20565. /**
  20566. * The current angle of the particle.
  20567. */
  20568. angle: number;
  20569. /**
  20570. * Defines how fast is the angle changing.
  20571. */
  20572. angularSpeed: number;
  20573. /**
  20574. * Defines the cell index used by the particle to be rendered from a sprite.
  20575. */
  20576. cellIndex: number;
  20577. /**
  20578. * The information required to support color remapping
  20579. */
  20580. remapData: Vector4;
  20581. /** @hidden */
  20582. _randomCellOffset?: number;
  20583. /** @hidden */
  20584. _initialDirection: Nullable<Vector3>;
  20585. /** @hidden */
  20586. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20587. /** @hidden */
  20588. _initialStartSpriteCellID: number;
  20589. /** @hidden */
  20590. _initialEndSpriteCellID: number;
  20591. /** @hidden */
  20592. _currentColorGradient: Nullable<ColorGradient>;
  20593. /** @hidden */
  20594. _currentColor1: Color4;
  20595. /** @hidden */
  20596. _currentColor2: Color4;
  20597. /** @hidden */
  20598. _currentSizeGradient: Nullable<FactorGradient>;
  20599. /** @hidden */
  20600. _currentSize1: number;
  20601. /** @hidden */
  20602. _currentSize2: number;
  20603. /** @hidden */
  20604. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20605. /** @hidden */
  20606. _currentAngularSpeed1: number;
  20607. /** @hidden */
  20608. _currentAngularSpeed2: number;
  20609. /** @hidden */
  20610. _currentVelocityGradient: Nullable<FactorGradient>;
  20611. /** @hidden */
  20612. _currentVelocity1: number;
  20613. /** @hidden */
  20614. _currentVelocity2: number;
  20615. /** @hidden */
  20616. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20617. /** @hidden */
  20618. _currentLimitVelocity1: number;
  20619. /** @hidden */
  20620. _currentLimitVelocity2: number;
  20621. /** @hidden */
  20622. _currentDragGradient: Nullable<FactorGradient>;
  20623. /** @hidden */
  20624. _currentDrag1: number;
  20625. /** @hidden */
  20626. _currentDrag2: number;
  20627. /** @hidden */
  20628. _randomNoiseCoordinates1: Vector3;
  20629. /** @hidden */
  20630. _randomNoiseCoordinates2: Vector3;
  20631. /**
  20632. * Creates a new instance Particle
  20633. * @param particleSystem the particle system the particle belongs to
  20634. */
  20635. constructor(
  20636. /**
  20637. * The particle system the particle belongs to.
  20638. */
  20639. particleSystem: ParticleSystem);
  20640. private updateCellInfoFromSystem;
  20641. /**
  20642. * Defines how the sprite cell index is updated for the particle
  20643. */
  20644. updateCellIndex(): void;
  20645. /** @hidden */
  20646. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20647. /** @hidden */
  20648. _inheritParticleInfoToSubEmitters(): void;
  20649. /** @hidden */
  20650. _reset(): void;
  20651. /**
  20652. * Copy the properties of particle to another one.
  20653. * @param other the particle to copy the information to.
  20654. */
  20655. copyTo(other: Particle): void;
  20656. }
  20657. }
  20658. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20659. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20660. import { Effect } from "babylonjs/Materials/effect";
  20661. import { Particle } from "babylonjs/Particles/particle";
  20662. /**
  20663. * Particle emitter represents a volume emitting particles.
  20664. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20665. */
  20666. export interface IParticleEmitterType {
  20667. /**
  20668. * Called by the particle System when the direction is computed for the created particle.
  20669. * @param worldMatrix is the world matrix of the particle system
  20670. * @param directionToUpdate is the direction vector to update with the result
  20671. * @param particle is the particle we are computed the direction for
  20672. */
  20673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20674. /**
  20675. * Called by the particle System when the position is computed for the created particle.
  20676. * @param worldMatrix is the world matrix of the particle system
  20677. * @param positionToUpdate is the position vector to update with the result
  20678. * @param particle is the particle we are computed the position for
  20679. */
  20680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20681. /**
  20682. * Clones the current emitter and returns a copy of it
  20683. * @returns the new emitter
  20684. */
  20685. clone(): IParticleEmitterType;
  20686. /**
  20687. * Called by the GPUParticleSystem to setup the update shader
  20688. * @param effect defines the update shader
  20689. */
  20690. applyToShader(effect: Effect): void;
  20691. /**
  20692. * Returns a string to use to update the GPU particles update shader
  20693. * @returns the effect defines string
  20694. */
  20695. getEffectDefines(): string;
  20696. /**
  20697. * Returns a string representing the class name
  20698. * @returns a string containing the class name
  20699. */
  20700. getClassName(): string;
  20701. /**
  20702. * Serializes the particle system to a JSON object.
  20703. * @returns the JSON object
  20704. */
  20705. serialize(): any;
  20706. /**
  20707. * Parse properties from a JSON object
  20708. * @param serializationObject defines the JSON object
  20709. */
  20710. parse(serializationObject: any): void;
  20711. }
  20712. }
  20713. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20714. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20715. import { Effect } from "babylonjs/Materials/effect";
  20716. import { Particle } from "babylonjs/Particles/particle";
  20717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20718. /**
  20719. * Particle emitter emitting particles from the inside of a box.
  20720. * It emits the particles randomly between 2 given directions.
  20721. */
  20722. export class BoxParticleEmitter implements IParticleEmitterType {
  20723. /**
  20724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20725. */
  20726. direction1: Vector3;
  20727. /**
  20728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20729. */
  20730. direction2: Vector3;
  20731. /**
  20732. * 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.
  20733. */
  20734. minEmitBox: Vector3;
  20735. /**
  20736. * 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.
  20737. */
  20738. maxEmitBox: Vector3;
  20739. /**
  20740. * Creates a new instance BoxParticleEmitter
  20741. */
  20742. constructor();
  20743. /**
  20744. * Called by the particle System when the direction is computed for the created particle.
  20745. * @param worldMatrix is the world matrix of the particle system
  20746. * @param directionToUpdate is the direction vector to update with the result
  20747. * @param particle is the particle we are computed the direction for
  20748. */
  20749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20750. /**
  20751. * Called by the particle System when the position is computed for the created particle.
  20752. * @param worldMatrix is the world matrix of the particle system
  20753. * @param positionToUpdate is the position vector to update with the result
  20754. * @param particle is the particle we are computed the position for
  20755. */
  20756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20757. /**
  20758. * Clones the current emitter and returns a copy of it
  20759. * @returns the new emitter
  20760. */
  20761. clone(): BoxParticleEmitter;
  20762. /**
  20763. * Called by the GPUParticleSystem to setup the update shader
  20764. * @param effect defines the update shader
  20765. */
  20766. applyToShader(effect: Effect): void;
  20767. /**
  20768. * Returns a string to use to update the GPU particles update shader
  20769. * @returns a string containng the defines string
  20770. */
  20771. getEffectDefines(): string;
  20772. /**
  20773. * Returns the string "BoxParticleEmitter"
  20774. * @returns a string containing the class name
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Serializes the particle system to a JSON object.
  20779. * @returns the JSON object
  20780. */
  20781. serialize(): any;
  20782. /**
  20783. * Parse properties from a JSON object
  20784. * @param serializationObject defines the JSON object
  20785. */
  20786. parse(serializationObject: any): void;
  20787. }
  20788. }
  20789. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20790. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20791. import { Effect } from "babylonjs/Materials/effect";
  20792. import { Particle } from "babylonjs/Particles/particle";
  20793. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20794. /**
  20795. * Particle emitter emitting particles from the inside of a cone.
  20796. * It emits the particles alongside the cone volume from the base to the particle.
  20797. * The emission direction might be randomized.
  20798. */
  20799. export class ConeParticleEmitter implements IParticleEmitterType {
  20800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20801. directionRandomizer: number;
  20802. private _radius;
  20803. private _angle;
  20804. private _height;
  20805. /**
  20806. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20807. */
  20808. radiusRange: number;
  20809. /**
  20810. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20811. */
  20812. heightRange: number;
  20813. /**
  20814. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20815. */
  20816. emitFromSpawnPointOnly: boolean;
  20817. /**
  20818. * Gets or sets the radius of the emission cone
  20819. */
  20820. radius: number;
  20821. /**
  20822. * Gets or sets the angle of the emission cone
  20823. */
  20824. angle: number;
  20825. private _buildHeight;
  20826. /**
  20827. * Creates a new instance ConeParticleEmitter
  20828. * @param radius the radius of the emission cone (1 by default)
  20829. * @param angle the cone base angle (PI by default)
  20830. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20831. */
  20832. constructor(radius?: number, angle?: number,
  20833. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20834. directionRandomizer?: number);
  20835. /**
  20836. * Called by the particle System when the direction is computed for the created particle.
  20837. * @param worldMatrix is the world matrix of the particle system
  20838. * @param directionToUpdate is the direction vector to update with the result
  20839. * @param particle is the particle we are computed the direction for
  20840. */
  20841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20842. /**
  20843. * Called by the particle System when the position is computed for the created particle.
  20844. * @param worldMatrix is the world matrix of the particle system
  20845. * @param positionToUpdate is the position vector to update with the result
  20846. * @param particle is the particle we are computed the position for
  20847. */
  20848. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20849. /**
  20850. * Clones the current emitter and returns a copy of it
  20851. * @returns the new emitter
  20852. */
  20853. clone(): ConeParticleEmitter;
  20854. /**
  20855. * Called by the GPUParticleSystem to setup the update shader
  20856. * @param effect defines the update shader
  20857. */
  20858. applyToShader(effect: Effect): void;
  20859. /**
  20860. * Returns a string to use to update the GPU particles update shader
  20861. * @returns a string containng the defines string
  20862. */
  20863. getEffectDefines(): string;
  20864. /**
  20865. * Returns the string "ConeParticleEmitter"
  20866. * @returns a string containing the class name
  20867. */
  20868. getClassName(): string;
  20869. /**
  20870. * Serializes the particle system to a JSON object.
  20871. * @returns the JSON object
  20872. */
  20873. serialize(): any;
  20874. /**
  20875. * Parse properties from a JSON object
  20876. * @param serializationObject defines the JSON object
  20877. */
  20878. parse(serializationObject: any): void;
  20879. }
  20880. }
  20881. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20882. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20883. import { Effect } from "babylonjs/Materials/effect";
  20884. import { Particle } from "babylonjs/Particles/particle";
  20885. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20886. /**
  20887. * Particle emitter emitting particles from the inside of a cylinder.
  20888. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20889. */
  20890. export class CylinderParticleEmitter implements IParticleEmitterType {
  20891. /**
  20892. * The radius of the emission cylinder.
  20893. */
  20894. radius: number;
  20895. /**
  20896. * The height of the emission cylinder.
  20897. */
  20898. height: number;
  20899. /**
  20900. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20901. */
  20902. radiusRange: number;
  20903. /**
  20904. * How much to randomize the particle direction [0-1].
  20905. */
  20906. directionRandomizer: number;
  20907. /**
  20908. * Creates a new instance CylinderParticleEmitter
  20909. * @param radius the radius of the emission cylinder (1 by default)
  20910. * @param height the height of the emission cylinder (1 by default)
  20911. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20912. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20913. */
  20914. constructor(
  20915. /**
  20916. * The radius of the emission cylinder.
  20917. */
  20918. radius?: number,
  20919. /**
  20920. * The height of the emission cylinder.
  20921. */
  20922. height?: number,
  20923. /**
  20924. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20925. */
  20926. radiusRange?: number,
  20927. /**
  20928. * How much to randomize the particle direction [0-1].
  20929. */
  20930. directionRandomizer?: number);
  20931. /**
  20932. * Called by the particle System when the direction is computed for the created particle.
  20933. * @param worldMatrix is the world matrix of the particle system
  20934. * @param directionToUpdate is the direction vector to update with the result
  20935. * @param particle is the particle we are computed the direction for
  20936. */
  20937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20938. /**
  20939. * Called by the particle System when the position is computed for the created particle.
  20940. * @param worldMatrix is the world matrix of the particle system
  20941. * @param positionToUpdate is the position vector to update with the result
  20942. * @param particle is the particle we are computed the position for
  20943. */
  20944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20945. /**
  20946. * Clones the current emitter and returns a copy of it
  20947. * @returns the new emitter
  20948. */
  20949. clone(): CylinderParticleEmitter;
  20950. /**
  20951. * Called by the GPUParticleSystem to setup the update shader
  20952. * @param effect defines the update shader
  20953. */
  20954. applyToShader(effect: Effect): void;
  20955. /**
  20956. * Returns a string to use to update the GPU particles update shader
  20957. * @returns a string containng the defines string
  20958. */
  20959. getEffectDefines(): string;
  20960. /**
  20961. * Returns the string "CylinderParticleEmitter"
  20962. * @returns a string containing the class name
  20963. */
  20964. getClassName(): string;
  20965. /**
  20966. * Serializes the particle system to a JSON object.
  20967. * @returns the JSON object
  20968. */
  20969. serialize(): any;
  20970. /**
  20971. * Parse properties from a JSON object
  20972. * @param serializationObject defines the JSON object
  20973. */
  20974. parse(serializationObject: any): void;
  20975. }
  20976. /**
  20977. * Particle emitter emitting particles from the inside of a cylinder.
  20978. * It emits the particles randomly between two vectors.
  20979. */
  20980. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  20991. * @param radius the radius of the emission cylinder (1 by default)
  20992. * @param height the height of the emission cylinder (1 by default)
  20993. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20994. * @param direction1 the min limit of the emission direction (up vector by default)
  20995. * @param direction2 the max limit of the emission direction (up vector by default)
  20996. */
  20997. constructor(radius?: number, height?: number, radiusRange?: number,
  20998. /**
  20999. * The min limit of the emission direction.
  21000. */
  21001. direction1?: Vector3,
  21002. /**
  21003. * The max limit of the emission direction.
  21004. */
  21005. direction2?: Vector3);
  21006. /**
  21007. * Called by the particle System when the direction is computed for the created particle.
  21008. * @param worldMatrix is the world matrix of the particle system
  21009. * @param directionToUpdate is the direction vector to update with the result
  21010. * @param particle is the particle we are computed the direction for
  21011. */
  21012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21013. /**
  21014. * Clones the current emitter and returns a copy of it
  21015. * @returns the new emitter
  21016. */
  21017. clone(): CylinderDirectedParticleEmitter;
  21018. /**
  21019. * Called by the GPUParticleSystem to setup the update shader
  21020. * @param effect defines the update shader
  21021. */
  21022. applyToShader(effect: Effect): void;
  21023. /**
  21024. * Returns a string to use to update the GPU particles update shader
  21025. * @returns a string containng the defines string
  21026. */
  21027. getEffectDefines(): string;
  21028. /**
  21029. * Returns the string "CylinderDirectedParticleEmitter"
  21030. * @returns a string containing the class name
  21031. */
  21032. getClassName(): string;
  21033. /**
  21034. * Serializes the particle system to a JSON object.
  21035. * @returns the JSON object
  21036. */
  21037. serialize(): any;
  21038. /**
  21039. * Parse properties from a JSON object
  21040. * @param serializationObject defines the JSON object
  21041. */
  21042. parse(serializationObject: any): void;
  21043. }
  21044. }
  21045. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21046. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21047. import { Effect } from "babylonjs/Materials/effect";
  21048. import { Particle } from "babylonjs/Particles/particle";
  21049. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21050. /**
  21051. * Particle emitter emitting particles from the inside of a hemisphere.
  21052. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21053. */
  21054. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21055. /**
  21056. * The radius of the emission hemisphere.
  21057. */
  21058. radius: number;
  21059. /**
  21060. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21061. */
  21062. radiusRange: number;
  21063. /**
  21064. * How much to randomize the particle direction [0-1].
  21065. */
  21066. directionRandomizer: number;
  21067. /**
  21068. * Creates a new instance HemisphericParticleEmitter
  21069. * @param radius the radius of the emission hemisphere (1 by default)
  21070. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21071. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21072. */
  21073. constructor(
  21074. /**
  21075. * The radius of the emission hemisphere.
  21076. */
  21077. radius?: number,
  21078. /**
  21079. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21080. */
  21081. radiusRange?: number,
  21082. /**
  21083. * How much to randomize the particle direction [0-1].
  21084. */
  21085. directionRandomizer?: number);
  21086. /**
  21087. * Called by the particle System when the direction is computed for the created particle.
  21088. * @param worldMatrix is the world matrix of the particle system
  21089. * @param directionToUpdate is the direction vector to update with the result
  21090. * @param particle is the particle we are computed the direction for
  21091. */
  21092. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21093. /**
  21094. * Called by the particle System when the position is computed for the created particle.
  21095. * @param worldMatrix is the world matrix of the particle system
  21096. * @param positionToUpdate is the position vector to update with the result
  21097. * @param particle is the particle we are computed the position for
  21098. */
  21099. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21100. /**
  21101. * Clones the current emitter and returns a copy of it
  21102. * @returns the new emitter
  21103. */
  21104. clone(): HemisphericParticleEmitter;
  21105. /**
  21106. * Called by the GPUParticleSystem to setup the update shader
  21107. * @param effect defines the update shader
  21108. */
  21109. applyToShader(effect: Effect): void;
  21110. /**
  21111. * Returns a string to use to update the GPU particles update shader
  21112. * @returns a string containng the defines string
  21113. */
  21114. getEffectDefines(): string;
  21115. /**
  21116. * Returns the string "HemisphericParticleEmitter"
  21117. * @returns a string containing the class name
  21118. */
  21119. getClassName(): string;
  21120. /**
  21121. * Serializes the particle system to a JSON object.
  21122. * @returns the JSON object
  21123. */
  21124. serialize(): any;
  21125. /**
  21126. * Parse properties from a JSON object
  21127. * @param serializationObject defines the JSON object
  21128. */
  21129. parse(serializationObject: any): void;
  21130. }
  21131. }
  21132. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21133. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21134. import { Effect } from "babylonjs/Materials/effect";
  21135. import { Particle } from "babylonjs/Particles/particle";
  21136. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21137. /**
  21138. * Particle emitter emitting particles from a point.
  21139. * It emits the particles randomly between 2 given directions.
  21140. */
  21141. export class PointParticleEmitter implements IParticleEmitterType {
  21142. /**
  21143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21144. */
  21145. direction1: Vector3;
  21146. /**
  21147. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21148. */
  21149. direction2: Vector3;
  21150. /**
  21151. * Creates a new instance PointParticleEmitter
  21152. */
  21153. constructor();
  21154. /**
  21155. * Called by the particle System when the direction is computed for the created particle.
  21156. * @param worldMatrix is the world matrix of the particle system
  21157. * @param directionToUpdate is the direction vector to update with the result
  21158. * @param particle is the particle we are computed the direction for
  21159. */
  21160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21161. /**
  21162. * Called by the particle System when the position is computed for the created particle.
  21163. * @param worldMatrix is the world matrix of the particle system
  21164. * @param positionToUpdate is the position vector to update with the result
  21165. * @param particle is the particle we are computed the position for
  21166. */
  21167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21168. /**
  21169. * Clones the current emitter and returns a copy of it
  21170. * @returns the new emitter
  21171. */
  21172. clone(): PointParticleEmitter;
  21173. /**
  21174. * Called by the GPUParticleSystem to setup the update shader
  21175. * @param effect defines the update shader
  21176. */
  21177. applyToShader(effect: Effect): void;
  21178. /**
  21179. * Returns a string to use to update the GPU particles update shader
  21180. * @returns a string containng the defines string
  21181. */
  21182. getEffectDefines(): string;
  21183. /**
  21184. * Returns the string "PointParticleEmitter"
  21185. * @returns a string containing the class name
  21186. */
  21187. getClassName(): string;
  21188. /**
  21189. * Serializes the particle system to a JSON object.
  21190. * @returns the JSON object
  21191. */
  21192. serialize(): any;
  21193. /**
  21194. * Parse properties from a JSON object
  21195. * @param serializationObject defines the JSON object
  21196. */
  21197. parse(serializationObject: any): void;
  21198. }
  21199. }
  21200. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21201. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21202. import { Effect } from "babylonjs/Materials/effect";
  21203. import { Particle } from "babylonjs/Particles/particle";
  21204. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21205. /**
  21206. * Particle emitter emitting particles from the inside of a sphere.
  21207. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21208. */
  21209. export class SphereParticleEmitter implements IParticleEmitterType {
  21210. /**
  21211. * The radius of the emission sphere.
  21212. */
  21213. radius: number;
  21214. /**
  21215. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21216. */
  21217. radiusRange: number;
  21218. /**
  21219. * How much to randomize the particle direction [0-1].
  21220. */
  21221. directionRandomizer: number;
  21222. /**
  21223. * Creates a new instance SphereParticleEmitter
  21224. * @param radius the radius of the emission sphere (1 by default)
  21225. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21226. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21227. */
  21228. constructor(
  21229. /**
  21230. * The radius of the emission sphere.
  21231. */
  21232. radius?: number,
  21233. /**
  21234. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21235. */
  21236. radiusRange?: number,
  21237. /**
  21238. * How much to randomize the particle direction [0-1].
  21239. */
  21240. directionRandomizer?: number);
  21241. /**
  21242. * Called by the particle System when the direction is computed for the created particle.
  21243. * @param worldMatrix is the world matrix of the particle system
  21244. * @param directionToUpdate is the direction vector to update with the result
  21245. * @param particle is the particle we are computed the direction for
  21246. */
  21247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21248. /**
  21249. * Called by the particle System when the position is computed for the created particle.
  21250. * @param worldMatrix is the world matrix of the particle system
  21251. * @param positionToUpdate is the position vector to update with the result
  21252. * @param particle is the particle we are computed the position for
  21253. */
  21254. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21255. /**
  21256. * Clones the current emitter and returns a copy of it
  21257. * @returns the new emitter
  21258. */
  21259. clone(): SphereParticleEmitter;
  21260. /**
  21261. * Called by the GPUParticleSystem to setup the update shader
  21262. * @param effect defines the update shader
  21263. */
  21264. applyToShader(effect: Effect): void;
  21265. /**
  21266. * Returns a string to use to update the GPU particles update shader
  21267. * @returns a string containng the defines string
  21268. */
  21269. getEffectDefines(): string;
  21270. /**
  21271. * Returns the string "SphereParticleEmitter"
  21272. * @returns a string containing the class name
  21273. */
  21274. getClassName(): string;
  21275. /**
  21276. * Serializes the particle system to a JSON object.
  21277. * @returns the JSON object
  21278. */
  21279. serialize(): any;
  21280. /**
  21281. * Parse properties from a JSON object
  21282. * @param serializationObject defines the JSON object
  21283. */
  21284. parse(serializationObject: any): void;
  21285. }
  21286. /**
  21287. * Particle emitter emitting particles from the inside of a sphere.
  21288. * It emits the particles randomly between two vectors.
  21289. */
  21290. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21291. /**
  21292. * The min limit of the emission direction.
  21293. */
  21294. direction1: Vector3;
  21295. /**
  21296. * The max limit of the emission direction.
  21297. */
  21298. direction2: Vector3;
  21299. /**
  21300. * Creates a new instance SphereDirectedParticleEmitter
  21301. * @param radius the radius of the emission sphere (1 by default)
  21302. * @param direction1 the min limit of the emission direction (up vector by default)
  21303. * @param direction2 the max limit of the emission direction (up vector by default)
  21304. */
  21305. constructor(radius?: number,
  21306. /**
  21307. * The min limit of the emission direction.
  21308. */
  21309. direction1?: Vector3,
  21310. /**
  21311. * The max limit of the emission direction.
  21312. */
  21313. direction2?: Vector3);
  21314. /**
  21315. * Called by the particle System when the direction is computed for the created particle.
  21316. * @param worldMatrix is the world matrix of the particle system
  21317. * @param directionToUpdate is the direction vector to update with the result
  21318. * @param particle is the particle we are computed the direction for
  21319. */
  21320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21321. /**
  21322. * Clones the current emitter and returns a copy of it
  21323. * @returns the new emitter
  21324. */
  21325. clone(): SphereDirectedParticleEmitter;
  21326. /**
  21327. * Called by the GPUParticleSystem to setup the update shader
  21328. * @param effect defines the update shader
  21329. */
  21330. applyToShader(effect: Effect): void;
  21331. /**
  21332. * Returns a string to use to update the GPU particles update shader
  21333. * @returns a string containng the defines string
  21334. */
  21335. getEffectDefines(): string;
  21336. /**
  21337. * Returns the string "SphereDirectedParticleEmitter"
  21338. * @returns a string containing the class name
  21339. */
  21340. getClassName(): string;
  21341. /**
  21342. * Serializes the particle system to a JSON object.
  21343. * @returns the JSON object
  21344. */
  21345. serialize(): any;
  21346. /**
  21347. * Parse properties from a JSON object
  21348. * @param serializationObject defines the JSON object
  21349. */
  21350. parse(serializationObject: any): void;
  21351. }
  21352. }
  21353. declare module "babylonjs/Particles/EmitterTypes/index" {
  21354. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21355. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21356. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21357. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21358. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21359. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21360. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21361. }
  21362. declare module "babylonjs/Particles/IParticleSystem" {
  21363. import { Nullable } from "babylonjs/types";
  21364. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21367. import { Texture } from "babylonjs/Materials/Textures/texture";
  21368. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21369. import { Scene } from "babylonjs/scene";
  21370. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21371. import { Animation } from "babylonjs/Animations/animation";
  21372. /**
  21373. * Interface representing a particle system in Babylon.js.
  21374. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21375. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21376. */
  21377. export interface IParticleSystem {
  21378. /**
  21379. * List of animations used by the particle system.
  21380. */
  21381. animations: Animation[];
  21382. /**
  21383. * The id of the Particle system.
  21384. */
  21385. id: string;
  21386. /**
  21387. * The name of the Particle system.
  21388. */
  21389. name: string;
  21390. /**
  21391. * The emitter represents the Mesh or position we are attaching the particle system to.
  21392. */
  21393. emitter: Nullable<AbstractMesh | Vector3>;
  21394. /**
  21395. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21396. */
  21397. isBillboardBased: boolean;
  21398. /**
  21399. * The rendering group used by the Particle system to chose when to render.
  21400. */
  21401. renderingGroupId: number;
  21402. /**
  21403. * The layer mask we are rendering the particles through.
  21404. */
  21405. layerMask: number;
  21406. /**
  21407. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21408. */
  21409. updateSpeed: number;
  21410. /**
  21411. * The amount of time the particle system is running (depends of the overall update speed).
  21412. */
  21413. targetStopDuration: number;
  21414. /**
  21415. * The texture used to render each particle. (this can be a spritesheet)
  21416. */
  21417. particleTexture: Nullable<Texture>;
  21418. /**
  21419. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21420. */
  21421. blendMode: number;
  21422. /**
  21423. * Minimum life time of emitting particles.
  21424. */
  21425. minLifeTime: number;
  21426. /**
  21427. * Maximum life time of emitting particles.
  21428. */
  21429. maxLifeTime: number;
  21430. /**
  21431. * Minimum Size of emitting particles.
  21432. */
  21433. minSize: number;
  21434. /**
  21435. * Maximum Size of emitting particles.
  21436. */
  21437. maxSize: number;
  21438. /**
  21439. * Minimum scale of emitting particles on X axis.
  21440. */
  21441. minScaleX: number;
  21442. /**
  21443. * Maximum scale of emitting particles on X axis.
  21444. */
  21445. maxScaleX: number;
  21446. /**
  21447. * Minimum scale of emitting particles on Y axis.
  21448. */
  21449. minScaleY: number;
  21450. /**
  21451. * Maximum scale of emitting particles on Y axis.
  21452. */
  21453. maxScaleY: number;
  21454. /**
  21455. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21456. */
  21457. color1: Color4;
  21458. /**
  21459. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21460. */
  21461. color2: Color4;
  21462. /**
  21463. * Color the particle will have at the end of its lifetime.
  21464. */
  21465. colorDead: Color4;
  21466. /**
  21467. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21468. */
  21469. emitRate: number;
  21470. /**
  21471. * You can use gravity if you want to give an orientation to your particles.
  21472. */
  21473. gravity: Vector3;
  21474. /**
  21475. * Minimum power of emitting particles.
  21476. */
  21477. minEmitPower: number;
  21478. /**
  21479. * Maximum power of emitting particles.
  21480. */
  21481. maxEmitPower: number;
  21482. /**
  21483. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21484. */
  21485. minAngularSpeed: number;
  21486. /**
  21487. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21488. */
  21489. maxAngularSpeed: number;
  21490. /**
  21491. * Gets or sets the minimal initial rotation in radians.
  21492. */
  21493. minInitialRotation: number;
  21494. /**
  21495. * Gets or sets the maximal initial rotation in radians.
  21496. */
  21497. maxInitialRotation: number;
  21498. /**
  21499. * The particle emitter type defines the emitter used by the particle system.
  21500. * It can be for example box, sphere, or cone...
  21501. */
  21502. particleEmitterType: Nullable<IParticleEmitterType>;
  21503. /**
  21504. * Defines the delay in milliseconds before starting the system (0 by default)
  21505. */
  21506. startDelay: number;
  21507. /**
  21508. * 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
  21509. */
  21510. preWarmCycles: number;
  21511. /**
  21512. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21513. */
  21514. preWarmStepOffset: number;
  21515. /**
  21516. * 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)
  21517. */
  21518. spriteCellChangeSpeed: number;
  21519. /**
  21520. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21521. */
  21522. startSpriteCellID: number;
  21523. /**
  21524. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21525. */
  21526. endSpriteCellID: number;
  21527. /**
  21528. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21529. */
  21530. spriteCellWidth: number;
  21531. /**
  21532. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21533. */
  21534. spriteCellHeight: number;
  21535. /**
  21536. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21537. */
  21538. spriteRandomStartCell: boolean;
  21539. /**
  21540. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21541. */
  21542. isAnimationSheetEnabled: boolean;
  21543. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21544. translationPivot: Vector2;
  21545. /**
  21546. * Gets or sets a texture used to add random noise to particle positions
  21547. */
  21548. noiseTexture: Nullable<BaseTexture>;
  21549. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21550. noiseStrength: Vector3;
  21551. /**
  21552. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21553. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21554. */
  21555. billboardMode: number;
  21556. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21557. limitVelocityDamping: number;
  21558. /**
  21559. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21560. */
  21561. beginAnimationOnStart: boolean;
  21562. /**
  21563. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21564. */
  21565. beginAnimationFrom: number;
  21566. /**
  21567. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21568. */
  21569. beginAnimationTo: number;
  21570. /**
  21571. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21572. */
  21573. beginAnimationLoop: boolean;
  21574. /**
  21575. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21576. */
  21577. disposeOnStop: boolean;
  21578. /**
  21579. * Gets the maximum number of particles active at the same time.
  21580. * @returns The max number of active particles.
  21581. */
  21582. getCapacity(): number;
  21583. /**
  21584. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21585. * @returns True if it has been started, otherwise false.
  21586. */
  21587. isStarted(): boolean;
  21588. /**
  21589. * Animates the particle system for this frame.
  21590. */
  21591. animate(): void;
  21592. /**
  21593. * Renders the particle system in its current state.
  21594. * @returns the current number of particles
  21595. */
  21596. render(): number;
  21597. /**
  21598. * Dispose the particle system and frees its associated resources.
  21599. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21600. */
  21601. dispose(disposeTexture?: boolean): void;
  21602. /**
  21603. * Clones the particle system.
  21604. * @param name The name of the cloned object
  21605. * @param newEmitter The new emitter to use
  21606. * @returns the cloned particle system
  21607. */
  21608. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21609. /**
  21610. * Serializes the particle system to a JSON object.
  21611. * @returns the JSON object
  21612. */
  21613. serialize(): any;
  21614. /**
  21615. * Rebuild the particle system
  21616. */
  21617. rebuild(): void;
  21618. /**
  21619. * Starts the particle system and begins to emit
  21620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21621. */
  21622. start(delay?: number): void;
  21623. /**
  21624. * Stops the particle system.
  21625. */
  21626. stop(): void;
  21627. /**
  21628. * Remove all active particles
  21629. */
  21630. reset(): void;
  21631. /**
  21632. * Is this system ready to be used/rendered
  21633. * @return true if the system is ready
  21634. */
  21635. isReady(): boolean;
  21636. /**
  21637. * Adds a new color gradient
  21638. * @param gradient defines the gradient to use (between 0 and 1)
  21639. * @param color1 defines the color to affect to the specified gradient
  21640. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21641. * @returns the current particle system
  21642. */
  21643. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21644. /**
  21645. * Remove a specific color gradient
  21646. * @param gradient defines the gradient to remove
  21647. * @returns the current particle system
  21648. */
  21649. removeColorGradient(gradient: number): IParticleSystem;
  21650. /**
  21651. * Adds a new size gradient
  21652. * @param gradient defines the gradient to use (between 0 and 1)
  21653. * @param factor defines the size factor to affect to the specified gradient
  21654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21655. * @returns the current particle system
  21656. */
  21657. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21658. /**
  21659. * Remove a specific size gradient
  21660. * @param gradient defines the gradient to remove
  21661. * @returns the current particle system
  21662. */
  21663. removeSizeGradient(gradient: number): IParticleSystem;
  21664. /**
  21665. * Gets the current list of color gradients.
  21666. * You must use addColorGradient and removeColorGradient to udpate this list
  21667. * @returns the list of color gradients
  21668. */
  21669. getColorGradients(): Nullable<Array<ColorGradient>>;
  21670. /**
  21671. * Gets the current list of size gradients.
  21672. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21673. * @returns the list of size gradients
  21674. */
  21675. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21676. /**
  21677. * Gets the current list of angular speed gradients.
  21678. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21679. * @returns the list of angular speed gradients
  21680. */
  21681. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21682. /**
  21683. * Adds a new angular speed gradient
  21684. * @param gradient defines the gradient to use (between 0 and 1)
  21685. * @param factor defines the angular speed to affect to the specified gradient
  21686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21687. * @returns the current particle system
  21688. */
  21689. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21690. /**
  21691. * Remove a specific angular speed gradient
  21692. * @param gradient defines the gradient to remove
  21693. * @returns the current particle system
  21694. */
  21695. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21696. /**
  21697. * Gets the current list of velocity gradients.
  21698. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21699. * @returns the list of velocity gradients
  21700. */
  21701. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21702. /**
  21703. * Adds a new velocity gradient
  21704. * @param gradient defines the gradient to use (between 0 and 1)
  21705. * @param factor defines the velocity to affect to the specified gradient
  21706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21707. * @returns the current particle system
  21708. */
  21709. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21710. /**
  21711. * Remove a specific velocity gradient
  21712. * @param gradient defines the gradient to remove
  21713. * @returns the current particle system
  21714. */
  21715. removeVelocityGradient(gradient: number): IParticleSystem;
  21716. /**
  21717. * Gets the current list of limit velocity gradients.
  21718. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21719. * @returns the list of limit velocity gradients
  21720. */
  21721. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21722. /**
  21723. * Adds a new limit velocity gradient
  21724. * @param gradient defines the gradient to use (between 0 and 1)
  21725. * @param factor defines the limit velocity to affect to the specified gradient
  21726. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21727. * @returns the current particle system
  21728. */
  21729. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21730. /**
  21731. * Remove a specific limit velocity gradient
  21732. * @param gradient defines the gradient to remove
  21733. * @returns the current particle system
  21734. */
  21735. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21736. /**
  21737. * Adds a new drag gradient
  21738. * @param gradient defines the gradient to use (between 0 and 1)
  21739. * @param factor defines the drag to affect to the specified gradient
  21740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21741. * @returns the current particle system
  21742. */
  21743. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21744. /**
  21745. * Remove a specific drag gradient
  21746. * @param gradient defines the gradient to remove
  21747. * @returns the current particle system
  21748. */
  21749. removeDragGradient(gradient: number): IParticleSystem;
  21750. /**
  21751. * Gets the current list of drag gradients.
  21752. * You must use addDragGradient and removeDragGradient to udpate this list
  21753. * @returns the list of drag gradients
  21754. */
  21755. getDragGradients(): Nullable<Array<FactorGradient>>;
  21756. /**
  21757. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21758. * @param gradient defines the gradient to use (between 0 and 1)
  21759. * @param factor defines the emit rate to affect to the specified gradient
  21760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21761. * @returns the current particle system
  21762. */
  21763. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21764. /**
  21765. * Remove a specific emit rate gradient
  21766. * @param gradient defines the gradient to remove
  21767. * @returns the current particle system
  21768. */
  21769. removeEmitRateGradient(gradient: number): IParticleSystem;
  21770. /**
  21771. * Gets the current list of emit rate gradients.
  21772. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21773. * @returns the list of emit rate gradients
  21774. */
  21775. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21776. /**
  21777. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21778. * @param gradient defines the gradient to use (between 0 and 1)
  21779. * @param factor defines the start size to affect to the specified gradient
  21780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21781. * @returns the current particle system
  21782. */
  21783. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21784. /**
  21785. * Remove a specific start size gradient
  21786. * @param gradient defines the gradient to remove
  21787. * @returns the current particle system
  21788. */
  21789. removeStartSizeGradient(gradient: number): IParticleSystem;
  21790. /**
  21791. * Gets the current list of start size gradients.
  21792. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21793. * @returns the list of start size gradients
  21794. */
  21795. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21796. /**
  21797. * Adds a new life time gradient
  21798. * @param gradient defines the gradient to use (between 0 and 1)
  21799. * @param factor defines the life time factor to affect to the specified gradient
  21800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21801. * @returns the current particle system
  21802. */
  21803. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21804. /**
  21805. * Remove a specific life time gradient
  21806. * @param gradient defines the gradient to remove
  21807. * @returns the current particle system
  21808. */
  21809. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21810. /**
  21811. * Gets the current list of life time gradients.
  21812. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21813. * @returns the list of life time gradients
  21814. */
  21815. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21816. /**
  21817. * Gets the current list of color gradients.
  21818. * You must use addColorGradient and removeColorGradient to udpate this list
  21819. * @returns the list of color gradients
  21820. */
  21821. getColorGradients(): Nullable<Array<ColorGradient>>;
  21822. /**
  21823. * Adds a new ramp gradient used to remap particle colors
  21824. * @param gradient defines the gradient to use (between 0 and 1)
  21825. * @param color defines the color to affect to the specified gradient
  21826. * @returns the current particle system
  21827. */
  21828. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21829. /**
  21830. * Gets the current list of ramp gradients.
  21831. * You must use addRampGradient and removeRampGradient to udpate this list
  21832. * @returns the list of ramp gradients
  21833. */
  21834. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21835. /** Gets or sets a boolean indicating that ramp gradients must be used
  21836. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21837. */
  21838. useRampGradients: boolean;
  21839. /**
  21840. * Adds a new color remap gradient
  21841. * @param gradient defines the gradient to use (between 0 and 1)
  21842. * @param min defines the color remap minimal range
  21843. * @param max defines the color remap maximal range
  21844. * @returns the current particle system
  21845. */
  21846. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21847. /**
  21848. * Gets the current list of color remap gradients.
  21849. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21850. * @returns the list of color remap gradients
  21851. */
  21852. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21853. /**
  21854. * Adds a new alpha remap gradient
  21855. * @param gradient defines the gradient to use (between 0 and 1)
  21856. * @param min defines the alpha remap minimal range
  21857. * @param max defines the alpha remap maximal range
  21858. * @returns the current particle system
  21859. */
  21860. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21861. /**
  21862. * Gets the current list of alpha remap gradients.
  21863. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21864. * @returns the list of alpha remap gradients
  21865. */
  21866. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21867. /**
  21868. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21871. * @returns the emitter
  21872. */
  21873. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21874. /**
  21875. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21876. * @param radius The radius of the hemisphere to emit from
  21877. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21878. * @returns the emitter
  21879. */
  21880. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21881. /**
  21882. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21883. * @param radius The radius of the sphere to emit from
  21884. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21885. * @returns the emitter
  21886. */
  21887. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21888. /**
  21889. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21890. * @param radius The radius of the sphere to emit from
  21891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21893. * @returns the emitter
  21894. */
  21895. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21896. /**
  21897. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21898. * @param radius The radius of the emission cylinder
  21899. * @param height The height of the emission cylinder
  21900. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21901. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21902. * @returns the emitter
  21903. */
  21904. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21905. /**
  21906. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21907. * @param radius The radius of the cylinder to emit from
  21908. * @param height The height of the emission cylinder
  21909. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21912. * @returns the emitter
  21913. */
  21914. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21915. /**
  21916. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21917. * @param radius The radius of the cone to emit from
  21918. * @param angle The base angle of the cone
  21919. * @returns the emitter
  21920. */
  21921. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21922. /**
  21923. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21924. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21925. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21926. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21927. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21928. * @returns the emitter
  21929. */
  21930. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21931. /**
  21932. * Get hosting scene
  21933. * @returns the scene
  21934. */
  21935. getScene(): Scene;
  21936. }
  21937. }
  21938. declare module "babylonjs/Shaders/line.fragment" {
  21939. /** @hidden */
  21940. export var linePixelShader: {
  21941. name: string;
  21942. shader: string;
  21943. };
  21944. }
  21945. declare module "babylonjs/Shaders/line.vertex" {
  21946. /** @hidden */
  21947. export var lineVertexShader: {
  21948. name: string;
  21949. shader: string;
  21950. };
  21951. }
  21952. declare module "babylonjs/Rendering/edgesRenderer" {
  21953. import { Nullable } from "babylonjs/types";
  21954. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21956. import { Vector3 } from "babylonjs/Maths/math";
  21957. import { IDisposable } from "babylonjs/scene";
  21958. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21959. import "babylonjs/Shaders/line.fragment";
  21960. import "babylonjs/Shaders/line.vertex";
  21961. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21962. module "babylonjs/Meshes/abstractMesh" {
  21963. interface AbstractMesh {
  21964. /**
  21965. * Gets the edgesRenderer associated with the mesh
  21966. */
  21967. edgesRenderer: Nullable<EdgesRenderer>;
  21968. }
  21969. }
  21970. module "babylonjs/Meshes/linesMesh" {
  21971. interface LinesMesh {
  21972. /**
  21973. * Enables the edge rendering mode on the mesh.
  21974. * This mode makes the mesh edges visible
  21975. * @param epsilon defines the maximal distance between two angles to detect a face
  21976. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21977. * @returns the currentAbstractMesh
  21978. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21979. */
  21980. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21981. }
  21982. }
  21983. module "babylonjs/Meshes/linesMesh" {
  21984. interface InstancedLinesMesh {
  21985. /**
  21986. * Enables the edge rendering mode on the mesh.
  21987. * This mode makes the mesh edges visible
  21988. * @param epsilon defines the maximal distance between two angles to detect a face
  21989. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21990. * @returns the current InstancedLinesMesh
  21991. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21992. */
  21993. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21994. }
  21995. }
  21996. /**
  21997. * Defines the minimum contract an Edges renderer should follow.
  21998. */
  21999. export interface IEdgesRenderer extends IDisposable {
  22000. /**
  22001. * Gets or sets a boolean indicating if the edgesRenderer is active
  22002. */
  22003. isEnabled: boolean;
  22004. /**
  22005. * Renders the edges of the attached mesh,
  22006. */
  22007. render(): void;
  22008. /**
  22009. * Checks wether or not the edges renderer is ready to render.
  22010. * @return true if ready, otherwise false.
  22011. */
  22012. isReady(): boolean;
  22013. }
  22014. /**
  22015. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  22016. */
  22017. export class EdgesRenderer implements IEdgesRenderer {
  22018. /**
  22019. * Define the size of the edges with an orthographic camera
  22020. */
  22021. edgesWidthScalerForOrthographic: number;
  22022. /**
  22023. * Define the size of the edges with a perspective camera
  22024. */
  22025. edgesWidthScalerForPerspective: number;
  22026. protected _source: AbstractMesh;
  22027. protected _linesPositions: number[];
  22028. protected _linesNormals: number[];
  22029. protected _linesIndices: number[];
  22030. protected _epsilon: number;
  22031. protected _indicesCount: number;
  22032. protected _lineShader: ShaderMaterial;
  22033. protected _ib: DataBuffer;
  22034. protected _buffers: {
  22035. [key: string]: Nullable<VertexBuffer>;
  22036. };
  22037. protected _checkVerticesInsteadOfIndices: boolean;
  22038. private _meshRebuildObserver;
  22039. private _meshDisposeObserver;
  22040. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22041. isEnabled: boolean;
  22042. /**
  22043. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22044. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22045. * @param source Mesh used to create edges
  22046. * @param epsilon sum of angles in adjacency to check for edge
  22047. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22048. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22049. */
  22050. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22051. protected _prepareRessources(): void;
  22052. /** @hidden */
  22053. _rebuild(): void;
  22054. /**
  22055. * Releases the required resources for the edges renderer
  22056. */
  22057. dispose(): void;
  22058. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22059. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22060. /**
  22061. * Checks if the pair of p0 and p1 is en edge
  22062. * @param faceIndex
  22063. * @param edge
  22064. * @param faceNormals
  22065. * @param p0
  22066. * @param p1
  22067. * @private
  22068. */
  22069. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22070. /**
  22071. * push line into the position, normal and index buffer
  22072. * @protected
  22073. */
  22074. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22075. /**
  22076. * Generates lines edges from adjacencjes
  22077. * @private
  22078. */
  22079. _generateEdgesLines(): void;
  22080. /**
  22081. * Checks wether or not the edges renderer is ready to render.
  22082. * @return true if ready, otherwise false.
  22083. */
  22084. isReady(): boolean;
  22085. /**
  22086. * Renders the edges of the attached mesh,
  22087. */
  22088. render(): void;
  22089. }
  22090. /**
  22091. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22092. */
  22093. export class LineEdgesRenderer extends EdgesRenderer {
  22094. /**
  22095. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22096. * @param source LineMesh used to generate edges
  22097. * @param epsilon not important (specified angle for edge detection)
  22098. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22099. */
  22100. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22101. /**
  22102. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22103. */
  22104. _generateEdgesLines(): void;
  22105. }
  22106. }
  22107. declare module "babylonjs/Rendering/renderingGroup" {
  22108. import { SmartArray } from "babylonjs/Misc/smartArray";
  22109. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22111. import { Nullable } from "babylonjs/types";
  22112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22113. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22114. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22115. import { Material } from "babylonjs/Materials/material";
  22116. import { Scene } from "babylonjs/scene";
  22117. /**
  22118. * This represents the object necessary to create a rendering group.
  22119. * This is exclusively used and created by the rendering manager.
  22120. * To modify the behavior, you use the available helpers in your scene or meshes.
  22121. * @hidden
  22122. */
  22123. export class RenderingGroup {
  22124. index: number;
  22125. private static _zeroVector;
  22126. private _scene;
  22127. private _opaqueSubMeshes;
  22128. private _transparentSubMeshes;
  22129. private _alphaTestSubMeshes;
  22130. private _depthOnlySubMeshes;
  22131. private _particleSystems;
  22132. private _spriteManagers;
  22133. private _opaqueSortCompareFn;
  22134. private _alphaTestSortCompareFn;
  22135. private _transparentSortCompareFn;
  22136. private _renderOpaque;
  22137. private _renderAlphaTest;
  22138. private _renderTransparent;
  22139. /** @hidden */
  22140. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22141. onBeforeTransparentRendering: () => void;
  22142. /**
  22143. * Set the opaque sort comparison function.
  22144. * If null the sub meshes will be render in the order they were created
  22145. */
  22146. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22147. /**
  22148. * Set the alpha test sort comparison function.
  22149. * If null the sub meshes will be render in the order they were created
  22150. */
  22151. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22152. /**
  22153. * Set the transparent sort comparison function.
  22154. * If null the sub meshes will be render in the order they were created
  22155. */
  22156. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22157. /**
  22158. * Creates a new rendering group.
  22159. * @param index The rendering group index
  22160. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22161. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22162. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22163. */
  22164. 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>);
  22165. /**
  22166. * Render all the sub meshes contained in the group.
  22167. * @param customRenderFunction Used to override the default render behaviour of the group.
  22168. * @returns true if rendered some submeshes.
  22169. */
  22170. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22171. /**
  22172. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22173. * @param subMeshes The submeshes to render
  22174. */
  22175. private renderOpaqueSorted;
  22176. /**
  22177. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22178. * @param subMeshes The submeshes to render
  22179. */
  22180. private renderAlphaTestSorted;
  22181. /**
  22182. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22183. * @param subMeshes The submeshes to render
  22184. */
  22185. private renderTransparentSorted;
  22186. /**
  22187. * Renders the submeshes in a specified order.
  22188. * @param subMeshes The submeshes to sort before render
  22189. * @param sortCompareFn The comparison function use to sort
  22190. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22191. * @param transparent Specifies to activate blending if true
  22192. */
  22193. private static renderSorted;
  22194. /**
  22195. * Renders the submeshes in the order they were dispatched (no sort applied).
  22196. * @param subMeshes The submeshes to render
  22197. */
  22198. private static renderUnsorted;
  22199. /**
  22200. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22201. * are rendered back to front if in the same alpha index.
  22202. *
  22203. * @param a The first submesh
  22204. * @param b The second submesh
  22205. * @returns The result of the comparison
  22206. */
  22207. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22208. /**
  22209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22210. * are rendered back to front.
  22211. *
  22212. * @param a The first submesh
  22213. * @param b The second submesh
  22214. * @returns The result of the comparison
  22215. */
  22216. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22217. /**
  22218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22219. * are rendered front to back (prevent overdraw).
  22220. *
  22221. * @param a The first submesh
  22222. * @param b The second submesh
  22223. * @returns The result of the comparison
  22224. */
  22225. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22226. /**
  22227. * Resets the different lists of submeshes to prepare a new frame.
  22228. */
  22229. prepare(): void;
  22230. dispose(): void;
  22231. /**
  22232. * Inserts the submesh in its correct queue depending on its material.
  22233. * @param subMesh The submesh to dispatch
  22234. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22235. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22236. */
  22237. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22238. dispatchSprites(spriteManager: ISpriteManager): void;
  22239. dispatchParticles(particleSystem: IParticleSystem): void;
  22240. private _renderParticles;
  22241. private _renderSprites;
  22242. }
  22243. }
  22244. declare module "babylonjs/Rendering/renderingManager" {
  22245. import { Nullable } from "babylonjs/types";
  22246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22248. import { SmartArray } from "babylonjs/Misc/smartArray";
  22249. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22251. import { Material } from "babylonjs/Materials/material";
  22252. import { Scene } from "babylonjs/scene";
  22253. import { Camera } from "babylonjs/Cameras/camera";
  22254. /**
  22255. * Interface describing the different options available in the rendering manager
  22256. * regarding Auto Clear between groups.
  22257. */
  22258. export interface IRenderingManagerAutoClearSetup {
  22259. /**
  22260. * Defines whether or not autoclear is enable.
  22261. */
  22262. autoClear: boolean;
  22263. /**
  22264. * Defines whether or not to autoclear the depth buffer.
  22265. */
  22266. depth: boolean;
  22267. /**
  22268. * Defines whether or not to autoclear the stencil buffer.
  22269. */
  22270. stencil: boolean;
  22271. }
  22272. /**
  22273. * This class is used by the onRenderingGroupObservable
  22274. */
  22275. export class RenderingGroupInfo {
  22276. /**
  22277. * The Scene that being rendered
  22278. */
  22279. scene: Scene;
  22280. /**
  22281. * The camera currently used for the rendering pass
  22282. */
  22283. camera: Nullable<Camera>;
  22284. /**
  22285. * The ID of the renderingGroup being processed
  22286. */
  22287. renderingGroupId: number;
  22288. }
  22289. /**
  22290. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22291. * It is enable to manage the different groups as well as the different necessary sort functions.
  22292. * This should not be used directly aside of the few static configurations
  22293. */
  22294. export class RenderingManager {
  22295. /**
  22296. * The max id used for rendering groups (not included)
  22297. */
  22298. static MAX_RENDERINGGROUPS: number;
  22299. /**
  22300. * The min id used for rendering groups (included)
  22301. */
  22302. static MIN_RENDERINGGROUPS: number;
  22303. /**
  22304. * Used to globally prevent autoclearing scenes.
  22305. */
  22306. static AUTOCLEAR: boolean;
  22307. /**
  22308. * @hidden
  22309. */
  22310. _useSceneAutoClearSetup: boolean;
  22311. private _scene;
  22312. private _renderingGroups;
  22313. private _depthStencilBufferAlreadyCleaned;
  22314. private _autoClearDepthStencil;
  22315. private _customOpaqueSortCompareFn;
  22316. private _customAlphaTestSortCompareFn;
  22317. private _customTransparentSortCompareFn;
  22318. private _renderingGroupInfo;
  22319. /**
  22320. * Instantiates a new rendering group for a particular scene
  22321. * @param scene Defines the scene the groups belongs to
  22322. */
  22323. constructor(scene: Scene);
  22324. private _clearDepthStencilBuffer;
  22325. /**
  22326. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22327. * @hidden
  22328. */
  22329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22330. /**
  22331. * Resets the different information of the group to prepare a new frame
  22332. * @hidden
  22333. */
  22334. reset(): void;
  22335. /**
  22336. * Dispose and release the group and its associated resources.
  22337. * @hidden
  22338. */
  22339. dispose(): void;
  22340. /**
  22341. * Clear the info related to rendering groups preventing retention points during dispose.
  22342. */
  22343. freeRenderingGroups(): void;
  22344. private _prepareRenderingGroup;
  22345. /**
  22346. * Add a sprite manager to the rendering manager in order to render it this frame.
  22347. * @param spriteManager Define the sprite manager to render
  22348. */
  22349. dispatchSprites(spriteManager: ISpriteManager): void;
  22350. /**
  22351. * Add a particle system to the rendering manager in order to render it this frame.
  22352. * @param particleSystem Define the particle system to render
  22353. */
  22354. dispatchParticles(particleSystem: IParticleSystem): void;
  22355. /**
  22356. * Add a submesh to the manager in order to render it this frame
  22357. * @param subMesh The submesh to dispatch
  22358. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22359. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22360. */
  22361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22362. /**
  22363. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22364. * This allowed control for front to back rendering or reversly depending of the special needs.
  22365. *
  22366. * @param renderingGroupId The rendering group id corresponding to its index
  22367. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22368. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22369. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22370. */
  22371. 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;
  22372. /**
  22373. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22374. *
  22375. * @param renderingGroupId The rendering group id corresponding to its index
  22376. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22377. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22378. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22379. */
  22380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22381. /**
  22382. * Gets the current auto clear configuration for one rendering group of the rendering
  22383. * manager.
  22384. * @param index the rendering group index to get the information for
  22385. * @returns The auto clear setup for the requested rendering group
  22386. */
  22387. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22388. }
  22389. }
  22390. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22391. import { Observable } from "babylonjs/Misc/observable";
  22392. import { SmartArray } from "babylonjs/Misc/smartArray";
  22393. import { Nullable } from "babylonjs/types";
  22394. import { Camera } from "babylonjs/Cameras/camera";
  22395. import { Scene } from "babylonjs/scene";
  22396. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22397. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22401. import { Texture } from "babylonjs/Materials/Textures/texture";
  22402. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22403. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22404. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22405. import { Engine } from "babylonjs/Engines/engine";
  22406. /**
  22407. * This Helps creating a texture that will be created from a camera in your scene.
  22408. * It is basically a dynamic texture that could be used to create special effects for instance.
  22409. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22410. */
  22411. export class RenderTargetTexture extends Texture {
  22412. isCube: boolean;
  22413. /**
  22414. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22415. */
  22416. static readonly REFRESHRATE_RENDER_ONCE: number;
  22417. /**
  22418. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22419. */
  22420. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22421. /**
  22422. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22423. * the central point of your effect and can save a lot of performances.
  22424. */
  22425. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22426. /**
  22427. * Use this predicate to dynamically define the list of mesh you want to render.
  22428. * If set, the renderList property will be overwritten.
  22429. */
  22430. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22431. private _renderList;
  22432. /**
  22433. * Use this list to define the list of mesh you want to render.
  22434. */
  22435. renderList: Nullable<Array<AbstractMesh>>;
  22436. private _hookArray;
  22437. /**
  22438. * Define if particles should be rendered in your texture.
  22439. */
  22440. renderParticles: boolean;
  22441. /**
  22442. * Define if sprites should be rendered in your texture.
  22443. */
  22444. renderSprites: boolean;
  22445. /**
  22446. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22447. */
  22448. coordinatesMode: number;
  22449. /**
  22450. * Define the camera used to render the texture.
  22451. */
  22452. activeCamera: Nullable<Camera>;
  22453. /**
  22454. * Override the render function of the texture with your own one.
  22455. */
  22456. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22457. /**
  22458. * Define if camera post processes should be use while rendering the texture.
  22459. */
  22460. useCameraPostProcesses: boolean;
  22461. /**
  22462. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22463. */
  22464. ignoreCameraViewport: boolean;
  22465. private _postProcessManager;
  22466. private _postProcesses;
  22467. private _resizeObserver;
  22468. /**
  22469. * An event triggered when the texture is unbind.
  22470. */
  22471. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22472. /**
  22473. * An event triggered when the texture is unbind.
  22474. */
  22475. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22476. private _onAfterUnbindObserver;
  22477. /**
  22478. * Set a after unbind callback in the texture.
  22479. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22480. */
  22481. onAfterUnbind: () => void;
  22482. /**
  22483. * An event triggered before rendering the texture
  22484. */
  22485. onBeforeRenderObservable: Observable<number>;
  22486. private _onBeforeRenderObserver;
  22487. /**
  22488. * Set a before render callback in the texture.
  22489. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22490. */
  22491. onBeforeRender: (faceIndex: number) => void;
  22492. /**
  22493. * An event triggered after rendering the texture
  22494. */
  22495. onAfterRenderObservable: Observable<number>;
  22496. private _onAfterRenderObserver;
  22497. /**
  22498. * Set a after render callback in the texture.
  22499. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22500. */
  22501. onAfterRender: (faceIndex: number) => void;
  22502. /**
  22503. * An event triggered after the texture clear
  22504. */
  22505. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22506. private _onClearObserver;
  22507. /**
  22508. * Set a clear callback in the texture.
  22509. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22510. */
  22511. onClear: (Engine: Engine) => void;
  22512. /**
  22513. * Define the clear color of the Render Target if it should be different from the scene.
  22514. */
  22515. clearColor: Color4;
  22516. protected _size: number | {
  22517. width: number;
  22518. height: number;
  22519. };
  22520. protected _initialSizeParameter: number | {
  22521. width: number;
  22522. height: number;
  22523. } | {
  22524. ratio: number;
  22525. };
  22526. protected _sizeRatio: Nullable<number>;
  22527. /** @hidden */
  22528. _generateMipMaps: boolean;
  22529. protected _renderingManager: RenderingManager;
  22530. /** @hidden */
  22531. _waitingRenderList: string[];
  22532. protected _doNotChangeAspectRatio: boolean;
  22533. protected _currentRefreshId: number;
  22534. protected _refreshRate: number;
  22535. protected _textureMatrix: Matrix;
  22536. protected _samples: number;
  22537. protected _renderTargetOptions: RenderTargetCreationOptions;
  22538. /**
  22539. * Gets render target creation options that were used.
  22540. */
  22541. readonly renderTargetOptions: RenderTargetCreationOptions;
  22542. protected _engine: Engine;
  22543. protected _onRatioRescale(): void;
  22544. /**
  22545. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22546. * It must define where the camera used to render the texture is set
  22547. */
  22548. boundingBoxPosition: Vector3;
  22549. private _boundingBoxSize;
  22550. /**
  22551. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22552. * When defined, the cubemap will switch to local mode
  22553. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22554. * @example https://www.babylonjs-playground.com/#RNASML
  22555. */
  22556. boundingBoxSize: Vector3;
  22557. /**
  22558. * In case the RTT has been created with a depth texture, get the associated
  22559. * depth texture.
  22560. * Otherwise, return null.
  22561. */
  22562. depthStencilTexture: Nullable<InternalTexture>;
  22563. /**
  22564. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22565. * or used a shadow, depth texture...
  22566. * @param name The friendly name of the texture
  22567. * @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)
  22568. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22569. * @param generateMipMaps True if mip maps need to be generated after render.
  22570. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22571. * @param type The type of the buffer in the RTT (int, half float, float...)
  22572. * @param isCube True if a cube texture needs to be created
  22573. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22574. * @param generateDepthBuffer True to generate a depth buffer
  22575. * @param generateStencilBuffer True to generate a stencil buffer
  22576. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22577. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22578. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22579. */
  22580. constructor(name: string, size: number | {
  22581. width: number;
  22582. height: number;
  22583. } | {
  22584. ratio: number;
  22585. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22586. /**
  22587. * Creates a depth stencil texture.
  22588. * This is only available in WebGL 2 or with the depth texture extension available.
  22589. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22590. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22591. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22592. */
  22593. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22594. private _processSizeParameter;
  22595. /**
  22596. * Define the number of samples to use in case of MSAA.
  22597. * It defaults to one meaning no MSAA has been enabled.
  22598. */
  22599. samples: number;
  22600. /**
  22601. * Resets the refresh counter of the texture and start bak from scratch.
  22602. * Could be useful to regenerate the texture if it is setup to render only once.
  22603. */
  22604. resetRefreshCounter(): void;
  22605. /**
  22606. * Define the refresh rate of the texture or the rendering frequency.
  22607. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22608. */
  22609. refreshRate: number;
  22610. /**
  22611. * Adds a post process to the render target rendering passes.
  22612. * @param postProcess define the post process to add
  22613. */
  22614. addPostProcess(postProcess: PostProcess): void;
  22615. /**
  22616. * Clear all the post processes attached to the render target
  22617. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22618. */
  22619. clearPostProcesses(dispose?: boolean): void;
  22620. /**
  22621. * Remove one of the post process from the list of attached post processes to the texture
  22622. * @param postProcess define the post process to remove from the list
  22623. */
  22624. removePostProcess(postProcess: PostProcess): void;
  22625. /** @hidden */
  22626. _shouldRender(): boolean;
  22627. /**
  22628. * Gets the actual render size of the texture.
  22629. * @returns the width of the render size
  22630. */
  22631. getRenderSize(): number;
  22632. /**
  22633. * Gets the actual render width of the texture.
  22634. * @returns the width of the render size
  22635. */
  22636. getRenderWidth(): number;
  22637. /**
  22638. * Gets the actual render height of the texture.
  22639. * @returns the height of the render size
  22640. */
  22641. getRenderHeight(): number;
  22642. /**
  22643. * Get if the texture can be rescaled or not.
  22644. */
  22645. readonly canRescale: boolean;
  22646. /**
  22647. * Resize the texture using a ratio.
  22648. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22649. */
  22650. scale(ratio: number): void;
  22651. /**
  22652. * Get the texture reflection matrix used to rotate/transform the reflection.
  22653. * @returns the reflection matrix
  22654. */
  22655. getReflectionTextureMatrix(): Matrix;
  22656. /**
  22657. * Resize the texture to a new desired size.
  22658. * Be carrefull as it will recreate all the data in the new texture.
  22659. * @param size Define the new size. It can be:
  22660. * - a number for squared texture,
  22661. * - an object containing { width: number, height: number }
  22662. * - or an object containing a ratio { ratio: number }
  22663. */
  22664. resize(size: number | {
  22665. width: number;
  22666. height: number;
  22667. } | {
  22668. ratio: number;
  22669. }): void;
  22670. /**
  22671. * Renders all the objects from the render list into the texture.
  22672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22674. */
  22675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22676. private _bestReflectionRenderTargetDimension;
  22677. /**
  22678. * @hidden
  22679. * @param faceIndex face index to bind to if this is a cubetexture
  22680. */
  22681. _bindFrameBuffer(faceIndex?: number): void;
  22682. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22683. private renderToTarget;
  22684. /**
  22685. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22686. * This allowed control for front to back rendering or reversly depending of the special needs.
  22687. *
  22688. * @param renderingGroupId The rendering group id corresponding to its index
  22689. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22690. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22691. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22692. */
  22693. 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;
  22694. /**
  22695. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22696. *
  22697. * @param renderingGroupId The rendering group id corresponding to its index
  22698. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22699. */
  22700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22701. /**
  22702. * Clones the texture.
  22703. * @returns the cloned texture
  22704. */
  22705. clone(): RenderTargetTexture;
  22706. /**
  22707. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22708. * @returns The JSON representation of the texture
  22709. */
  22710. serialize(): any;
  22711. /**
  22712. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22713. */
  22714. disposeFramebufferObjects(): void;
  22715. /**
  22716. * Dispose the texture and release its associated resources.
  22717. */
  22718. dispose(): void;
  22719. /** @hidden */
  22720. _rebuild(): void;
  22721. /**
  22722. * Clear the info related to rendering groups preventing retention point in material dispose.
  22723. */
  22724. freeRenderingGroups(): void;
  22725. /**
  22726. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22727. * @returns the view count
  22728. */
  22729. getViewCount(): number;
  22730. }
  22731. }
  22732. declare module "babylonjs/Materials/material" {
  22733. import { IAnimatable } from "babylonjs/Misc/tools";
  22734. import { SmartArray } from "babylonjs/Misc/smartArray";
  22735. import { Observable } from "babylonjs/Misc/observable";
  22736. import { Nullable } from "babylonjs/types";
  22737. import { Scene } from "babylonjs/scene";
  22738. import { Matrix } from "babylonjs/Maths/math";
  22739. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22741. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22742. import { Effect } from "babylonjs/Materials/effect";
  22743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22745. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22746. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22747. import { Mesh } from "babylonjs/Meshes/mesh";
  22748. import { Animation } from "babylonjs/Animations/animation";
  22749. /**
  22750. * Base class for the main features of a material in Babylon.js
  22751. */
  22752. export class Material implements IAnimatable {
  22753. /**
  22754. * Returns the triangle fill mode
  22755. */
  22756. static readonly TriangleFillMode: number;
  22757. /**
  22758. * Returns the wireframe mode
  22759. */
  22760. static readonly WireFrameFillMode: number;
  22761. /**
  22762. * Returns the point fill mode
  22763. */
  22764. static readonly PointFillMode: number;
  22765. /**
  22766. * Returns the point list draw mode
  22767. */
  22768. static readonly PointListDrawMode: number;
  22769. /**
  22770. * Returns the line list draw mode
  22771. */
  22772. static readonly LineListDrawMode: number;
  22773. /**
  22774. * Returns the line loop draw mode
  22775. */
  22776. static readonly LineLoopDrawMode: number;
  22777. /**
  22778. * Returns the line strip draw mode
  22779. */
  22780. static readonly LineStripDrawMode: number;
  22781. /**
  22782. * Returns the triangle strip draw mode
  22783. */
  22784. static readonly TriangleStripDrawMode: number;
  22785. /**
  22786. * Returns the triangle fan draw mode
  22787. */
  22788. static readonly TriangleFanDrawMode: number;
  22789. /**
  22790. * Stores the clock-wise side orientation
  22791. */
  22792. static readonly ClockWiseSideOrientation: number;
  22793. /**
  22794. * Stores the counter clock-wise side orientation
  22795. */
  22796. static readonly CounterClockWiseSideOrientation: number;
  22797. /**
  22798. * The dirty texture flag value
  22799. */
  22800. static readonly TextureDirtyFlag: number;
  22801. /**
  22802. * The dirty light flag value
  22803. */
  22804. static readonly LightDirtyFlag: number;
  22805. /**
  22806. * The dirty fresnel flag value
  22807. */
  22808. static readonly FresnelDirtyFlag: number;
  22809. /**
  22810. * The dirty attribute flag value
  22811. */
  22812. static readonly AttributesDirtyFlag: number;
  22813. /**
  22814. * The dirty misc flag value
  22815. */
  22816. static readonly MiscDirtyFlag: number;
  22817. /**
  22818. * The all dirty flag value
  22819. */
  22820. static readonly AllDirtyFlag: number;
  22821. /**
  22822. * The ID of the material
  22823. */
  22824. id: string;
  22825. /**
  22826. * Gets or sets the unique id of the material
  22827. */
  22828. uniqueId: number;
  22829. /**
  22830. * The name of the material
  22831. */
  22832. name: string;
  22833. /**
  22834. * Gets or sets user defined metadata
  22835. */
  22836. metadata: any;
  22837. /**
  22838. * For internal use only. Please do not use.
  22839. */
  22840. reservedDataStore: any;
  22841. /**
  22842. * Specifies if the ready state should be checked on each call
  22843. */
  22844. checkReadyOnEveryCall: boolean;
  22845. /**
  22846. * Specifies if the ready state should be checked once
  22847. */
  22848. checkReadyOnlyOnce: boolean;
  22849. /**
  22850. * The state of the material
  22851. */
  22852. state: string;
  22853. /**
  22854. * The alpha value of the material
  22855. */
  22856. protected _alpha: number;
  22857. /**
  22858. * List of inspectable custom properties (used by the Inspector)
  22859. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22860. */
  22861. inspectableCustomProperties: IInspectable[];
  22862. /**
  22863. * Sets the alpha value of the material
  22864. */
  22865. /**
  22866. * Gets the alpha value of the material
  22867. */
  22868. alpha: number;
  22869. /**
  22870. * Specifies if back face culling is enabled
  22871. */
  22872. protected _backFaceCulling: boolean;
  22873. /**
  22874. * Sets the back-face culling state
  22875. */
  22876. /**
  22877. * Gets the back-face culling state
  22878. */
  22879. backFaceCulling: boolean;
  22880. /**
  22881. * Stores the value for side orientation
  22882. */
  22883. sideOrientation: number;
  22884. /**
  22885. * Callback triggered when the material is compiled
  22886. */
  22887. onCompiled: Nullable<(effect: Effect) => void>;
  22888. /**
  22889. * Callback triggered when an error occurs
  22890. */
  22891. onError: Nullable<(effect: Effect, errors: string) => void>;
  22892. /**
  22893. * Callback triggered to get the render target textures
  22894. */
  22895. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22896. /**
  22897. * Gets a boolean indicating that current material needs to register RTT
  22898. */
  22899. readonly hasRenderTargetTextures: boolean;
  22900. /**
  22901. * Specifies if the material should be serialized
  22902. */
  22903. doNotSerialize: boolean;
  22904. /**
  22905. * @hidden
  22906. */
  22907. _storeEffectOnSubMeshes: boolean;
  22908. /**
  22909. * Stores the animations for the material
  22910. */
  22911. animations: Nullable<Array<Animation>>;
  22912. /**
  22913. * An event triggered when the material is disposed
  22914. */
  22915. onDisposeObservable: Observable<Material>;
  22916. /**
  22917. * An observer which watches for dispose events
  22918. */
  22919. private _onDisposeObserver;
  22920. private _onUnBindObservable;
  22921. /**
  22922. * Called during a dispose event
  22923. */
  22924. onDispose: () => void;
  22925. private _onBindObservable;
  22926. /**
  22927. * An event triggered when the material is bound
  22928. */
  22929. readonly onBindObservable: Observable<AbstractMesh>;
  22930. /**
  22931. * An observer which watches for bind events
  22932. */
  22933. private _onBindObserver;
  22934. /**
  22935. * Called during a bind event
  22936. */
  22937. onBind: (Mesh: AbstractMesh) => void;
  22938. /**
  22939. * An event triggered when the material is unbound
  22940. */
  22941. readonly onUnBindObservable: Observable<Material>;
  22942. /**
  22943. * Stores the value of the alpha mode
  22944. */
  22945. private _alphaMode;
  22946. /**
  22947. * Sets the value of the alpha mode.
  22948. *
  22949. * | Value | Type | Description |
  22950. * | --- | --- | --- |
  22951. * | 0 | ALPHA_DISABLE | |
  22952. * | 1 | ALPHA_ADD | |
  22953. * | 2 | ALPHA_COMBINE | |
  22954. * | 3 | ALPHA_SUBTRACT | |
  22955. * | 4 | ALPHA_MULTIPLY | |
  22956. * | 5 | ALPHA_MAXIMIZED | |
  22957. * | 6 | ALPHA_ONEONE | |
  22958. * | 7 | ALPHA_PREMULTIPLIED | |
  22959. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22960. * | 9 | ALPHA_INTERPOLATE | |
  22961. * | 10 | ALPHA_SCREENMODE | |
  22962. *
  22963. */
  22964. /**
  22965. * Gets the value of the alpha mode
  22966. */
  22967. alphaMode: number;
  22968. /**
  22969. * Stores the state of the need depth pre-pass value
  22970. */
  22971. private _needDepthPrePass;
  22972. /**
  22973. * Sets the need depth pre-pass value
  22974. */
  22975. /**
  22976. * Gets the depth pre-pass value
  22977. */
  22978. needDepthPrePass: boolean;
  22979. /**
  22980. * Specifies if depth writing should be disabled
  22981. */
  22982. disableDepthWrite: boolean;
  22983. /**
  22984. * Specifies if depth writing should be forced
  22985. */
  22986. forceDepthWrite: boolean;
  22987. /**
  22988. * Specifies if there should be a separate pass for culling
  22989. */
  22990. separateCullingPass: boolean;
  22991. /**
  22992. * Stores the state specifing if fog should be enabled
  22993. */
  22994. private _fogEnabled;
  22995. /**
  22996. * Sets the state for enabling fog
  22997. */
  22998. /**
  22999. * Gets the value of the fog enabled state
  23000. */
  23001. fogEnabled: boolean;
  23002. /**
  23003. * Stores the size of points
  23004. */
  23005. pointSize: number;
  23006. /**
  23007. * Stores the z offset value
  23008. */
  23009. zOffset: number;
  23010. /**
  23011. * Gets a value specifying if wireframe mode is enabled
  23012. */
  23013. /**
  23014. * Sets the state of wireframe mode
  23015. */
  23016. wireframe: boolean;
  23017. /**
  23018. * Gets the value specifying if point clouds are enabled
  23019. */
  23020. /**
  23021. * Sets the state of point cloud mode
  23022. */
  23023. pointsCloud: boolean;
  23024. /**
  23025. * Gets the material fill mode
  23026. */
  23027. /**
  23028. * Sets the material fill mode
  23029. */
  23030. fillMode: number;
  23031. /**
  23032. * @hidden
  23033. * Stores the effects for the material
  23034. */
  23035. _effect: Nullable<Effect>;
  23036. /**
  23037. * @hidden
  23038. * Specifies if the material was previously ready
  23039. */
  23040. _wasPreviouslyReady: boolean;
  23041. /**
  23042. * Specifies if uniform buffers should be used
  23043. */
  23044. private _useUBO;
  23045. /**
  23046. * Stores a reference to the scene
  23047. */
  23048. private _scene;
  23049. /**
  23050. * Stores the fill mode state
  23051. */
  23052. private _fillMode;
  23053. /**
  23054. * Specifies if the depth write state should be cached
  23055. */
  23056. private _cachedDepthWriteState;
  23057. /**
  23058. * Stores the uniform buffer
  23059. */
  23060. protected _uniformBuffer: UniformBuffer;
  23061. /** @hidden */
  23062. _indexInSceneMaterialArray: number;
  23063. /** @hidden */
  23064. meshMap: Nullable<{
  23065. [id: string]: AbstractMesh | undefined;
  23066. }>;
  23067. /**
  23068. * Creates a material instance
  23069. * @param name defines the name of the material
  23070. * @param scene defines the scene to reference
  23071. * @param doNotAdd specifies if the material should be added to the scene
  23072. */
  23073. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23074. /**
  23075. * Returns a string representation of the current material
  23076. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23077. * @returns a string with material information
  23078. */
  23079. toString(fullDetails?: boolean): string;
  23080. /**
  23081. * Gets the class name of the material
  23082. * @returns a string with the class name of the material
  23083. */
  23084. getClassName(): string;
  23085. /**
  23086. * Specifies if updates for the material been locked
  23087. */
  23088. readonly isFrozen: boolean;
  23089. /**
  23090. * Locks updates for the material
  23091. */
  23092. freeze(): void;
  23093. /**
  23094. * Unlocks updates for the material
  23095. */
  23096. unfreeze(): void;
  23097. /**
  23098. * Specifies if the material is ready to be used
  23099. * @param mesh defines the mesh to check
  23100. * @param useInstances specifies if instances should be used
  23101. * @returns a boolean indicating if the material is ready to be used
  23102. */
  23103. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23104. /**
  23105. * Specifies that the submesh is ready to be used
  23106. * @param mesh defines the mesh to check
  23107. * @param subMesh defines which submesh to check
  23108. * @param useInstances specifies that instances should be used
  23109. * @returns a boolean indicating that the submesh is ready or not
  23110. */
  23111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23112. /**
  23113. * Returns the material effect
  23114. * @returns the effect associated with the material
  23115. */
  23116. getEffect(): Nullable<Effect>;
  23117. /**
  23118. * Returns the current scene
  23119. * @returns a Scene
  23120. */
  23121. getScene(): Scene;
  23122. /**
  23123. * Specifies if the material will require alpha blending
  23124. * @returns a boolean specifying if alpha blending is needed
  23125. */
  23126. needAlphaBlending(): boolean;
  23127. /**
  23128. * Specifies if the mesh will require alpha blending
  23129. * @param mesh defines the mesh to check
  23130. * @returns a boolean specifying if alpha blending is needed for the mesh
  23131. */
  23132. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23133. /**
  23134. * Specifies if this material should be rendered in alpha test mode
  23135. * @returns a boolean specifying if an alpha test is needed.
  23136. */
  23137. needAlphaTesting(): boolean;
  23138. /**
  23139. * Gets the texture used for the alpha test
  23140. * @returns the texture to use for alpha testing
  23141. */
  23142. getAlphaTestTexture(): Nullable<BaseTexture>;
  23143. /**
  23144. * Marks the material to indicate that it needs to be re-calculated
  23145. */
  23146. markDirty(): void;
  23147. /** @hidden */
  23148. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23149. /**
  23150. * Binds the material to the mesh
  23151. * @param world defines the world transformation matrix
  23152. * @param mesh defines the mesh to bind the material to
  23153. */
  23154. bind(world: Matrix, mesh?: Mesh): void;
  23155. /**
  23156. * Binds the submesh to the material
  23157. * @param world defines the world transformation matrix
  23158. * @param mesh defines the mesh containing the submesh
  23159. * @param subMesh defines the submesh to bind the material to
  23160. */
  23161. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23162. /**
  23163. * Binds the world matrix to the material
  23164. * @param world defines the world transformation matrix
  23165. */
  23166. bindOnlyWorldMatrix(world: Matrix): void;
  23167. /**
  23168. * Binds the scene's uniform buffer to the effect.
  23169. * @param effect defines the effect to bind to the scene uniform buffer
  23170. * @param sceneUbo defines the uniform buffer storing scene data
  23171. */
  23172. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23173. /**
  23174. * Binds the view matrix to the effect
  23175. * @param effect defines the effect to bind the view matrix to
  23176. */
  23177. bindView(effect: Effect): void;
  23178. /**
  23179. * Binds the view projection matrix to the effect
  23180. * @param effect defines the effect to bind the view projection matrix to
  23181. */
  23182. bindViewProjection(effect: Effect): void;
  23183. /**
  23184. * Specifies if material alpha testing should be turned on for the mesh
  23185. * @param mesh defines the mesh to check
  23186. */
  23187. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23188. /**
  23189. * Processes to execute after binding the material to a mesh
  23190. * @param mesh defines the rendered mesh
  23191. */
  23192. protected _afterBind(mesh?: Mesh): void;
  23193. /**
  23194. * Unbinds the material from the mesh
  23195. */
  23196. unbind(): void;
  23197. /**
  23198. * Gets the active textures from the material
  23199. * @returns an array of textures
  23200. */
  23201. getActiveTextures(): BaseTexture[];
  23202. /**
  23203. * Specifies if the material uses a texture
  23204. * @param texture defines the texture to check against the material
  23205. * @returns a boolean specifying if the material uses the texture
  23206. */
  23207. hasTexture(texture: BaseTexture): boolean;
  23208. /**
  23209. * Makes a duplicate of the material, and gives it a new name
  23210. * @param name defines the new name for the duplicated material
  23211. * @returns the cloned material
  23212. */
  23213. clone(name: string): Nullable<Material>;
  23214. /**
  23215. * Gets the meshes bound to the material
  23216. * @returns an array of meshes bound to the material
  23217. */
  23218. getBindedMeshes(): AbstractMesh[];
  23219. /**
  23220. * Force shader compilation
  23221. * @param mesh defines the mesh associated with this material
  23222. * @param onCompiled defines a function to execute once the material is compiled
  23223. * @param options defines the options to configure the compilation
  23224. */
  23225. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23226. clipPlane: boolean;
  23227. }>): void;
  23228. /**
  23229. * Force shader compilation
  23230. * @param mesh defines the mesh that will use this material
  23231. * @param options defines additional options for compiling the shaders
  23232. * @returns a promise that resolves when the compilation completes
  23233. */
  23234. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23235. clipPlane: boolean;
  23236. }>): Promise<void>;
  23237. private static readonly _AllDirtyCallBack;
  23238. private static readonly _ImageProcessingDirtyCallBack;
  23239. private static readonly _TextureDirtyCallBack;
  23240. private static readonly _FresnelDirtyCallBack;
  23241. private static readonly _MiscDirtyCallBack;
  23242. private static readonly _LightsDirtyCallBack;
  23243. private static readonly _AttributeDirtyCallBack;
  23244. private static _FresnelAndMiscDirtyCallBack;
  23245. private static _TextureAndMiscDirtyCallBack;
  23246. private static readonly _DirtyCallbackArray;
  23247. private static readonly _RunDirtyCallBacks;
  23248. /**
  23249. * Marks a define in the material to indicate that it needs to be re-computed
  23250. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23251. */
  23252. markAsDirty(flag: number): void;
  23253. /**
  23254. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23255. * @param func defines a function which checks material defines against the submeshes
  23256. */
  23257. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23258. /**
  23259. * Indicates that we need to re-calculated for all submeshes
  23260. */
  23261. protected _markAllSubMeshesAsAllDirty(): void;
  23262. /**
  23263. * Indicates that image processing needs to be re-calculated for all submeshes
  23264. */
  23265. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23266. /**
  23267. * Indicates that textures need to be re-calculated for all submeshes
  23268. */
  23269. protected _markAllSubMeshesAsTexturesDirty(): void;
  23270. /**
  23271. * Indicates that fresnel needs to be re-calculated for all submeshes
  23272. */
  23273. protected _markAllSubMeshesAsFresnelDirty(): void;
  23274. /**
  23275. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23276. */
  23277. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23278. /**
  23279. * Indicates that lights need to be re-calculated for all submeshes
  23280. */
  23281. protected _markAllSubMeshesAsLightsDirty(): void;
  23282. /**
  23283. * Indicates that attributes need to be re-calculated for all submeshes
  23284. */
  23285. protected _markAllSubMeshesAsAttributesDirty(): void;
  23286. /**
  23287. * Indicates that misc needs to be re-calculated for all submeshes
  23288. */
  23289. protected _markAllSubMeshesAsMiscDirty(): void;
  23290. /**
  23291. * Indicates that textures and misc need to be re-calculated for all submeshes
  23292. */
  23293. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23294. /**
  23295. * Disposes the material
  23296. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23297. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23298. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23299. */
  23300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23301. /** @hidden */
  23302. private releaseVertexArrayObject;
  23303. /**
  23304. * Serializes this material
  23305. * @returns the serialized material object
  23306. */
  23307. serialize(): any;
  23308. /**
  23309. * Creates a material from parsed material data
  23310. * @param parsedMaterial defines parsed material data
  23311. * @param scene defines the hosting scene
  23312. * @param rootUrl defines the root URL to use to load textures
  23313. * @returns a new material
  23314. */
  23315. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23316. }
  23317. }
  23318. declare module "babylonjs/Meshes/subMesh" {
  23319. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23320. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23321. import { Engine } from "babylonjs/Engines/engine";
  23322. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23323. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23324. import { Effect } from "babylonjs/Materials/effect";
  23325. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23326. import { Collider } from "babylonjs/Collisions/collider";
  23327. import { Material } from "babylonjs/Materials/material";
  23328. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23330. import { Mesh } from "babylonjs/Meshes/mesh";
  23331. import { Ray } from "babylonjs/Culling/ray";
  23332. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23333. /**
  23334. * Base class for submeshes
  23335. */
  23336. export class BaseSubMesh {
  23337. /** @hidden */
  23338. _materialDefines: Nullable<MaterialDefines>;
  23339. /** @hidden */
  23340. _materialEffect: Nullable<Effect>;
  23341. /**
  23342. * Gets associated effect
  23343. */
  23344. readonly effect: Nullable<Effect>;
  23345. /**
  23346. * Sets associated effect (effect used to render this submesh)
  23347. * @param effect defines the effect to associate with
  23348. * @param defines defines the set of defines used to compile this effect
  23349. */
  23350. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23351. }
  23352. /**
  23353. * Defines a subdivision inside a mesh
  23354. */
  23355. export class SubMesh extends BaseSubMesh implements ICullable {
  23356. /** the material index to use */
  23357. materialIndex: number;
  23358. /** vertex index start */
  23359. verticesStart: number;
  23360. /** vertices count */
  23361. verticesCount: number;
  23362. /** index start */
  23363. indexStart: number;
  23364. /** indices count */
  23365. indexCount: number;
  23366. /** @hidden */
  23367. _linesIndexCount: number;
  23368. private _mesh;
  23369. private _renderingMesh;
  23370. private _boundingInfo;
  23371. private _linesIndexBuffer;
  23372. /** @hidden */
  23373. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23374. /** @hidden */
  23375. _trianglePlanes: Plane[];
  23376. /** @hidden */
  23377. _lastColliderTransformMatrix: Nullable<Matrix>;
  23378. /** @hidden */
  23379. _renderId: number;
  23380. /** @hidden */
  23381. _alphaIndex: number;
  23382. /** @hidden */
  23383. _distanceToCamera: number;
  23384. /** @hidden */
  23385. _id: number;
  23386. private _currentMaterial;
  23387. /**
  23388. * Add a new submesh to a mesh
  23389. * @param materialIndex defines the material index to use
  23390. * @param verticesStart defines vertex index start
  23391. * @param verticesCount defines vertices count
  23392. * @param indexStart defines index start
  23393. * @param indexCount defines indices count
  23394. * @param mesh defines the parent mesh
  23395. * @param renderingMesh defines an optional rendering mesh
  23396. * @param createBoundingBox defines if bounding box should be created for this submesh
  23397. * @returns the new submesh
  23398. */
  23399. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23400. /**
  23401. * Creates a new submesh
  23402. * @param materialIndex defines the material index to use
  23403. * @param verticesStart defines vertex index start
  23404. * @param verticesCount defines vertices count
  23405. * @param indexStart defines index start
  23406. * @param indexCount defines indices count
  23407. * @param mesh defines the parent mesh
  23408. * @param renderingMesh defines an optional rendering mesh
  23409. * @param createBoundingBox defines if bounding box should be created for this submesh
  23410. */
  23411. constructor(
  23412. /** the material index to use */
  23413. materialIndex: number,
  23414. /** vertex index start */
  23415. verticesStart: number,
  23416. /** vertices count */
  23417. verticesCount: number,
  23418. /** index start */
  23419. indexStart: number,
  23420. /** indices count */
  23421. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23422. /**
  23423. * Returns true if this submesh covers the entire parent mesh
  23424. * @ignorenaming
  23425. */
  23426. readonly IsGlobal: boolean;
  23427. /**
  23428. * Returns the submesh BoudingInfo object
  23429. * @returns current bounding info (or mesh's one if the submesh is global)
  23430. */
  23431. getBoundingInfo(): BoundingInfo;
  23432. /**
  23433. * Sets the submesh BoundingInfo
  23434. * @param boundingInfo defines the new bounding info to use
  23435. * @returns the SubMesh
  23436. */
  23437. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23438. /**
  23439. * Returns the mesh of the current submesh
  23440. * @return the parent mesh
  23441. */
  23442. getMesh(): AbstractMesh;
  23443. /**
  23444. * Returns the rendering mesh of the submesh
  23445. * @returns the rendering mesh (could be different from parent mesh)
  23446. */
  23447. getRenderingMesh(): Mesh;
  23448. /**
  23449. * Returns the submesh material
  23450. * @returns null or the current material
  23451. */
  23452. getMaterial(): Nullable<Material>;
  23453. /**
  23454. * Sets a new updated BoundingInfo object to the submesh
  23455. * @param data defines an optional position array to use to determine the bounding info
  23456. * @returns the SubMesh
  23457. */
  23458. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23459. /** @hidden */
  23460. _checkCollision(collider: Collider): boolean;
  23461. /**
  23462. * Updates the submesh BoundingInfo
  23463. * @param world defines the world matrix to use to update the bounding info
  23464. * @returns the submesh
  23465. */
  23466. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23467. /**
  23468. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23469. * @param frustumPlanes defines the frustum planes
  23470. * @returns true if the submesh is intersecting with the frustum
  23471. */
  23472. isInFrustum(frustumPlanes: Plane[]): boolean;
  23473. /**
  23474. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23475. * @param frustumPlanes defines the frustum planes
  23476. * @returns true if the submesh is inside the frustum
  23477. */
  23478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23479. /**
  23480. * Renders the submesh
  23481. * @param enableAlphaMode defines if alpha needs to be used
  23482. * @returns the submesh
  23483. */
  23484. render(enableAlphaMode: boolean): SubMesh;
  23485. /**
  23486. * @hidden
  23487. */
  23488. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23489. /**
  23490. * Checks if the submesh intersects with a ray
  23491. * @param ray defines the ray to test
  23492. * @returns true is the passed ray intersects the submesh bounding box
  23493. */
  23494. canIntersects(ray: Ray): boolean;
  23495. /**
  23496. * Intersects current submesh with a ray
  23497. * @param ray defines the ray to test
  23498. * @param positions defines mesh's positions array
  23499. * @param indices defines mesh's indices array
  23500. * @param fastCheck defines if only bounding info should be used
  23501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23502. * @returns intersection info or null if no intersection
  23503. */
  23504. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23505. /** @hidden */
  23506. private _intersectLines;
  23507. /** @hidden */
  23508. private _intersectUnIndexedLines;
  23509. /** @hidden */
  23510. private _intersectTriangles;
  23511. /** @hidden */
  23512. private _intersectUnIndexedTriangles;
  23513. /** @hidden */
  23514. _rebuild(): void;
  23515. /**
  23516. * Creates a new submesh from the passed mesh
  23517. * @param newMesh defines the new hosting mesh
  23518. * @param newRenderingMesh defines an optional rendering mesh
  23519. * @returns the new submesh
  23520. */
  23521. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23522. /**
  23523. * Release associated resources
  23524. */
  23525. dispose(): void;
  23526. /**
  23527. * Gets the class name
  23528. * @returns the string "SubMesh".
  23529. */
  23530. getClassName(): string;
  23531. /**
  23532. * Creates a new submesh from indices data
  23533. * @param materialIndex the index of the main mesh material
  23534. * @param startIndex the index where to start the copy in the mesh indices array
  23535. * @param indexCount the number of indices to copy then from the startIndex
  23536. * @param mesh the main mesh to create the submesh from
  23537. * @param renderingMesh the optional rendering mesh
  23538. * @returns a new submesh
  23539. */
  23540. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23541. }
  23542. }
  23543. declare module "babylonjs/Meshes/geometry" {
  23544. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23545. import { Scene } from "babylonjs/scene";
  23546. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23547. import { Engine } from "babylonjs/Engines/engine";
  23548. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23549. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23550. import { Effect } from "babylonjs/Materials/effect";
  23551. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23553. import { Mesh } from "babylonjs/Meshes/mesh";
  23554. /**
  23555. * Class used to store geometry data (vertex buffers + index buffer)
  23556. */
  23557. export class Geometry implements IGetSetVerticesData {
  23558. /**
  23559. * Gets or sets the ID of the geometry
  23560. */
  23561. id: string;
  23562. /**
  23563. * Gets or sets the unique ID of the geometry
  23564. */
  23565. uniqueId: number;
  23566. /**
  23567. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23568. */
  23569. delayLoadState: number;
  23570. /**
  23571. * Gets the file containing the data to load when running in delay load state
  23572. */
  23573. delayLoadingFile: Nullable<string>;
  23574. /**
  23575. * Callback called when the geometry is updated
  23576. */
  23577. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23578. private _scene;
  23579. private _engine;
  23580. private _meshes;
  23581. private _totalVertices;
  23582. /** @hidden */
  23583. _indices: IndicesArray;
  23584. /** @hidden */
  23585. _vertexBuffers: {
  23586. [key: string]: VertexBuffer;
  23587. };
  23588. private _isDisposed;
  23589. private _extend;
  23590. private _boundingBias;
  23591. /** @hidden */
  23592. _delayInfo: Array<string>;
  23593. private _indexBuffer;
  23594. private _indexBufferIsUpdatable;
  23595. /** @hidden */
  23596. _boundingInfo: Nullable<BoundingInfo>;
  23597. /** @hidden */
  23598. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23599. /** @hidden */
  23600. _softwareSkinningFrameId: number;
  23601. private _vertexArrayObjects;
  23602. private _updatable;
  23603. /** @hidden */
  23604. _positions: Nullable<Vector3[]>;
  23605. /**
  23606. * 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
  23607. */
  23608. /**
  23609. * 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
  23610. */
  23611. boundingBias: Vector2;
  23612. /**
  23613. * Static function used to attach a new empty geometry to a mesh
  23614. * @param mesh defines the mesh to attach the geometry to
  23615. * @returns the new Geometry
  23616. */
  23617. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23618. /**
  23619. * Creates a new geometry
  23620. * @param id defines the unique ID
  23621. * @param scene defines the hosting scene
  23622. * @param vertexData defines the VertexData used to get geometry data
  23623. * @param updatable defines if geometry must be updatable (false by default)
  23624. * @param mesh defines the mesh that will be associated with the geometry
  23625. */
  23626. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23627. /**
  23628. * Gets the current extend of the geometry
  23629. */
  23630. readonly extend: {
  23631. minimum: Vector3;
  23632. maximum: Vector3;
  23633. };
  23634. /**
  23635. * Gets the hosting scene
  23636. * @returns the hosting Scene
  23637. */
  23638. getScene(): Scene;
  23639. /**
  23640. * Gets the hosting engine
  23641. * @returns the hosting Engine
  23642. */
  23643. getEngine(): Engine;
  23644. /**
  23645. * Defines if the geometry is ready to use
  23646. * @returns true if the geometry is ready to be used
  23647. */
  23648. isReady(): boolean;
  23649. /**
  23650. * Gets a value indicating that the geometry should not be serialized
  23651. */
  23652. readonly doNotSerialize: boolean;
  23653. /** @hidden */
  23654. _rebuild(): void;
  23655. /**
  23656. * Affects all geometry data in one call
  23657. * @param vertexData defines the geometry data
  23658. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23659. */
  23660. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23661. /**
  23662. * Set specific vertex data
  23663. * @param kind defines the data kind (Position, normal, etc...)
  23664. * @param data defines the vertex data to use
  23665. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23666. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23667. */
  23668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23669. /**
  23670. * Removes a specific vertex data
  23671. * @param kind defines the data kind (Position, normal, etc...)
  23672. */
  23673. removeVerticesData(kind: string): void;
  23674. /**
  23675. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23676. * @param buffer defines the vertex buffer to use
  23677. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23678. */
  23679. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23680. /**
  23681. * Update a specific vertex buffer
  23682. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23683. * It will do nothing if the buffer is not updatable
  23684. * @param kind defines the data kind (Position, normal, etc...)
  23685. * @param data defines the data to use
  23686. * @param offset defines the offset in the target buffer where to store the data
  23687. * @param useBytes set to true if the offset is in bytes
  23688. */
  23689. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23690. /**
  23691. * Update a specific vertex buffer
  23692. * This function will create a new buffer if the current one is not updatable
  23693. * @param kind defines the data kind (Position, normal, etc...)
  23694. * @param data defines the data to use
  23695. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23696. */
  23697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23698. private _updateBoundingInfo;
  23699. /** @hidden */
  23700. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23701. /**
  23702. * Gets total number of vertices
  23703. * @returns the total number of vertices
  23704. */
  23705. getTotalVertices(): number;
  23706. /**
  23707. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23708. * @param kind defines the data kind (Position, normal, etc...)
  23709. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23711. * @returns a float array containing vertex data
  23712. */
  23713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23714. /**
  23715. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23716. * @param kind defines the data kind (Position, normal, etc...)
  23717. * @returns true if the vertex buffer with the specified kind is updatable
  23718. */
  23719. isVertexBufferUpdatable(kind: string): boolean;
  23720. /**
  23721. * Gets a specific vertex buffer
  23722. * @param kind defines the data kind (Position, normal, etc...)
  23723. * @returns a VertexBuffer
  23724. */
  23725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23726. /**
  23727. * Returns all vertex buffers
  23728. * @return an object holding all vertex buffers indexed by kind
  23729. */
  23730. getVertexBuffers(): Nullable<{
  23731. [key: string]: VertexBuffer;
  23732. }>;
  23733. /**
  23734. * Gets a boolean indicating if specific vertex buffer is present
  23735. * @param kind defines the data kind (Position, normal, etc...)
  23736. * @returns true if data is present
  23737. */
  23738. isVerticesDataPresent(kind: string): boolean;
  23739. /**
  23740. * Gets a list of all attached data kinds (Position, normal, etc...)
  23741. * @returns a list of string containing all kinds
  23742. */
  23743. getVerticesDataKinds(): string[];
  23744. /**
  23745. * Update index buffer
  23746. * @param indices defines the indices to store in the index buffer
  23747. * @param offset defines the offset in the target buffer where to store the data
  23748. * @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)
  23749. */
  23750. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23751. /**
  23752. * Creates a new index buffer
  23753. * @param indices defines the indices to store in the index buffer
  23754. * @param totalVertices defines the total number of vertices (could be null)
  23755. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23756. */
  23757. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23758. /**
  23759. * Return the total number of indices
  23760. * @returns the total number of indices
  23761. */
  23762. getTotalIndices(): number;
  23763. /**
  23764. * Gets the index buffer array
  23765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23767. * @returns the index buffer array
  23768. */
  23769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23770. /**
  23771. * Gets the index buffer
  23772. * @return the index buffer
  23773. */
  23774. getIndexBuffer(): Nullable<DataBuffer>;
  23775. /** @hidden */
  23776. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23777. /**
  23778. * Release the associated resources for a specific mesh
  23779. * @param mesh defines the source mesh
  23780. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23781. */
  23782. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23783. /**
  23784. * Apply current geometry to a given mesh
  23785. * @param mesh defines the mesh to apply geometry to
  23786. */
  23787. applyToMesh(mesh: Mesh): void;
  23788. private _updateExtend;
  23789. private _applyToMesh;
  23790. private notifyUpdate;
  23791. /**
  23792. * Load the geometry if it was flagged as delay loaded
  23793. * @param scene defines the hosting scene
  23794. * @param onLoaded defines a callback called when the geometry is loaded
  23795. */
  23796. load(scene: Scene, onLoaded?: () => void): void;
  23797. private _queueLoad;
  23798. /**
  23799. * Invert the geometry to move from a right handed system to a left handed one.
  23800. */
  23801. toLeftHanded(): void;
  23802. /** @hidden */
  23803. _resetPointsArrayCache(): void;
  23804. /** @hidden */
  23805. _generatePointsArray(): boolean;
  23806. /**
  23807. * Gets a value indicating if the geometry is disposed
  23808. * @returns true if the geometry was disposed
  23809. */
  23810. isDisposed(): boolean;
  23811. private _disposeVertexArrayObjects;
  23812. /**
  23813. * Free all associated resources
  23814. */
  23815. dispose(): void;
  23816. /**
  23817. * Clone the current geometry into a new geometry
  23818. * @param id defines the unique ID of the new geometry
  23819. * @returns a new geometry object
  23820. */
  23821. copy(id: string): Geometry;
  23822. /**
  23823. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23824. * @return a JSON representation of the current geometry data (without the vertices data)
  23825. */
  23826. serialize(): any;
  23827. private toNumberArray;
  23828. /**
  23829. * Serialize all vertices data into a JSON oject
  23830. * @returns a JSON representation of the current geometry data
  23831. */
  23832. serializeVerticeData(): any;
  23833. /**
  23834. * Extracts a clone of a mesh geometry
  23835. * @param mesh defines the source mesh
  23836. * @param id defines the unique ID of the new geometry object
  23837. * @returns the new geometry object
  23838. */
  23839. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23840. /**
  23841. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23842. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23843. * Be aware Math.random() could cause collisions, but:
  23844. * "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"
  23845. * @returns a string containing a new GUID
  23846. */
  23847. static RandomId(): string;
  23848. /** @hidden */
  23849. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23850. private static _CleanMatricesWeights;
  23851. /**
  23852. * Create a new geometry from persisted data (Using .babylon file format)
  23853. * @param parsedVertexData defines the persisted data
  23854. * @param scene defines the hosting scene
  23855. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23856. * @returns the new geometry object
  23857. */
  23858. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23859. }
  23860. }
  23861. declare module "babylonjs/Meshes/mesh.vertexData" {
  23862. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23863. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23864. import { Geometry } from "babylonjs/Meshes/geometry";
  23865. import { Mesh } from "babylonjs/Meshes/mesh";
  23866. /**
  23867. * Define an interface for all classes that will get and set the data on vertices
  23868. */
  23869. export interface IGetSetVerticesData {
  23870. /**
  23871. * Gets a boolean indicating if specific vertex data is present
  23872. * @param kind defines the vertex data kind to use
  23873. * @returns true is data kind is present
  23874. */
  23875. isVerticesDataPresent(kind: string): boolean;
  23876. /**
  23877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23878. * @param kind defines the data kind (Position, normal, etc...)
  23879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23881. * @returns a float array containing vertex data
  23882. */
  23883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23884. /**
  23885. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23886. * @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.
  23887. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23888. * @returns the indices array or an empty array if the mesh has no geometry
  23889. */
  23890. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23891. /**
  23892. * Set specific vertex data
  23893. * @param kind defines the data kind (Position, normal, etc...)
  23894. * @param data defines the vertex data to use
  23895. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23896. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23897. */
  23898. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23899. /**
  23900. * Update a specific associated vertex buffer
  23901. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23902. * - VertexBuffer.PositionKind
  23903. * - VertexBuffer.UVKind
  23904. * - VertexBuffer.UV2Kind
  23905. * - VertexBuffer.UV3Kind
  23906. * - VertexBuffer.UV4Kind
  23907. * - VertexBuffer.UV5Kind
  23908. * - VertexBuffer.UV6Kind
  23909. * - VertexBuffer.ColorKind
  23910. * - VertexBuffer.MatricesIndicesKind
  23911. * - VertexBuffer.MatricesIndicesExtraKind
  23912. * - VertexBuffer.MatricesWeightsKind
  23913. * - VertexBuffer.MatricesWeightsExtraKind
  23914. * @param data defines the data source
  23915. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23916. * @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)
  23917. */
  23918. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23919. /**
  23920. * Creates a new index buffer
  23921. * @param indices defines the indices to store in the index buffer
  23922. * @param totalVertices defines the total number of vertices (could be null)
  23923. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23924. */
  23925. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23926. }
  23927. /**
  23928. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23929. */
  23930. export class VertexData {
  23931. /**
  23932. * Mesh side orientation : usually the external or front surface
  23933. */
  23934. static readonly FRONTSIDE: number;
  23935. /**
  23936. * Mesh side orientation : usually the internal or back surface
  23937. */
  23938. static readonly BACKSIDE: number;
  23939. /**
  23940. * Mesh side orientation : both internal and external or front and back surfaces
  23941. */
  23942. static readonly DOUBLESIDE: number;
  23943. /**
  23944. * Mesh side orientation : by default, `FRONTSIDE`
  23945. */
  23946. static readonly DEFAULTSIDE: number;
  23947. /**
  23948. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23949. */
  23950. positions: Nullable<FloatArray>;
  23951. /**
  23952. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23953. */
  23954. normals: Nullable<FloatArray>;
  23955. /**
  23956. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23957. */
  23958. tangents: Nullable<FloatArray>;
  23959. /**
  23960. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23961. */
  23962. uvs: Nullable<FloatArray>;
  23963. /**
  23964. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23965. */
  23966. uvs2: Nullable<FloatArray>;
  23967. /**
  23968. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23969. */
  23970. uvs3: Nullable<FloatArray>;
  23971. /**
  23972. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23973. */
  23974. uvs4: Nullable<FloatArray>;
  23975. /**
  23976. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23977. */
  23978. uvs5: Nullable<FloatArray>;
  23979. /**
  23980. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23981. */
  23982. uvs6: Nullable<FloatArray>;
  23983. /**
  23984. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23985. */
  23986. colors: Nullable<FloatArray>;
  23987. /**
  23988. * 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).
  23989. */
  23990. matricesIndices: Nullable<FloatArray>;
  23991. /**
  23992. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23993. */
  23994. matricesWeights: Nullable<FloatArray>;
  23995. /**
  23996. * An array extending the number of possible indices
  23997. */
  23998. matricesIndicesExtra: Nullable<FloatArray>;
  23999. /**
  24000. * An array extending the number of possible weights when the number of indices is extended
  24001. */
  24002. matricesWeightsExtra: Nullable<FloatArray>;
  24003. /**
  24004. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  24005. */
  24006. indices: Nullable<IndicesArray>;
  24007. /**
  24008. * Uses the passed data array to set the set the values for the specified kind of data
  24009. * @param data a linear array of floating numbers
  24010. * @param kind the type of data that is being set, eg positions, colors etc
  24011. */
  24012. set(data: FloatArray, kind: string): void;
  24013. /**
  24014. * Associates the vertexData to the passed Mesh.
  24015. * Sets it as updatable or not (default `false`)
  24016. * @param mesh the mesh the vertexData is applied to
  24017. * @param updatable when used and having the value true allows new data to update the vertexData
  24018. * @returns the VertexData
  24019. */
  24020. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24021. /**
  24022. * Associates the vertexData to the passed Geometry.
  24023. * Sets it as updatable or not (default `false`)
  24024. * @param geometry the geometry the vertexData is applied to
  24025. * @param updatable when used and having the value true allows new data to update the vertexData
  24026. * @returns VertexData
  24027. */
  24028. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24029. /**
  24030. * Updates the associated mesh
  24031. * @param mesh the mesh to be updated
  24032. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24033. * @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
  24034. * @returns VertexData
  24035. */
  24036. updateMesh(mesh: Mesh): VertexData;
  24037. /**
  24038. * Updates the associated geometry
  24039. * @param geometry the geometry to be updated
  24040. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24041. * @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
  24042. * @returns VertexData.
  24043. */
  24044. updateGeometry(geometry: Geometry): VertexData;
  24045. private _applyTo;
  24046. private _update;
  24047. /**
  24048. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24049. * @param matrix the transforming matrix
  24050. * @returns the VertexData
  24051. */
  24052. transform(matrix: Matrix): VertexData;
  24053. /**
  24054. * Merges the passed VertexData into the current one
  24055. * @param other the VertexData to be merged into the current one
  24056. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24057. * @returns the modified VertexData
  24058. */
  24059. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24060. private _mergeElement;
  24061. private _validate;
  24062. /**
  24063. * Serializes the VertexData
  24064. * @returns a serialized object
  24065. */
  24066. serialize(): any;
  24067. /**
  24068. * Extracts the vertexData from a mesh
  24069. * @param mesh the mesh from which to extract the VertexData
  24070. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24071. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24072. * @returns the object VertexData associated to the passed mesh
  24073. */
  24074. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24075. /**
  24076. * Extracts the vertexData from the geometry
  24077. * @param geometry the geometry from which to extract the VertexData
  24078. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24080. * @returns the object VertexData associated to the passed mesh
  24081. */
  24082. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24083. private static _ExtractFrom;
  24084. /**
  24085. * Creates the VertexData for a Ribbon
  24086. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24087. * * pathArray array of paths, each of which an array of successive Vector3
  24088. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24089. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24090. * * 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
  24091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24092. * * 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)
  24093. * * 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)
  24094. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24095. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24096. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24097. * @returns the VertexData of the ribbon
  24098. */
  24099. static CreateRibbon(options: {
  24100. pathArray: Vector3[][];
  24101. closeArray?: boolean;
  24102. closePath?: boolean;
  24103. offset?: number;
  24104. sideOrientation?: number;
  24105. frontUVs?: Vector4;
  24106. backUVs?: Vector4;
  24107. invertUV?: boolean;
  24108. uvs?: Vector2[];
  24109. colors?: Color4[];
  24110. }): VertexData;
  24111. /**
  24112. * Creates the VertexData for a box
  24113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24114. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24115. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24116. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24117. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24118. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24119. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24121. * * 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)
  24122. * * 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)
  24123. * @returns the VertexData of the box
  24124. */
  24125. static CreateBox(options: {
  24126. size?: number;
  24127. width?: number;
  24128. height?: number;
  24129. depth?: number;
  24130. faceUV?: Vector4[];
  24131. faceColors?: Color4[];
  24132. sideOrientation?: number;
  24133. frontUVs?: Vector4;
  24134. backUVs?: Vector4;
  24135. }): VertexData;
  24136. /**
  24137. * Creates the VertexData for a tiled box
  24138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24139. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24140. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24141. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24143. * @returns the VertexData of the box
  24144. */
  24145. static CreateTiledBox(options: {
  24146. pattern?: number;
  24147. width?: number;
  24148. height?: number;
  24149. depth?: number;
  24150. tileSize?: number;
  24151. tileWidth?: number;
  24152. tileHeight?: number;
  24153. alignHorizontal?: number;
  24154. alignVertical?: number;
  24155. faceUV?: Vector4[];
  24156. faceColors?: Color4[];
  24157. sideOrientation?: number;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a tiled plane
  24161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24162. * * pattern a limited pattern arrangement depending on the number
  24163. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24164. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24165. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24167. * * 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)
  24168. * * 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)
  24169. * @returns the VertexData of the tiled plane
  24170. */
  24171. static CreateTiledPlane(options: {
  24172. pattern?: number;
  24173. tileSize?: number;
  24174. tileWidth?: number;
  24175. tileHeight?: number;
  24176. size?: number;
  24177. width?: number;
  24178. height?: number;
  24179. alignHorizontal?: number;
  24180. alignVertical?: number;
  24181. sideOrientation?: number;
  24182. frontUVs?: Vector4;
  24183. backUVs?: Vector4;
  24184. }): VertexData;
  24185. /**
  24186. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24187. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24188. * * segments sets the number of horizontal strips optional, default 32
  24189. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24190. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24191. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24192. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24193. * * 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
  24194. * * 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
  24195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24196. * * 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)
  24197. * * 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)
  24198. * @returns the VertexData of the ellipsoid
  24199. */
  24200. static CreateSphere(options: {
  24201. segments?: number;
  24202. diameter?: number;
  24203. diameterX?: number;
  24204. diameterY?: number;
  24205. diameterZ?: number;
  24206. arc?: number;
  24207. slice?: number;
  24208. sideOrientation?: number;
  24209. frontUVs?: Vector4;
  24210. backUVs?: Vector4;
  24211. }): VertexData;
  24212. /**
  24213. * Creates the VertexData for a cylinder, cone or prism
  24214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24215. * * height sets the height (y direction) of the cylinder, optional, default 2
  24216. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24217. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24218. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24219. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24220. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24221. * * 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
  24222. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24223. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24224. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24225. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24227. * * 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)
  24228. * * 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)
  24229. * @returns the VertexData of the cylinder, cone or prism
  24230. */
  24231. static CreateCylinder(options: {
  24232. height?: number;
  24233. diameterTop?: number;
  24234. diameterBottom?: number;
  24235. diameter?: number;
  24236. tessellation?: number;
  24237. subdivisions?: number;
  24238. arc?: number;
  24239. faceColors?: Color4[];
  24240. faceUV?: Vector4[];
  24241. hasRings?: boolean;
  24242. enclose?: boolean;
  24243. sideOrientation?: number;
  24244. frontUVs?: Vector4;
  24245. backUVs?: Vector4;
  24246. }): VertexData;
  24247. /**
  24248. * Creates the VertexData for a torus
  24249. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24250. * * diameter the diameter of the torus, optional default 1
  24251. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24252. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24254. * * 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)
  24255. * * 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)
  24256. * @returns the VertexData of the torus
  24257. */
  24258. static CreateTorus(options: {
  24259. diameter?: number;
  24260. thickness?: number;
  24261. tessellation?: number;
  24262. sideOrientation?: number;
  24263. frontUVs?: Vector4;
  24264. backUVs?: Vector4;
  24265. }): VertexData;
  24266. /**
  24267. * Creates the VertexData of the LineSystem
  24268. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24269. * - lines an array of lines, each line being an array of successive Vector3
  24270. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24271. * @returns the VertexData of the LineSystem
  24272. */
  24273. static CreateLineSystem(options: {
  24274. lines: Vector3[][];
  24275. colors?: Nullable<Color4[][]>;
  24276. }): VertexData;
  24277. /**
  24278. * Create the VertexData for a DashedLines
  24279. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24280. * - points an array successive Vector3
  24281. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24282. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24283. * - dashNb the intended total number of dashes, optional, default 200
  24284. * @returns the VertexData for the DashedLines
  24285. */
  24286. static CreateDashedLines(options: {
  24287. points: Vector3[];
  24288. dashSize?: number;
  24289. gapSize?: number;
  24290. dashNb?: number;
  24291. }): VertexData;
  24292. /**
  24293. * Creates the VertexData for a Ground
  24294. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24295. * - width the width (x direction) of the ground, optional, default 1
  24296. * - height the height (z direction) of the ground, optional, default 1
  24297. * - subdivisions the number of subdivisions per side, optional, default 1
  24298. * @returns the VertexData of the Ground
  24299. */
  24300. static CreateGround(options: {
  24301. width?: number;
  24302. height?: number;
  24303. subdivisions?: number;
  24304. subdivisionsX?: number;
  24305. subdivisionsY?: number;
  24306. }): VertexData;
  24307. /**
  24308. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24309. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24310. * * xmin the ground minimum X coordinate, optional, default -1
  24311. * * zmin the ground minimum Z coordinate, optional, default -1
  24312. * * xmax the ground maximum X coordinate, optional, default 1
  24313. * * zmax the ground maximum Z coordinate, optional, default 1
  24314. * * 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}
  24315. * * 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}
  24316. * @returns the VertexData of the TiledGround
  24317. */
  24318. static CreateTiledGround(options: {
  24319. xmin: number;
  24320. zmin: number;
  24321. xmax: number;
  24322. zmax: number;
  24323. subdivisions?: {
  24324. w: number;
  24325. h: number;
  24326. };
  24327. precision?: {
  24328. w: number;
  24329. h: number;
  24330. };
  24331. }): VertexData;
  24332. /**
  24333. * Creates the VertexData of the Ground designed from a heightmap
  24334. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24335. * * width the width (x direction) of the ground
  24336. * * height the height (z direction) of the ground
  24337. * * subdivisions the number of subdivisions per side
  24338. * * minHeight the minimum altitude on the ground, optional, default 0
  24339. * * maxHeight the maximum altitude on the ground, optional default 1
  24340. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24341. * * buffer the array holding the image color data
  24342. * * bufferWidth the width of image
  24343. * * bufferHeight the height of image
  24344. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24345. * @returns the VertexData of the Ground designed from a heightmap
  24346. */
  24347. static CreateGroundFromHeightMap(options: {
  24348. width: number;
  24349. height: number;
  24350. subdivisions: number;
  24351. minHeight: number;
  24352. maxHeight: number;
  24353. colorFilter: Color3;
  24354. buffer: Uint8Array;
  24355. bufferWidth: number;
  24356. bufferHeight: number;
  24357. alphaFilter: number;
  24358. }): VertexData;
  24359. /**
  24360. * Creates the VertexData for a Plane
  24361. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24362. * * size sets the width and height of the plane to the value of size, optional default 1
  24363. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24364. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24366. * * 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)
  24367. * * 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)
  24368. * @returns the VertexData of the box
  24369. */
  24370. static CreatePlane(options: {
  24371. size?: number;
  24372. width?: number;
  24373. height?: number;
  24374. sideOrientation?: number;
  24375. frontUVs?: Vector4;
  24376. backUVs?: Vector4;
  24377. }): VertexData;
  24378. /**
  24379. * Creates the VertexData of the Disc or regular Polygon
  24380. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24381. * * radius the radius of the disc, optional default 0.5
  24382. * * tessellation the number of polygon sides, optional, default 64
  24383. * * 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
  24384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24385. * * 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)
  24386. * * 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)
  24387. * @returns the VertexData of the box
  24388. */
  24389. static CreateDisc(options: {
  24390. radius?: number;
  24391. tessellation?: number;
  24392. arc?: number;
  24393. sideOrientation?: number;
  24394. frontUVs?: Vector4;
  24395. backUVs?: Vector4;
  24396. }): VertexData;
  24397. /**
  24398. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24399. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24400. * @param polygon a mesh built from polygonTriangulation.build()
  24401. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24402. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24403. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24404. * @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)
  24405. * @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)
  24406. * @returns the VertexData of the Polygon
  24407. */
  24408. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24409. /**
  24410. * Creates the VertexData of the IcoSphere
  24411. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24412. * * radius the radius of the IcoSphere, optional default 1
  24413. * * radiusX allows stretching in the x direction, optional, default radius
  24414. * * radiusY allows stretching in the y direction, optional, default radius
  24415. * * radiusZ allows stretching in the z direction, optional, default radius
  24416. * * flat when true creates a flat shaded mesh, optional, default true
  24417. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24419. * * 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)
  24420. * * 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)
  24421. * @returns the VertexData of the IcoSphere
  24422. */
  24423. static CreateIcoSphere(options: {
  24424. radius?: number;
  24425. radiusX?: number;
  24426. radiusY?: number;
  24427. radiusZ?: number;
  24428. flat?: boolean;
  24429. subdivisions?: number;
  24430. sideOrientation?: number;
  24431. frontUVs?: Vector4;
  24432. backUVs?: Vector4;
  24433. }): VertexData;
  24434. /**
  24435. * Creates the VertexData for a Polyhedron
  24436. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24437. * * type provided types are:
  24438. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24439. * * 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)
  24440. * * size the size of the IcoSphere, optional default 1
  24441. * * sizeX allows stretching in the x direction, optional, default size
  24442. * * sizeY allows stretching in the y direction, optional, default size
  24443. * * sizeZ allows stretching in the z direction, optional, default size
  24444. * * 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
  24445. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24446. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24447. * * flat when true creates a flat shaded mesh, optional, default true
  24448. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24450. * * 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)
  24451. * * 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)
  24452. * @returns the VertexData of the Polyhedron
  24453. */
  24454. static CreatePolyhedron(options: {
  24455. type?: number;
  24456. size?: number;
  24457. sizeX?: number;
  24458. sizeY?: number;
  24459. sizeZ?: number;
  24460. custom?: any;
  24461. faceUV?: Vector4[];
  24462. faceColors?: Color4[];
  24463. flat?: boolean;
  24464. sideOrientation?: number;
  24465. frontUVs?: Vector4;
  24466. backUVs?: Vector4;
  24467. }): VertexData;
  24468. /**
  24469. * Creates the VertexData for a TorusKnot
  24470. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24471. * * radius the radius of the torus knot, optional, default 2
  24472. * * tube the thickness of the tube, optional, default 0.5
  24473. * * radialSegments the number of sides on each tube segments, optional, default 32
  24474. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24475. * * p the number of windings around the z axis, optional, default 2
  24476. * * q the number of windings around the x axis, optional, default 3
  24477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24478. * * 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)
  24479. * * 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)
  24480. * @returns the VertexData of the Torus Knot
  24481. */
  24482. static CreateTorusKnot(options: {
  24483. radius?: number;
  24484. tube?: number;
  24485. radialSegments?: number;
  24486. tubularSegments?: number;
  24487. p?: number;
  24488. q?: number;
  24489. sideOrientation?: number;
  24490. frontUVs?: Vector4;
  24491. backUVs?: Vector4;
  24492. }): VertexData;
  24493. /**
  24494. * Compute normals for given positions and indices
  24495. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24496. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24497. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24498. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24499. * * facetNormals : optional array of facet normals (vector3)
  24500. * * facetPositions : optional array of facet positions (vector3)
  24501. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24502. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24503. * * bInfo : optional bounding info, required for facetPartitioning computation
  24504. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24505. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24506. * * useRightHandedSystem: optional boolean to for right handed system computation
  24507. * * depthSort : optional boolean to enable the facet depth sort computation
  24508. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24509. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24510. */
  24511. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24512. facetNormals?: any;
  24513. facetPositions?: any;
  24514. facetPartitioning?: any;
  24515. ratio?: number;
  24516. bInfo?: any;
  24517. bbSize?: Vector3;
  24518. subDiv?: any;
  24519. useRightHandedSystem?: boolean;
  24520. depthSort?: boolean;
  24521. distanceTo?: Vector3;
  24522. depthSortedFacets?: any;
  24523. }): void;
  24524. /** @hidden */
  24525. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24526. /**
  24527. * Applies VertexData created from the imported parameters to the geometry
  24528. * @param parsedVertexData the parsed data from an imported file
  24529. * @param geometry the geometry to apply the VertexData to
  24530. */
  24531. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24532. }
  24533. }
  24534. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24535. import { Nullable } from "babylonjs/types";
  24536. import { Scene } from "babylonjs/scene";
  24537. import { Vector4 } from "babylonjs/Maths/math";
  24538. import { Mesh } from "babylonjs/Meshes/mesh";
  24539. /**
  24540. * Class containing static functions to help procedurally build meshes
  24541. */
  24542. export class DiscBuilder {
  24543. /**
  24544. * Creates a plane polygonal mesh. By default, this is a disc
  24545. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24546. * * 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
  24547. * * 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
  24548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24551. * @param name defines the name of the mesh
  24552. * @param options defines the options used to create the mesh
  24553. * @param scene defines the hosting scene
  24554. * @returns the plane polygonal mesh
  24555. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24556. */
  24557. static CreateDisc(name: string, options: {
  24558. radius?: number;
  24559. tessellation?: number;
  24560. arc?: number;
  24561. updatable?: boolean;
  24562. sideOrientation?: number;
  24563. frontUVs?: Vector4;
  24564. backUVs?: Vector4;
  24565. }, scene?: Nullable<Scene>): Mesh;
  24566. }
  24567. }
  24568. declare module "babylonjs/Particles/solidParticleSystem" {
  24569. import { Vector3 } from "babylonjs/Maths/math";
  24570. import { Mesh } from "babylonjs/Meshes/mesh";
  24571. import { Scene, IDisposable } from "babylonjs/scene";
  24572. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24573. /**
  24574. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24575. *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.
  24576. * The SPS is also a particle system. It provides some methods to manage the particles.
  24577. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24578. *
  24579. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24580. */
  24581. export class SolidParticleSystem implements IDisposable {
  24582. /**
  24583. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24584. * Example : var p = SPS.particles[i];
  24585. */
  24586. particles: SolidParticle[];
  24587. /**
  24588. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24589. */
  24590. nbParticles: number;
  24591. /**
  24592. * If the particles must ever face the camera (default false). Useful for planar particles.
  24593. */
  24594. billboard: boolean;
  24595. /**
  24596. * Recompute normals when adding a shape
  24597. */
  24598. recomputeNormals: boolean;
  24599. /**
  24600. * This a counter ofr your own usage. It's not set by any SPS functions.
  24601. */
  24602. counter: number;
  24603. /**
  24604. * The SPS name. This name is also given to the underlying mesh.
  24605. */
  24606. name: string;
  24607. /**
  24608. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24609. */
  24610. mesh: Mesh;
  24611. /**
  24612. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24613. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24614. */
  24615. vars: any;
  24616. /**
  24617. * This array is populated when the SPS is set as 'pickable'.
  24618. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24619. * Each element of this array is an object `{idx: int, faceId: int}`.
  24620. * `idx` is the picked particle index in the `SPS.particles` array
  24621. * `faceId` is the picked face index counted within this particle.
  24622. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24623. */
  24624. pickedParticles: {
  24625. idx: number;
  24626. faceId: number;
  24627. }[];
  24628. /**
  24629. * This array is populated when `enableDepthSort` is set to true.
  24630. * Each element of this array is an instance of the class DepthSortedParticle.
  24631. */
  24632. depthSortedParticles: DepthSortedParticle[];
  24633. /**
  24634. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24635. * @hidden
  24636. */
  24637. _bSphereOnly: boolean;
  24638. /**
  24639. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24640. * @hidden
  24641. */
  24642. _bSphereRadiusFactor: number;
  24643. private _scene;
  24644. private _positions;
  24645. private _indices;
  24646. private _normals;
  24647. private _colors;
  24648. private _uvs;
  24649. private _indices32;
  24650. private _positions32;
  24651. private _normals32;
  24652. private _fixedNormal32;
  24653. private _colors32;
  24654. private _uvs32;
  24655. private _index;
  24656. private _updatable;
  24657. private _pickable;
  24658. private _isVisibilityBoxLocked;
  24659. private _alwaysVisible;
  24660. private _depthSort;
  24661. private _shapeCounter;
  24662. private _copy;
  24663. private _color;
  24664. private _computeParticleColor;
  24665. private _computeParticleTexture;
  24666. private _computeParticleRotation;
  24667. private _computeParticleVertex;
  24668. private _computeBoundingBox;
  24669. private _depthSortParticles;
  24670. private _camera;
  24671. private _mustUnrotateFixedNormals;
  24672. private _particlesIntersect;
  24673. private _needs32Bits;
  24674. /**
  24675. * Creates a SPS (Solid Particle System) object.
  24676. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24677. * @param scene (Scene) is the scene in which the SPS is added.
  24678. * @param options defines the options of the sps e.g.
  24679. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24680. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24681. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24682. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24683. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24684. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24685. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24686. */
  24687. constructor(name: string, scene: Scene, options?: {
  24688. updatable?: boolean;
  24689. isPickable?: boolean;
  24690. enableDepthSort?: boolean;
  24691. particleIntersection?: boolean;
  24692. boundingSphereOnly?: boolean;
  24693. bSphereRadiusFactor?: number;
  24694. });
  24695. /**
  24696. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24697. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24698. * @returns the created mesh
  24699. */
  24700. buildMesh(): Mesh;
  24701. /**
  24702. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24703. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24704. * Thus the particles generated from `digest()` have their property `position` set yet.
  24705. * @param mesh ( Mesh ) is the mesh to be digested
  24706. * @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
  24707. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24708. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24709. * @returns the current SPS
  24710. */
  24711. digest(mesh: Mesh, options?: {
  24712. facetNb?: number;
  24713. number?: number;
  24714. delta?: number;
  24715. }): SolidParticleSystem;
  24716. private _unrotateFixedNormals;
  24717. private _resetCopy;
  24718. private _meshBuilder;
  24719. private _posToShape;
  24720. private _uvsToShapeUV;
  24721. private _addParticle;
  24722. /**
  24723. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24724. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24725. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24726. * @param nb (positive integer) the number of particles to be created from this model
  24727. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24728. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24729. * @returns the number of shapes in the system
  24730. */
  24731. addShape(mesh: Mesh, nb: number, options?: {
  24732. positionFunction?: any;
  24733. vertexFunction?: any;
  24734. }): number;
  24735. private _rebuildParticle;
  24736. /**
  24737. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24738. * @returns the SPS.
  24739. */
  24740. rebuildMesh(): SolidParticleSystem;
  24741. /**
  24742. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24743. * This method calls `updateParticle()` for each particle of the SPS.
  24744. * For an animated SPS, it is usually called within the render loop.
  24745. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24746. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24747. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24748. * @returns the SPS.
  24749. */
  24750. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24751. /**
  24752. * Disposes the SPS.
  24753. */
  24754. dispose(): void;
  24755. /**
  24756. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24757. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24758. * @returns the SPS.
  24759. */
  24760. refreshVisibleSize(): SolidParticleSystem;
  24761. /**
  24762. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24763. * @param size the size (float) of the visibility box
  24764. * note : this doesn't lock the SPS mesh bounding box.
  24765. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24766. */
  24767. setVisibilityBox(size: number): void;
  24768. /**
  24769. * Gets whether the SPS as always visible or not
  24770. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24771. */
  24772. /**
  24773. * Sets the SPS as always visible or not
  24774. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24775. */
  24776. isAlwaysVisible: boolean;
  24777. /**
  24778. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24779. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24780. */
  24781. /**
  24782. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24783. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24784. */
  24785. isVisibilityBoxLocked: boolean;
  24786. /**
  24787. * Tells to `setParticles()` to compute the particle rotations or not.
  24788. * Default value : true. The SPS is faster when it's set to false.
  24789. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24790. */
  24791. /**
  24792. * Gets if `setParticles()` computes the particle rotations or not.
  24793. * Default value : true. The SPS is faster when it's set to false.
  24794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24795. */
  24796. computeParticleRotation: boolean;
  24797. /**
  24798. * Tells to `setParticles()` to compute the particle colors or not.
  24799. * Default value : true. The SPS is faster when it's set to false.
  24800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24801. */
  24802. /**
  24803. * Gets if `setParticles()` computes the particle colors or not.
  24804. * Default value : true. The SPS is faster when it's set to false.
  24805. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24806. */
  24807. computeParticleColor: boolean;
  24808. /**
  24809. * Gets if `setParticles()` computes the particle textures or not.
  24810. * Default value : true. The SPS is faster when it's set to false.
  24811. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24812. */
  24813. computeParticleTexture: boolean;
  24814. /**
  24815. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24816. * Default value : false. The SPS is faster when it's set to false.
  24817. * Note : the particle custom vertex positions aren't stored values.
  24818. */
  24819. /**
  24820. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24821. * Default value : false. The SPS is faster when it's set to false.
  24822. * Note : the particle custom vertex positions aren't stored values.
  24823. */
  24824. computeParticleVertex: boolean;
  24825. /**
  24826. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24827. */
  24828. /**
  24829. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24830. */
  24831. computeBoundingBox: boolean;
  24832. /**
  24833. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24834. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24835. * Default : `true`
  24836. */
  24837. /**
  24838. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24839. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24840. * Default : `true`
  24841. */
  24842. depthSortParticles: boolean;
  24843. /**
  24844. * This function does nothing. It may be overwritten to set all the particle first values.
  24845. * The SPS doesn't call this function, you may have to call it by your own.
  24846. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24847. */
  24848. initParticles(): void;
  24849. /**
  24850. * This function does nothing. It may be overwritten to recycle a particle.
  24851. * The SPS doesn't call this function, you may have to call it by your own.
  24852. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24853. * @param particle The particle to recycle
  24854. * @returns the recycled particle
  24855. */
  24856. recycleParticle(particle: SolidParticle): SolidParticle;
  24857. /**
  24858. * Updates a particle : this function should be overwritten by the user.
  24859. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24861. * @example : just set a particle position or velocity and recycle conditions
  24862. * @param particle The particle to update
  24863. * @returns the updated particle
  24864. */
  24865. updateParticle(particle: SolidParticle): SolidParticle;
  24866. /**
  24867. * Updates a vertex of a particle : it can be overwritten by the user.
  24868. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24869. * @param particle the current particle
  24870. * @param vertex the current index of the current particle
  24871. * @param pt the index of the current vertex in the particle shape
  24872. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24873. * @example : just set a vertex particle position
  24874. * @returns the updated vertex
  24875. */
  24876. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24877. /**
  24878. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24879. * This does nothing and may be overwritten by the user.
  24880. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24881. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24882. * @param update the boolean update value actually passed to setParticles()
  24883. */
  24884. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24885. /**
  24886. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24887. * This will be passed three parameters.
  24888. * This does nothing and may be overwritten by the user.
  24889. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24890. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24891. * @param update the boolean update value actually passed to setParticles()
  24892. */
  24893. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24894. }
  24895. }
  24896. declare module "babylonjs/Particles/solidParticle" {
  24897. import { Nullable } from "babylonjs/types";
  24898. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24899. import { Mesh } from "babylonjs/Meshes/mesh";
  24900. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24901. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24902. /**
  24903. * Represents one particle of a solid particle system.
  24904. */
  24905. export class SolidParticle {
  24906. /**
  24907. * particle global index
  24908. */
  24909. idx: number;
  24910. /**
  24911. * The color of the particle
  24912. */
  24913. color: Nullable<Color4>;
  24914. /**
  24915. * The world space position of the particle.
  24916. */
  24917. position: Vector3;
  24918. /**
  24919. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24920. */
  24921. rotation: Vector3;
  24922. /**
  24923. * The world space rotation quaternion of the particle.
  24924. */
  24925. rotationQuaternion: Nullable<Quaternion>;
  24926. /**
  24927. * The scaling of the particle.
  24928. */
  24929. scaling: Vector3;
  24930. /**
  24931. * The uvs of the particle.
  24932. */
  24933. uvs: Vector4;
  24934. /**
  24935. * The current speed of the particle.
  24936. */
  24937. velocity: Vector3;
  24938. /**
  24939. * The pivot point in the particle local space.
  24940. */
  24941. pivot: Vector3;
  24942. /**
  24943. * Must the particle be translated from its pivot point in its local space ?
  24944. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24945. * Default : false
  24946. */
  24947. translateFromPivot: boolean;
  24948. /**
  24949. * Is the particle active or not ?
  24950. */
  24951. alive: boolean;
  24952. /**
  24953. * Is the particle visible or not ?
  24954. */
  24955. isVisible: boolean;
  24956. /**
  24957. * Index of this particle in the global "positions" array (Internal use)
  24958. * @hidden
  24959. */
  24960. _pos: number;
  24961. /**
  24962. * @hidden Index of this particle in the global "indices" array (Internal use)
  24963. */
  24964. _ind: number;
  24965. /**
  24966. * @hidden ModelShape of this particle (Internal use)
  24967. */
  24968. _model: ModelShape;
  24969. /**
  24970. * ModelShape id of this particle
  24971. */
  24972. shapeId: number;
  24973. /**
  24974. * Index of the particle in its shape id (Internal use)
  24975. */
  24976. idxInShape: number;
  24977. /**
  24978. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24979. */
  24980. _modelBoundingInfo: BoundingInfo;
  24981. /**
  24982. * @hidden Particle BoundingInfo object (Internal use)
  24983. */
  24984. _boundingInfo: BoundingInfo;
  24985. /**
  24986. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24987. */
  24988. _sps: SolidParticleSystem;
  24989. /**
  24990. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24991. */
  24992. _stillInvisible: boolean;
  24993. /**
  24994. * @hidden Last computed particle rotation matrix
  24995. */
  24996. _rotationMatrix: number[];
  24997. /**
  24998. * Parent particle Id, if any.
  24999. * Default null.
  25000. */
  25001. parentId: Nullable<number>;
  25002. /**
  25003. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25004. * The possible values are :
  25005. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25006. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25007. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25008. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25009. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25010. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25011. * */
  25012. cullingStrategy: number;
  25013. /**
  25014. * @hidden Internal global position in the SPS.
  25015. */
  25016. _globalPosition: Vector3;
  25017. /**
  25018. * Creates a Solid Particle object.
  25019. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25020. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25021. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25022. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25023. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25024. * @param shapeId (integer) is the model shape identifier in the SPS.
  25025. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25026. * @param sps defines the sps it is associated to
  25027. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25028. */
  25029. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25030. /**
  25031. * Legacy support, changed scale to scaling
  25032. */
  25033. /**
  25034. * Legacy support, changed scale to scaling
  25035. */
  25036. scale: Vector3;
  25037. /**
  25038. * Legacy support, changed quaternion to rotationQuaternion
  25039. */
  25040. /**
  25041. * Legacy support, changed quaternion to rotationQuaternion
  25042. */
  25043. quaternion: Nullable<Quaternion>;
  25044. /**
  25045. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25046. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25047. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25048. * @returns true if it intersects
  25049. */
  25050. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25051. /**
  25052. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25053. * A particle is in the frustum if its bounding box intersects the frustum
  25054. * @param frustumPlanes defines the frustum to test
  25055. * @returns true if the particle is in the frustum planes
  25056. */
  25057. isInFrustum(frustumPlanes: Plane[]): boolean;
  25058. /**
  25059. * get the rotation matrix of the particle
  25060. * @hidden
  25061. */
  25062. getRotationMatrix(m: Matrix): void;
  25063. }
  25064. /**
  25065. * Represents the shape of the model used by one particle of a solid particle system.
  25066. * SPS internal tool, don't use it manually.
  25067. */
  25068. export class ModelShape {
  25069. /**
  25070. * The shape id
  25071. * @hidden
  25072. */
  25073. shapeID: number;
  25074. /**
  25075. * flat array of model positions (internal use)
  25076. * @hidden
  25077. */
  25078. _shape: Vector3[];
  25079. /**
  25080. * flat array of model UVs (internal use)
  25081. * @hidden
  25082. */
  25083. _shapeUV: number[];
  25084. /**
  25085. * length of the shape in the model indices array (internal use)
  25086. * @hidden
  25087. */
  25088. _indicesLength: number;
  25089. /**
  25090. * Custom position function (internal use)
  25091. * @hidden
  25092. */
  25093. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25094. /**
  25095. * Custom vertex function (internal use)
  25096. * @hidden
  25097. */
  25098. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25099. /**
  25100. * 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.
  25101. * SPS internal tool, don't use it manually.
  25102. * @hidden
  25103. */
  25104. 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>);
  25105. }
  25106. /**
  25107. * Represents a Depth Sorted Particle in the solid particle system.
  25108. */
  25109. export class DepthSortedParticle {
  25110. /**
  25111. * Index of the particle in the "indices" array
  25112. */
  25113. ind: number;
  25114. /**
  25115. * Length of the particle shape in the "indices" array
  25116. */
  25117. indicesLength: number;
  25118. /**
  25119. * Squared distance from the particle to the camera
  25120. */
  25121. sqDistance: number;
  25122. }
  25123. }
  25124. declare module "babylonjs/Collisions/meshCollisionData" {
  25125. import { Collider } from "babylonjs/Collisions/collider";
  25126. import { Vector3 } from "babylonjs/Maths/math";
  25127. import { Nullable } from "babylonjs/types";
  25128. import { Observer } from "babylonjs/Misc/observable";
  25129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25130. /**
  25131. * @hidden
  25132. */
  25133. export class _MeshCollisionData {
  25134. _checkCollisions: boolean;
  25135. _collisionMask: number;
  25136. _collisionGroup: number;
  25137. _collider: Nullable<Collider>;
  25138. _oldPositionForCollisions: Vector3;
  25139. _diffPositionForCollisions: Vector3;
  25140. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25141. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25142. }
  25143. }
  25144. declare module "babylonjs/Meshes/abstractMesh" {
  25145. import { Observable } from "babylonjs/Misc/observable";
  25146. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25147. import { Camera } from "babylonjs/Cameras/camera";
  25148. import { Scene, IDisposable } from "babylonjs/scene";
  25149. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25150. import { Node } from "babylonjs/node";
  25151. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25152. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25154. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25155. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25156. import { Material } from "babylonjs/Materials/material";
  25157. import { Light } from "babylonjs/Lights/light";
  25158. import { Skeleton } from "babylonjs/Bones/skeleton";
  25159. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25160. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25161. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25162. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25163. import { Ray } from "babylonjs/Culling/ray";
  25164. import { Collider } from "babylonjs/Collisions/collider";
  25165. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25166. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25167. /** @hidden */
  25168. class _FacetDataStorage {
  25169. facetPositions: Vector3[];
  25170. facetNormals: Vector3[];
  25171. facetPartitioning: number[][];
  25172. facetNb: number;
  25173. partitioningSubdivisions: number;
  25174. partitioningBBoxRatio: number;
  25175. facetDataEnabled: boolean;
  25176. facetParameters: any;
  25177. bbSize: Vector3;
  25178. subDiv: {
  25179. max: number;
  25180. X: number;
  25181. Y: number;
  25182. Z: number;
  25183. };
  25184. facetDepthSort: boolean;
  25185. facetDepthSortEnabled: boolean;
  25186. depthSortedIndices: IndicesArray;
  25187. depthSortedFacets: {
  25188. ind: number;
  25189. sqDistance: number;
  25190. }[];
  25191. facetDepthSortFunction: (f1: {
  25192. ind: number;
  25193. sqDistance: number;
  25194. }, f2: {
  25195. ind: number;
  25196. sqDistance: number;
  25197. }) => number;
  25198. facetDepthSortFrom: Vector3;
  25199. facetDepthSortOrigin: Vector3;
  25200. invertedMatrix: Matrix;
  25201. }
  25202. /**
  25203. * @hidden
  25204. **/
  25205. class _InternalAbstractMeshDataInfo {
  25206. _hasVertexAlpha: boolean;
  25207. _useVertexColors: boolean;
  25208. _numBoneInfluencers: number;
  25209. _applyFog: boolean;
  25210. _receiveShadows: boolean;
  25211. _facetData: _FacetDataStorage;
  25212. _visibility: number;
  25213. _skeleton: Nullable<Skeleton>;
  25214. _layerMask: number;
  25215. _computeBonesUsingShaders: boolean;
  25216. _isActive: boolean;
  25217. _onlyForInstances: boolean;
  25218. _isActiveIntermediate: boolean;
  25219. _onlyForInstancesIntermediate: boolean;
  25220. }
  25221. /**
  25222. * Class used to store all common mesh properties
  25223. */
  25224. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25225. /** No occlusion */
  25226. static OCCLUSION_TYPE_NONE: number;
  25227. /** Occlusion set to optimisitic */
  25228. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25229. /** Occlusion set to strict */
  25230. static OCCLUSION_TYPE_STRICT: number;
  25231. /** Use an accurante occlusion algorithm */
  25232. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25233. /** Use a conservative occlusion algorithm */
  25234. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25235. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25236. * Test order :
  25237. * Is the bounding sphere outside the frustum ?
  25238. * If not, are the bounding box vertices outside the frustum ?
  25239. * It not, then the cullable object is in the frustum.
  25240. */
  25241. static readonly CULLINGSTRATEGY_STANDARD: number;
  25242. /** Culling strategy : Bounding Sphere Only.
  25243. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25244. * It's also less accurate than the standard because some not visible objects can still be selected.
  25245. * Test : is the bounding sphere outside the frustum ?
  25246. * If not, then the cullable object is in the frustum.
  25247. */
  25248. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25249. /** Culling strategy : Optimistic Inclusion.
  25250. * This in an inclusion test first, then the standard exclusion test.
  25251. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25252. * 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.
  25253. * Anyway, it's as accurate as the standard strategy.
  25254. * Test :
  25255. * Is the cullable object bounding sphere center in the frustum ?
  25256. * If not, apply the default culling strategy.
  25257. */
  25258. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25259. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25260. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25261. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25262. * 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.
  25263. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25264. * Test :
  25265. * Is the cullable object bounding sphere center in the frustum ?
  25266. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25267. */
  25268. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25269. /**
  25270. * No billboard
  25271. */
  25272. static readonly BILLBOARDMODE_NONE: number;
  25273. /** Billboard on X axis */
  25274. static readonly BILLBOARDMODE_X: number;
  25275. /** Billboard on Y axis */
  25276. static readonly BILLBOARDMODE_Y: number;
  25277. /** Billboard on Z axis */
  25278. static readonly BILLBOARDMODE_Z: number;
  25279. /** Billboard on all axes */
  25280. static readonly BILLBOARDMODE_ALL: number;
  25281. /** @hidden */
  25282. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25283. /**
  25284. * The culling strategy to use to check whether the mesh must be rendered or not.
  25285. * This value can be changed at any time and will be used on the next render mesh selection.
  25286. * The possible values are :
  25287. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25288. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25289. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25290. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25291. * Please read each static variable documentation to get details about the culling process.
  25292. * */
  25293. cullingStrategy: number;
  25294. /**
  25295. * Gets the number of facets in the mesh
  25296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25297. */
  25298. readonly facetNb: number;
  25299. /**
  25300. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25302. */
  25303. partitioningSubdivisions: number;
  25304. /**
  25305. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25306. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25308. */
  25309. partitioningBBoxRatio: number;
  25310. /**
  25311. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25312. * Works only for updatable meshes.
  25313. * Doesn't work with multi-materials
  25314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25315. */
  25316. mustDepthSortFacets: boolean;
  25317. /**
  25318. * The location (Vector3) where the facet depth sort must be computed from.
  25319. * By default, the active camera position.
  25320. * Used only when facet depth sort is enabled
  25321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25322. */
  25323. facetDepthSortFrom: Vector3;
  25324. /**
  25325. * gets a boolean indicating if facetData is enabled
  25326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25327. */
  25328. readonly isFacetDataEnabled: boolean;
  25329. /** @hidden */
  25330. _updateNonUniformScalingState(value: boolean): boolean;
  25331. /**
  25332. * An event triggered when this mesh collides with another one
  25333. */
  25334. onCollideObservable: Observable<AbstractMesh>;
  25335. /** Set a function to call when this mesh collides with another one */
  25336. onCollide: () => void;
  25337. /**
  25338. * An event triggered when the collision's position changes
  25339. */
  25340. onCollisionPositionChangeObservable: Observable<Vector3>;
  25341. /** Set a function to call when the collision's position changes */
  25342. onCollisionPositionChange: () => void;
  25343. /**
  25344. * An event triggered when material is changed
  25345. */
  25346. onMaterialChangedObservable: Observable<AbstractMesh>;
  25347. /**
  25348. * Gets or sets the orientation for POV movement & rotation
  25349. */
  25350. definedFacingForward: boolean;
  25351. /** @hidden */
  25352. _occlusionQuery: Nullable<WebGLQuery>;
  25353. /** @hidden */
  25354. _renderingGroup: Nullable<RenderingGroup>;
  25355. /**
  25356. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25357. */
  25358. /**
  25359. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25360. */
  25361. visibility: number;
  25362. /** Gets or sets the alpha index used to sort transparent meshes
  25363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25364. */
  25365. alphaIndex: number;
  25366. /**
  25367. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25368. */
  25369. isVisible: boolean;
  25370. /**
  25371. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25372. */
  25373. isPickable: boolean;
  25374. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25375. showSubMeshesBoundingBox: boolean;
  25376. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25377. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25378. */
  25379. isBlocker: boolean;
  25380. /**
  25381. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25382. */
  25383. enablePointerMoveEvents: boolean;
  25384. /**
  25385. * Specifies the rendering group id for this mesh (0 by default)
  25386. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25387. */
  25388. renderingGroupId: number;
  25389. private _material;
  25390. /** Gets or sets current material */
  25391. material: Nullable<Material>;
  25392. /**
  25393. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25394. * @see http://doc.babylonjs.com/babylon101/shadows
  25395. */
  25396. receiveShadows: boolean;
  25397. /** Defines color to use when rendering outline */
  25398. outlineColor: Color3;
  25399. /** Define width to use when rendering outline */
  25400. outlineWidth: number;
  25401. /** Defines color to use when rendering overlay */
  25402. overlayColor: Color3;
  25403. /** Defines alpha to use when rendering overlay */
  25404. overlayAlpha: number;
  25405. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25406. hasVertexAlpha: boolean;
  25407. /** 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) */
  25408. useVertexColors: boolean;
  25409. /**
  25410. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25411. */
  25412. computeBonesUsingShaders: boolean;
  25413. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25414. numBoneInfluencers: number;
  25415. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25416. applyFog: boolean;
  25417. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25418. useOctreeForRenderingSelection: boolean;
  25419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25420. useOctreeForPicking: boolean;
  25421. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25422. useOctreeForCollisions: boolean;
  25423. /**
  25424. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25425. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25426. */
  25427. layerMask: number;
  25428. /**
  25429. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25430. */
  25431. alwaysSelectAsActiveMesh: boolean;
  25432. /**
  25433. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25434. */
  25435. doNotSyncBoundingInfo: boolean;
  25436. /**
  25437. * Gets or sets the current action manager
  25438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25439. */
  25440. actionManager: Nullable<AbstractActionManager>;
  25441. private _meshCollisionData;
  25442. /**
  25443. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25445. */
  25446. ellipsoid: Vector3;
  25447. /**
  25448. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25449. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25450. */
  25451. ellipsoidOffset: Vector3;
  25452. /**
  25453. * Gets or sets a collision mask used to mask collisions (default is -1).
  25454. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25455. */
  25456. collisionMask: number;
  25457. /**
  25458. * Gets or sets the current collision group mask (-1 by default).
  25459. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25460. */
  25461. collisionGroup: number;
  25462. /**
  25463. * Defines edge width used when edgesRenderer is enabled
  25464. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25465. */
  25466. edgesWidth: number;
  25467. /**
  25468. * Defines edge color used when edgesRenderer is enabled
  25469. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25470. */
  25471. edgesColor: Color4;
  25472. /** @hidden */
  25473. _edgesRenderer: Nullable<IEdgesRenderer>;
  25474. /** @hidden */
  25475. _masterMesh: Nullable<AbstractMesh>;
  25476. /** @hidden */
  25477. _boundingInfo: Nullable<BoundingInfo>;
  25478. /** @hidden */
  25479. _renderId: number;
  25480. /**
  25481. * Gets or sets the list of subMeshes
  25482. * @see http://doc.babylonjs.com/how_to/multi_materials
  25483. */
  25484. subMeshes: SubMesh[];
  25485. /** @hidden */
  25486. _intersectionsInProgress: AbstractMesh[];
  25487. /** @hidden */
  25488. _unIndexed: boolean;
  25489. /** @hidden */
  25490. _lightSources: Light[];
  25491. /** Gets the list of lights affecting that mesh */
  25492. readonly lightSources: Light[];
  25493. /** @hidden */
  25494. readonly _positions: Nullable<Vector3[]>;
  25495. /** @hidden */
  25496. _waitingData: {
  25497. lods: Nullable<any>;
  25498. actions: Nullable<any>;
  25499. freezeWorldMatrix: Nullable<boolean>;
  25500. };
  25501. /** @hidden */
  25502. _bonesTransformMatrices: Nullable<Float32Array>;
  25503. /** @hidden */
  25504. _transformMatrixTexture: Nullable<RawTexture>;
  25505. /**
  25506. * Gets or sets a skeleton to apply skining transformations
  25507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25508. */
  25509. skeleton: Nullable<Skeleton>;
  25510. /**
  25511. * An event triggered when the mesh is rebuilt.
  25512. */
  25513. onRebuildObservable: Observable<AbstractMesh>;
  25514. /**
  25515. * Creates a new AbstractMesh
  25516. * @param name defines the name of the mesh
  25517. * @param scene defines the hosting scene
  25518. */
  25519. constructor(name: string, scene?: Nullable<Scene>);
  25520. /**
  25521. * Returns the string "AbstractMesh"
  25522. * @returns "AbstractMesh"
  25523. */
  25524. getClassName(): string;
  25525. /**
  25526. * Gets a string representation of the current mesh
  25527. * @param fullDetails defines a boolean indicating if full details must be included
  25528. * @returns a string representation of the current mesh
  25529. */
  25530. toString(fullDetails?: boolean): string;
  25531. /**
  25532. * @hidden
  25533. */
  25534. protected _getEffectiveParent(): Nullable<Node>;
  25535. /** @hidden */
  25536. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25537. /** @hidden */
  25538. _rebuild(): void;
  25539. /** @hidden */
  25540. _resyncLightSources(): void;
  25541. /** @hidden */
  25542. _resyncLighSource(light: Light): void;
  25543. /** @hidden */
  25544. _unBindEffect(): void;
  25545. /** @hidden */
  25546. _removeLightSource(light: Light): void;
  25547. private _markSubMeshesAsDirty;
  25548. /** @hidden */
  25549. _markSubMeshesAsLightDirty(): void;
  25550. /** @hidden */
  25551. _markSubMeshesAsAttributesDirty(): void;
  25552. /** @hidden */
  25553. _markSubMeshesAsMiscDirty(): void;
  25554. /**
  25555. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25556. */
  25557. scaling: Vector3;
  25558. /**
  25559. * Returns true if the mesh is blocked. Implemented by child classes
  25560. */
  25561. readonly isBlocked: boolean;
  25562. /**
  25563. * Returns the mesh itself by default. Implemented by child classes
  25564. * @param camera defines the camera to use to pick the right LOD level
  25565. * @returns the currentAbstractMesh
  25566. */
  25567. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25568. /**
  25569. * Returns 0 by default. Implemented by child classes
  25570. * @returns an integer
  25571. */
  25572. getTotalVertices(): number;
  25573. /**
  25574. * Returns a positive integer : the total number of indices in this mesh geometry.
  25575. * @returns the numner of indices or zero if the mesh has no geometry.
  25576. */
  25577. getTotalIndices(): number;
  25578. /**
  25579. * Returns null by default. Implemented by child classes
  25580. * @returns null
  25581. */
  25582. getIndices(): Nullable<IndicesArray>;
  25583. /**
  25584. * Returns the array of the requested vertex data kind. Implemented by child classes
  25585. * @param kind defines the vertex data kind to use
  25586. * @returns null
  25587. */
  25588. getVerticesData(kind: string): Nullable<FloatArray>;
  25589. /**
  25590. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25591. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25592. * Note that a new underlying VertexBuffer object is created each call.
  25593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25594. * @param kind defines vertex data kind:
  25595. * * VertexBuffer.PositionKind
  25596. * * VertexBuffer.UVKind
  25597. * * VertexBuffer.UV2Kind
  25598. * * VertexBuffer.UV3Kind
  25599. * * VertexBuffer.UV4Kind
  25600. * * VertexBuffer.UV5Kind
  25601. * * VertexBuffer.UV6Kind
  25602. * * VertexBuffer.ColorKind
  25603. * * VertexBuffer.MatricesIndicesKind
  25604. * * VertexBuffer.MatricesIndicesExtraKind
  25605. * * VertexBuffer.MatricesWeightsKind
  25606. * * VertexBuffer.MatricesWeightsExtraKind
  25607. * @param data defines the data source
  25608. * @param updatable defines if the data must be flagged as updatable (or static)
  25609. * @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
  25610. * @returns the current mesh
  25611. */
  25612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25613. /**
  25614. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25615. * If the mesh has no geometry, it is simply returned as it is.
  25616. * @param kind defines vertex data kind:
  25617. * * VertexBuffer.PositionKind
  25618. * * VertexBuffer.UVKind
  25619. * * VertexBuffer.UV2Kind
  25620. * * VertexBuffer.UV3Kind
  25621. * * VertexBuffer.UV4Kind
  25622. * * VertexBuffer.UV5Kind
  25623. * * VertexBuffer.UV6Kind
  25624. * * VertexBuffer.ColorKind
  25625. * * VertexBuffer.MatricesIndicesKind
  25626. * * VertexBuffer.MatricesIndicesExtraKind
  25627. * * VertexBuffer.MatricesWeightsKind
  25628. * * VertexBuffer.MatricesWeightsExtraKind
  25629. * @param data defines the data source
  25630. * @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
  25631. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25632. * @returns the current mesh
  25633. */
  25634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25635. /**
  25636. * Sets the mesh indices,
  25637. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25638. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25639. * @param totalVertices Defines the total number of vertices
  25640. * @returns the current mesh
  25641. */
  25642. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25643. /**
  25644. * Gets a boolean indicating if specific vertex data is present
  25645. * @param kind defines the vertex data kind to use
  25646. * @returns true is data kind is present
  25647. */
  25648. isVerticesDataPresent(kind: string): boolean;
  25649. /**
  25650. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25651. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25652. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25653. * @returns a BoundingInfo
  25654. */
  25655. getBoundingInfo(): BoundingInfo;
  25656. /**
  25657. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25658. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25659. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25660. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25661. * @returns the current mesh
  25662. */
  25663. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25664. /**
  25665. * Overwrite the current bounding info
  25666. * @param boundingInfo defines the new bounding info
  25667. * @returns the current mesh
  25668. */
  25669. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25670. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25671. readonly useBones: boolean;
  25672. /** @hidden */
  25673. _preActivate(): void;
  25674. /** @hidden */
  25675. _preActivateForIntermediateRendering(renderId: number): void;
  25676. /** @hidden */
  25677. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25678. /** @hidden */
  25679. _postActivate(): void;
  25680. /** @hidden */
  25681. _freeze(): void;
  25682. /** @hidden */
  25683. _unFreeze(): void;
  25684. /**
  25685. * Gets the current world matrix
  25686. * @returns a Matrix
  25687. */
  25688. getWorldMatrix(): Matrix;
  25689. /** @hidden */
  25690. _getWorldMatrixDeterminant(): number;
  25691. /**
  25692. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25693. */
  25694. readonly isAnInstance: boolean;
  25695. /**
  25696. * Perform relative position change from the point of view of behind the front of the mesh.
  25697. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25698. * Supports definition of mesh facing forward or backward
  25699. * @param amountRight defines the distance on the right axis
  25700. * @param amountUp defines the distance on the up axis
  25701. * @param amountForward defines the distance on the forward axis
  25702. * @returns the current mesh
  25703. */
  25704. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25705. /**
  25706. * Calculate relative position change from the point of view of behind the front of the mesh.
  25707. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25708. * Supports definition of mesh facing forward or backward
  25709. * @param amountRight defines the distance on the right axis
  25710. * @param amountUp defines the distance on the up axis
  25711. * @param amountForward defines the distance on the forward axis
  25712. * @returns the new displacement vector
  25713. */
  25714. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25715. /**
  25716. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25717. * Supports definition of mesh facing forward or backward
  25718. * @param flipBack defines the flip
  25719. * @param twirlClockwise defines the twirl
  25720. * @param tiltRight defines the tilt
  25721. * @returns the current mesh
  25722. */
  25723. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25724. /**
  25725. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25726. * Supports definition of mesh facing forward or backward.
  25727. * @param flipBack defines the flip
  25728. * @param twirlClockwise defines the twirl
  25729. * @param tiltRight defines the tilt
  25730. * @returns the new rotation vector
  25731. */
  25732. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25733. /**
  25734. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25735. * This means the mesh underlying bounding box and sphere are recomputed.
  25736. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25737. * @returns the current mesh
  25738. */
  25739. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25740. /** @hidden */
  25741. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25742. /** @hidden */
  25743. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25744. /** @hidden */
  25745. _updateBoundingInfo(): AbstractMesh;
  25746. /** @hidden */
  25747. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25748. /** @hidden */
  25749. protected _afterComputeWorldMatrix(): void;
  25750. /** @hidden */
  25751. readonly _effectiveMesh: AbstractMesh;
  25752. /**
  25753. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25754. * A mesh is in the frustum if its bounding box intersects the frustum
  25755. * @param frustumPlanes defines the frustum to test
  25756. * @returns true if the mesh is in the frustum planes
  25757. */
  25758. isInFrustum(frustumPlanes: Plane[]): boolean;
  25759. /**
  25760. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25761. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25762. * @param frustumPlanes defines the frustum to test
  25763. * @returns true if the mesh is completely in the frustum planes
  25764. */
  25765. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25766. /**
  25767. * True if the mesh intersects another mesh or a SolidParticle object
  25768. * @param mesh defines a target mesh or SolidParticle to test
  25769. * @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)
  25770. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25771. * @returns true if there is an intersection
  25772. */
  25773. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25774. /**
  25775. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25776. * @param point defines the point to test
  25777. * @returns true if there is an intersection
  25778. */
  25779. intersectsPoint(point: Vector3): boolean;
  25780. /**
  25781. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25783. */
  25784. checkCollisions: boolean;
  25785. /**
  25786. * Gets Collider object used to compute collisions (not physics)
  25787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25788. */
  25789. readonly collider: Nullable<Collider>;
  25790. /**
  25791. * Move the mesh using collision engine
  25792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25793. * @param displacement defines the requested displacement vector
  25794. * @returns the current mesh
  25795. */
  25796. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25797. private _onCollisionPositionChange;
  25798. /** @hidden */
  25799. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25800. /** @hidden */
  25801. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25802. /** @hidden */
  25803. _checkCollision(collider: Collider): AbstractMesh;
  25804. /** @hidden */
  25805. _generatePointsArray(): boolean;
  25806. /**
  25807. * Checks if the passed Ray intersects with the mesh
  25808. * @param ray defines the ray to use
  25809. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25810. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25811. * @returns the picking info
  25812. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25813. */
  25814. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25815. /**
  25816. * Clones the current mesh
  25817. * @param name defines the mesh name
  25818. * @param newParent defines the new mesh parent
  25819. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25820. * @returns the new mesh
  25821. */
  25822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25823. /**
  25824. * Disposes all the submeshes of the current meshnp
  25825. * @returns the current mesh
  25826. */
  25827. releaseSubMeshes(): AbstractMesh;
  25828. /**
  25829. * Releases resources associated with this abstract mesh.
  25830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25832. */
  25833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25834. /**
  25835. * Adds the passed mesh as a child to the current mesh
  25836. * @param mesh defines the child mesh
  25837. * @returns the current mesh
  25838. */
  25839. addChild(mesh: AbstractMesh): AbstractMesh;
  25840. /**
  25841. * Removes the passed mesh from the current mesh children list
  25842. * @param mesh defines the child mesh
  25843. * @returns the current mesh
  25844. */
  25845. removeChild(mesh: AbstractMesh): AbstractMesh;
  25846. /** @hidden */
  25847. private _initFacetData;
  25848. /**
  25849. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25850. * This method can be called within the render loop.
  25851. * 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
  25852. * @returns the current mesh
  25853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25854. */
  25855. updateFacetData(): AbstractMesh;
  25856. /**
  25857. * Returns the facetLocalNormals array.
  25858. * The normals are expressed in the mesh local spac
  25859. * @returns an array of Vector3
  25860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25861. */
  25862. getFacetLocalNormals(): Vector3[];
  25863. /**
  25864. * Returns the facetLocalPositions array.
  25865. * The facet positions are expressed in the mesh local space
  25866. * @returns an array of Vector3
  25867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25868. */
  25869. getFacetLocalPositions(): Vector3[];
  25870. /**
  25871. * Returns the facetLocalPartioning array
  25872. * @returns an array of array of numbers
  25873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25874. */
  25875. getFacetLocalPartitioning(): number[][];
  25876. /**
  25877. * Returns the i-th facet position in the world system.
  25878. * This method allocates a new Vector3 per call
  25879. * @param i defines the facet index
  25880. * @returns a new Vector3
  25881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25882. */
  25883. getFacetPosition(i: number): Vector3;
  25884. /**
  25885. * Sets the reference Vector3 with the i-th facet position in the world system
  25886. * @param i defines the facet index
  25887. * @param ref defines the target vector
  25888. * @returns the current mesh
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25890. */
  25891. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25892. /**
  25893. * Returns the i-th facet normal in the world system.
  25894. * This method allocates a new Vector3 per call
  25895. * @param i defines the facet index
  25896. * @returns a new Vector3
  25897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25898. */
  25899. getFacetNormal(i: number): Vector3;
  25900. /**
  25901. * Sets the reference Vector3 with the i-th facet normal in the world system
  25902. * @param i defines the facet index
  25903. * @param ref defines the target vector
  25904. * @returns the current mesh
  25905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25906. */
  25907. getFacetNormalToRef(i: number, ref: Vector3): this;
  25908. /**
  25909. * 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)
  25910. * @param x defines x coordinate
  25911. * @param y defines y coordinate
  25912. * @param z defines z coordinate
  25913. * @returns the array of facet indexes
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25915. */
  25916. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25917. /**
  25918. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25919. * @param projected sets as the (x,y,z) world projection on the facet
  25920. * @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
  25921. * @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
  25922. * @param x defines x coordinate
  25923. * @param y defines y coordinate
  25924. * @param z defines z coordinate
  25925. * @returns the face index if found (or null instead)
  25926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25927. */
  25928. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25929. /**
  25930. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25931. * @param projected sets as the (x,y,z) local projection on the facet
  25932. * @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
  25933. * @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
  25934. * @param x defines x coordinate
  25935. * @param y defines y coordinate
  25936. * @param z defines z coordinate
  25937. * @returns the face index if found (or null instead)
  25938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25939. */
  25940. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25941. /**
  25942. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25943. * @returns the parameters
  25944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25945. */
  25946. getFacetDataParameters(): any;
  25947. /**
  25948. * Disables the feature FacetData and frees the related memory
  25949. * @returns the current mesh
  25950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25951. */
  25952. disableFacetData(): AbstractMesh;
  25953. /**
  25954. * Updates the AbstractMesh indices array
  25955. * @param indices defines the data source
  25956. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25957. * @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)
  25958. * @returns the current mesh
  25959. */
  25960. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25961. /**
  25962. * Creates new normals data for the mesh
  25963. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25964. * @returns the current mesh
  25965. */
  25966. createNormals(updatable: boolean): AbstractMesh;
  25967. /**
  25968. * Align the mesh with a normal
  25969. * @param normal defines the normal to use
  25970. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25971. * @returns the current mesh
  25972. */
  25973. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25974. /** @hidden */
  25975. _checkOcclusionQuery(): boolean;
  25976. /**
  25977. * Disables the mesh edge rendering mode
  25978. * @returns the currentAbstractMesh
  25979. */
  25980. disableEdgesRendering(): AbstractMesh;
  25981. /**
  25982. * Enables the edge rendering mode on the mesh.
  25983. * This mode makes the mesh edges visible
  25984. * @param epsilon defines the maximal distance between two angles to detect a face
  25985. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25986. * @returns the currentAbstractMesh
  25987. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25988. */
  25989. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25990. }
  25991. }
  25992. declare module "babylonjs/Actions/actionEvent" {
  25993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25994. import { Nullable } from "babylonjs/types";
  25995. import { Sprite } from "babylonjs/Sprites/sprite";
  25996. import { Scene } from "babylonjs/scene";
  25997. import { Vector2 } from "babylonjs/Maths/math";
  25998. /**
  25999. * Interface used to define ActionEvent
  26000. */
  26001. export interface 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. /**
  26016. * ActionEvent is the event being sent when an action is triggered.
  26017. */
  26018. export class ActionEvent implements IActionEvent {
  26019. /** The mesh or sprite that triggered the action */
  26020. source: any;
  26021. /** The X mouse cursor position at the time of the event */
  26022. pointerX: number;
  26023. /** The Y mouse cursor position at the time of the event */
  26024. pointerY: number;
  26025. /** The mesh that is currently pointed at (can be null) */
  26026. meshUnderPointer: Nullable<AbstractMesh>;
  26027. /** the original (browser) event that triggered the ActionEvent */
  26028. sourceEvent?: any;
  26029. /** additional data for the event */
  26030. additionalData?: any;
  26031. /**
  26032. * Creates a new ActionEvent
  26033. * @param source The mesh or sprite that triggered the action
  26034. * @param pointerX The X mouse cursor position at the time of the event
  26035. * @param pointerY The Y mouse cursor position at the time of the event
  26036. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26037. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26038. * @param additionalData additional data for the event
  26039. */
  26040. constructor(
  26041. /** The mesh or sprite that triggered the action */
  26042. source: any,
  26043. /** The X mouse cursor position at the time of the event */
  26044. pointerX: number,
  26045. /** The Y mouse cursor position at the time of the event */
  26046. pointerY: number,
  26047. /** The mesh that is currently pointed at (can be null) */
  26048. meshUnderPointer: Nullable<AbstractMesh>,
  26049. /** the original (browser) event that triggered the ActionEvent */
  26050. sourceEvent?: any,
  26051. /** additional data for the event */
  26052. additionalData?: any);
  26053. /**
  26054. * Helper function to auto-create an ActionEvent from a source mesh.
  26055. * @param source The source mesh that triggered the event
  26056. * @param evt The original (browser) event
  26057. * @param additionalData additional data for the event
  26058. * @returns the new ActionEvent
  26059. */
  26060. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26061. /**
  26062. * Helper function to auto-create an ActionEvent from a source sprite
  26063. * @param source The source sprite that triggered the event
  26064. * @param scene Scene associated with the sprite
  26065. * @param evt The original (browser) event
  26066. * @param additionalData additional data for the event
  26067. * @returns the new ActionEvent
  26068. */
  26069. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26070. /**
  26071. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26072. * @param scene the scene where the event occurred
  26073. * @param evt The original (browser) event
  26074. * @returns the new ActionEvent
  26075. */
  26076. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26077. /**
  26078. * Helper function to auto-create an ActionEvent from a primitive
  26079. * @param prim defines the target primitive
  26080. * @param pointerPos defines the pointer position
  26081. * @param evt The original (browser) event
  26082. * @param additionalData additional data for the event
  26083. * @returns the new ActionEvent
  26084. */
  26085. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26086. }
  26087. }
  26088. declare module "babylonjs/Actions/abstractActionManager" {
  26089. import { IDisposable } from "babylonjs/scene";
  26090. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26091. import { IAction } from "babylonjs/Actions/action";
  26092. import { Nullable } from "babylonjs/types";
  26093. /**
  26094. * Abstract class used to decouple action Manager from scene and meshes.
  26095. * Do not instantiate.
  26096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26097. */
  26098. export abstract class AbstractActionManager implements IDisposable {
  26099. /** Gets the list of active triggers */
  26100. static Triggers: {
  26101. [key: string]: number;
  26102. };
  26103. /** Gets the cursor to use when hovering items */
  26104. hoverCursor: string;
  26105. /** Gets the list of actions */
  26106. actions: IAction[];
  26107. /**
  26108. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26109. */
  26110. isRecursive: boolean;
  26111. /**
  26112. * Releases all associated resources
  26113. */
  26114. abstract dispose(): void;
  26115. /**
  26116. * Does this action manager has pointer triggers
  26117. */
  26118. abstract readonly hasPointerTriggers: boolean;
  26119. /**
  26120. * Does this action manager has pick triggers
  26121. */
  26122. abstract readonly hasPickTriggers: boolean;
  26123. /**
  26124. * Process a specific trigger
  26125. * @param trigger defines the trigger to process
  26126. * @param evt defines the event details to be processed
  26127. */
  26128. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26129. /**
  26130. * Does this action manager handles actions of any of the given triggers
  26131. * @param triggers defines the triggers to be tested
  26132. * @return a boolean indicating whether one (or more) of the triggers is handled
  26133. */
  26134. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26135. /**
  26136. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26137. * speed.
  26138. * @param triggerA defines the trigger to be tested
  26139. * @param triggerB defines the trigger to be tested
  26140. * @return a boolean indicating whether one (or more) of the triggers is handled
  26141. */
  26142. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26143. /**
  26144. * Does this action manager handles actions of a given trigger
  26145. * @param trigger defines the trigger to be tested
  26146. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26147. * @return whether the trigger is handled
  26148. */
  26149. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26150. /**
  26151. * Serialize this manager to a JSON object
  26152. * @param name defines the property name to store this manager
  26153. * @returns a JSON representation of this manager
  26154. */
  26155. abstract serialize(name: string): any;
  26156. /**
  26157. * Registers an action to this action manager
  26158. * @param action defines the action to be registered
  26159. * @return the action amended (prepared) after registration
  26160. */
  26161. abstract registerAction(action: IAction): Nullable<IAction>;
  26162. /**
  26163. * Unregisters an action to this action manager
  26164. * @param action defines the action to be unregistered
  26165. * @return a boolean indicating whether the action has been unregistered
  26166. */
  26167. abstract unregisterAction(action: IAction): Boolean;
  26168. /**
  26169. * Does exist one action manager with at least one trigger
  26170. **/
  26171. static readonly HasTriggers: boolean;
  26172. /**
  26173. * Does exist one action manager with at least one pick trigger
  26174. **/
  26175. static readonly HasPickTriggers: boolean;
  26176. /**
  26177. * Does exist one action manager that handles actions of a given trigger
  26178. * @param trigger defines the trigger to be tested
  26179. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26180. **/
  26181. static HasSpecificTrigger(trigger: number): boolean;
  26182. }
  26183. }
  26184. declare module "babylonjs/node" {
  26185. import { Scene } from "babylonjs/scene";
  26186. import { Nullable } from "babylonjs/types";
  26187. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26188. import { Engine } from "babylonjs/Engines/engine";
  26189. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26190. import { Observable } from "babylonjs/Misc/observable";
  26191. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26192. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26193. import { Animatable } from "babylonjs/Animations/animatable";
  26194. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26195. import { Animation } from "babylonjs/Animations/animation";
  26196. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26198. /**
  26199. * Defines how a node can be built from a string name.
  26200. */
  26201. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26202. /**
  26203. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26204. */
  26205. export class Node implements IBehaviorAware<Node> {
  26206. /** @hidden */
  26207. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26208. private static _NodeConstructors;
  26209. /**
  26210. * Add a new node constructor
  26211. * @param type defines the type name of the node to construct
  26212. * @param constructorFunc defines the constructor function
  26213. */
  26214. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26215. /**
  26216. * Returns a node constructor based on type name
  26217. * @param type defines the type name
  26218. * @param name defines the new node name
  26219. * @param scene defines the hosting scene
  26220. * @param options defines optional options to transmit to constructors
  26221. * @returns the new constructor or null
  26222. */
  26223. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26224. /**
  26225. * Gets or sets the name of the node
  26226. */
  26227. name: string;
  26228. /**
  26229. * Gets or sets the id of the node
  26230. */
  26231. id: string;
  26232. /**
  26233. * Gets or sets the unique id of the node
  26234. */
  26235. uniqueId: number;
  26236. /**
  26237. * Gets or sets a string used to store user defined state for the node
  26238. */
  26239. state: string;
  26240. /**
  26241. * Gets or sets an object used to store user defined information for the node
  26242. */
  26243. metadata: any;
  26244. /**
  26245. * For internal use only. Please do not use.
  26246. */
  26247. reservedDataStore: any;
  26248. /**
  26249. * List of inspectable custom properties (used by the Inspector)
  26250. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26251. */
  26252. inspectableCustomProperties: IInspectable[];
  26253. /**
  26254. * Gets or sets a boolean used to define if the node must be serialized
  26255. */
  26256. doNotSerialize: boolean;
  26257. /** @hidden */
  26258. _isDisposed: boolean;
  26259. /**
  26260. * Gets a list of Animations associated with the node
  26261. */
  26262. animations: import("babylonjs/Animations/animation").Animation[];
  26263. protected _ranges: {
  26264. [name: string]: Nullable<AnimationRange>;
  26265. };
  26266. /**
  26267. * Callback raised when the node is ready to be used
  26268. */
  26269. onReady: Nullable<(node: Node) => void>;
  26270. private _isEnabled;
  26271. private _isParentEnabled;
  26272. private _isReady;
  26273. /** @hidden */
  26274. _currentRenderId: number;
  26275. private _parentUpdateId;
  26276. /** @hidden */
  26277. _childUpdateId: number;
  26278. /** @hidden */
  26279. _waitingParentId: Nullable<string>;
  26280. /** @hidden */
  26281. _scene: Scene;
  26282. /** @hidden */
  26283. _cache: any;
  26284. private _parentNode;
  26285. private _children;
  26286. /** @hidden */
  26287. _worldMatrix: Matrix;
  26288. /** @hidden */
  26289. _worldMatrixDeterminant: number;
  26290. /** @hidden */
  26291. _worldMatrixDeterminantIsDirty: boolean;
  26292. /** @hidden */
  26293. private _sceneRootNodesIndex;
  26294. /**
  26295. * Gets a boolean indicating if the node has been disposed
  26296. * @returns true if the node was disposed
  26297. */
  26298. isDisposed(): boolean;
  26299. /**
  26300. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26301. * @see https://doc.babylonjs.com/how_to/parenting
  26302. */
  26303. parent: Nullable<Node>;
  26304. private addToSceneRootNodes;
  26305. private removeFromSceneRootNodes;
  26306. private _animationPropertiesOverride;
  26307. /**
  26308. * Gets or sets the animation properties override
  26309. */
  26310. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26311. /**
  26312. * Gets a string idenfifying the name of the class
  26313. * @returns "Node" string
  26314. */
  26315. getClassName(): string;
  26316. /** @hidden */
  26317. readonly _isNode: boolean;
  26318. /**
  26319. * An event triggered when the mesh is disposed
  26320. */
  26321. onDisposeObservable: Observable<Node>;
  26322. private _onDisposeObserver;
  26323. /**
  26324. * Sets a callback that will be raised when the node will be disposed
  26325. */
  26326. onDispose: () => void;
  26327. /**
  26328. * Creates a new Node
  26329. * @param name the name and id to be given to this node
  26330. * @param scene the scene this node will be added to
  26331. * @param addToRootNodes the node will be added to scene.rootNodes
  26332. */
  26333. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26334. /**
  26335. * Gets the scene of the node
  26336. * @returns a scene
  26337. */
  26338. getScene(): Scene;
  26339. /**
  26340. * Gets the engine of the node
  26341. * @returns a Engine
  26342. */
  26343. getEngine(): Engine;
  26344. private _behaviors;
  26345. /**
  26346. * Attach a behavior to the node
  26347. * @see http://doc.babylonjs.com/features/behaviour
  26348. * @param behavior defines the behavior to attach
  26349. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26350. * @returns the current Node
  26351. */
  26352. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26353. /**
  26354. * Remove an attached behavior
  26355. * @see http://doc.babylonjs.com/features/behaviour
  26356. * @param behavior defines the behavior to attach
  26357. * @returns the current Node
  26358. */
  26359. removeBehavior(behavior: Behavior<Node>): Node;
  26360. /**
  26361. * Gets the list of attached behaviors
  26362. * @see http://doc.babylonjs.com/features/behaviour
  26363. */
  26364. readonly behaviors: Behavior<Node>[];
  26365. /**
  26366. * Gets an attached behavior by name
  26367. * @param name defines the name of the behavior to look for
  26368. * @see http://doc.babylonjs.com/features/behaviour
  26369. * @returns null if behavior was not found else the requested behavior
  26370. */
  26371. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26372. /**
  26373. * Returns the latest update of the World matrix
  26374. * @returns a Matrix
  26375. */
  26376. getWorldMatrix(): Matrix;
  26377. /** @hidden */
  26378. _getWorldMatrixDeterminant(): number;
  26379. /**
  26380. * Returns directly the latest state of the mesh World matrix.
  26381. * A Matrix is returned.
  26382. */
  26383. readonly worldMatrixFromCache: Matrix;
  26384. /** @hidden */
  26385. _initCache(): void;
  26386. /** @hidden */
  26387. updateCache(force?: boolean): void;
  26388. /** @hidden */
  26389. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26390. /** @hidden */
  26391. _updateCache(ignoreParentClass?: boolean): void;
  26392. /** @hidden */
  26393. _isSynchronized(): boolean;
  26394. /** @hidden */
  26395. _markSyncedWithParent(): void;
  26396. /** @hidden */
  26397. isSynchronizedWithParent(): boolean;
  26398. /** @hidden */
  26399. isSynchronized(): boolean;
  26400. /**
  26401. * Is this node ready to be used/rendered
  26402. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26403. * @return true if the node is ready
  26404. */
  26405. isReady(completeCheck?: boolean): boolean;
  26406. /**
  26407. * Is this node enabled?
  26408. * 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
  26409. * @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
  26410. * @return whether this node (and its parent) is enabled
  26411. */
  26412. isEnabled(checkAncestors?: boolean): boolean;
  26413. /** @hidden */
  26414. protected _syncParentEnabledState(): void;
  26415. /**
  26416. * Set the enabled state of this node
  26417. * @param value defines the new enabled state
  26418. */
  26419. setEnabled(value: boolean): void;
  26420. /**
  26421. * Is this node a descendant of the given node?
  26422. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26423. * @param ancestor defines the parent node to inspect
  26424. * @returns a boolean indicating if this node is a descendant of the given node
  26425. */
  26426. isDescendantOf(ancestor: Node): boolean;
  26427. /** @hidden */
  26428. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26429. /**
  26430. * Will return all nodes that have this node as ascendant
  26431. * @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
  26432. * @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
  26433. * @return all children nodes of all types
  26434. */
  26435. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26436. /**
  26437. * Get all child-meshes of this node
  26438. * @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)
  26439. * @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
  26440. * @returns an array of AbstractMesh
  26441. */
  26442. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26443. /**
  26444. * Get all direct children of this node
  26445. * @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
  26446. * @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)
  26447. * @returns an array of Node
  26448. */
  26449. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26450. /** @hidden */
  26451. _setReady(state: boolean): void;
  26452. /**
  26453. * Get an animation by name
  26454. * @param name defines the name of the animation to look for
  26455. * @returns null if not found else the requested animation
  26456. */
  26457. getAnimationByName(name: string): Nullable<Animation>;
  26458. /**
  26459. * Creates an animation range for this node
  26460. * @param name defines the name of the range
  26461. * @param from defines the starting key
  26462. * @param to defines the end key
  26463. */
  26464. createAnimationRange(name: string, from: number, to: number): void;
  26465. /**
  26466. * Delete a specific animation range
  26467. * @param name defines the name of the range to delete
  26468. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26469. */
  26470. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26471. /**
  26472. * Get an animation range by name
  26473. * @param name defines the name of the animation range to look for
  26474. * @returns null if not found else the requested animation range
  26475. */
  26476. getAnimationRange(name: string): Nullable<AnimationRange>;
  26477. /**
  26478. * Gets the list of all animation ranges defined on this node
  26479. * @returns an array
  26480. */
  26481. getAnimationRanges(): Nullable<AnimationRange>[];
  26482. /**
  26483. * Will start the animation sequence
  26484. * @param name defines the range frames for animation sequence
  26485. * @param loop defines if the animation should loop (false by default)
  26486. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26487. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26488. * @returns the object created for this animation. If range does not exist, it will return null
  26489. */
  26490. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26491. /**
  26492. * Serialize animation ranges into a JSON compatible object
  26493. * @returns serialization object
  26494. */
  26495. serializeAnimationRanges(): any;
  26496. /**
  26497. * Computes the world matrix of the node
  26498. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26499. * @returns the world matrix
  26500. */
  26501. computeWorldMatrix(force?: boolean): Matrix;
  26502. /**
  26503. * Releases resources associated with this node.
  26504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26506. */
  26507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26508. /**
  26509. * Parse animation range data from a serialization object and store them into a given node
  26510. * @param node defines where to store the animation ranges
  26511. * @param parsedNode defines the serialization object to read data from
  26512. * @param scene defines the hosting scene
  26513. */
  26514. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26515. /**
  26516. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26517. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26518. * @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
  26519. * @returns the new bounding vectors
  26520. */
  26521. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26522. min: Vector3;
  26523. max: Vector3;
  26524. };
  26525. }
  26526. }
  26527. declare module "babylonjs/Animations/animation" {
  26528. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26529. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26530. import { Nullable } from "babylonjs/types";
  26531. import { Scene } from "babylonjs/scene";
  26532. import { IAnimatable } from "babylonjs/Misc/tools";
  26533. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26534. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26535. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26536. import { Node } from "babylonjs/node";
  26537. import { Animatable } from "babylonjs/Animations/animatable";
  26538. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26539. /**
  26540. * @hidden
  26541. */
  26542. export class _IAnimationState {
  26543. key: number;
  26544. repeatCount: number;
  26545. workValue?: any;
  26546. loopMode?: number;
  26547. offsetValue?: any;
  26548. highLimitValue?: any;
  26549. }
  26550. /**
  26551. * Class used to store any kind of animation
  26552. */
  26553. export class Animation {
  26554. /**Name of the animation */
  26555. name: string;
  26556. /**Property to animate */
  26557. targetProperty: string;
  26558. /**The frames per second of the animation */
  26559. framePerSecond: number;
  26560. /**The data type of the animation */
  26561. dataType: number;
  26562. /**The loop mode of the animation */
  26563. loopMode?: number | undefined;
  26564. /**Specifies if blending should be enabled */
  26565. enableBlending?: boolean | undefined;
  26566. /**
  26567. * Use matrix interpolation instead of using direct key value when animating matrices
  26568. */
  26569. static AllowMatricesInterpolation: boolean;
  26570. /**
  26571. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26572. */
  26573. static AllowMatrixDecomposeForInterpolation: boolean;
  26574. /**
  26575. * Stores the key frames of the animation
  26576. */
  26577. private _keys;
  26578. /**
  26579. * Stores the easing function of the animation
  26580. */
  26581. private _easingFunction;
  26582. /**
  26583. * @hidden Internal use only
  26584. */
  26585. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26586. /**
  26587. * The set of event that will be linked to this animation
  26588. */
  26589. private _events;
  26590. /**
  26591. * Stores an array of target property paths
  26592. */
  26593. targetPropertyPath: string[];
  26594. /**
  26595. * Stores the blending speed of the animation
  26596. */
  26597. blendingSpeed: number;
  26598. /**
  26599. * Stores the animation ranges for the animation
  26600. */
  26601. private _ranges;
  26602. /**
  26603. * @hidden Internal use
  26604. */
  26605. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26606. /**
  26607. * Sets up an animation
  26608. * @param property The property to animate
  26609. * @param animationType The animation type to apply
  26610. * @param framePerSecond The frames per second of the animation
  26611. * @param easingFunction The easing function used in the animation
  26612. * @returns The created animation
  26613. */
  26614. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26615. /**
  26616. * Create and start an animation on a node
  26617. * @param name defines the name of the global animation that will be run on all nodes
  26618. * @param node defines the root node where the animation will take place
  26619. * @param targetProperty defines property to animate
  26620. * @param framePerSecond defines the number of frame per second yo use
  26621. * @param totalFrame defines the number of frames in total
  26622. * @param from defines the initial value
  26623. * @param to defines the final value
  26624. * @param loopMode defines which loop mode you want to use (off by default)
  26625. * @param easingFunction defines the easing function to use (linear by default)
  26626. * @param onAnimationEnd defines the callback to call when animation end
  26627. * @returns the animatable created for this animation
  26628. */
  26629. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26630. /**
  26631. * Create and start an animation on a node and its descendants
  26632. * @param name defines the name of the global animation that will be run on all nodes
  26633. * @param node defines the root node where the animation will take place
  26634. * @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
  26635. * @param targetProperty defines property to animate
  26636. * @param framePerSecond defines the number of frame per second to use
  26637. * @param totalFrame defines the number of frames in total
  26638. * @param from defines the initial value
  26639. * @param to defines the final value
  26640. * @param loopMode defines which loop mode you want to use (off by default)
  26641. * @param easingFunction defines the easing function to use (linear by default)
  26642. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26643. * @returns the list of animatables created for all nodes
  26644. * @example https://www.babylonjs-playground.com/#MH0VLI
  26645. */
  26646. 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[]>;
  26647. /**
  26648. * Creates a new animation, merges it with the existing animations and starts it
  26649. * @param name Name of the animation
  26650. * @param node Node which contains the scene that begins the animations
  26651. * @param targetProperty Specifies which property to animate
  26652. * @param framePerSecond The frames per second of the animation
  26653. * @param totalFrame The total number of frames
  26654. * @param from The frame at the beginning of the animation
  26655. * @param to The frame at the end of the animation
  26656. * @param loopMode Specifies the loop mode of the animation
  26657. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26658. * @param onAnimationEnd Callback to run once the animation is complete
  26659. * @returns Nullable animation
  26660. */
  26661. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26662. /**
  26663. * Transition property of an host to the target Value
  26664. * @param property The property to transition
  26665. * @param targetValue The target Value of the property
  26666. * @param host The object where the property to animate belongs
  26667. * @param scene Scene used to run the animation
  26668. * @param frameRate Framerate (in frame/s) to use
  26669. * @param transition The transition type we want to use
  26670. * @param duration The duration of the animation, in milliseconds
  26671. * @param onAnimationEnd Callback trigger at the end of the animation
  26672. * @returns Nullable animation
  26673. */
  26674. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26675. /**
  26676. * Return the array of runtime animations currently using this animation
  26677. */
  26678. readonly runtimeAnimations: RuntimeAnimation[];
  26679. /**
  26680. * Specifies if any of the runtime animations are currently running
  26681. */
  26682. readonly hasRunningRuntimeAnimations: boolean;
  26683. /**
  26684. * Initializes the animation
  26685. * @param name Name of the animation
  26686. * @param targetProperty Property to animate
  26687. * @param framePerSecond The frames per second of the animation
  26688. * @param dataType The data type of the animation
  26689. * @param loopMode The loop mode of the animation
  26690. * @param enableBlending Specifies if blending should be enabled
  26691. */
  26692. constructor(
  26693. /**Name of the animation */
  26694. name: string,
  26695. /**Property to animate */
  26696. targetProperty: string,
  26697. /**The frames per second of the animation */
  26698. framePerSecond: number,
  26699. /**The data type of the animation */
  26700. dataType: number,
  26701. /**The loop mode of the animation */
  26702. loopMode?: number | undefined,
  26703. /**Specifies if blending should be enabled */
  26704. enableBlending?: boolean | undefined);
  26705. /**
  26706. * Converts the animation to a string
  26707. * @param fullDetails support for multiple levels of logging within scene loading
  26708. * @returns String form of the animation
  26709. */
  26710. toString(fullDetails?: boolean): string;
  26711. /**
  26712. * Add an event to this animation
  26713. * @param event Event to add
  26714. */
  26715. addEvent(event: AnimationEvent): void;
  26716. /**
  26717. * Remove all events found at the given frame
  26718. * @param frame The frame to remove events from
  26719. */
  26720. removeEvents(frame: number): void;
  26721. /**
  26722. * Retrieves all the events from the animation
  26723. * @returns Events from the animation
  26724. */
  26725. getEvents(): AnimationEvent[];
  26726. /**
  26727. * Creates an animation range
  26728. * @param name Name of the animation range
  26729. * @param from Starting frame of the animation range
  26730. * @param to Ending frame of the animation
  26731. */
  26732. createRange(name: string, from: number, to: number): void;
  26733. /**
  26734. * Deletes an animation range by name
  26735. * @param name Name of the animation range to delete
  26736. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26737. */
  26738. deleteRange(name: string, deleteFrames?: boolean): void;
  26739. /**
  26740. * Gets the animation range by name, or null if not defined
  26741. * @param name Name of the animation range
  26742. * @returns Nullable animation range
  26743. */
  26744. getRange(name: string): Nullable<AnimationRange>;
  26745. /**
  26746. * Gets the key frames from the animation
  26747. * @returns The key frames of the animation
  26748. */
  26749. getKeys(): Array<IAnimationKey>;
  26750. /**
  26751. * Gets the highest frame rate of the animation
  26752. * @returns Highest frame rate of the animation
  26753. */
  26754. getHighestFrame(): number;
  26755. /**
  26756. * Gets the easing function of the animation
  26757. * @returns Easing function of the animation
  26758. */
  26759. getEasingFunction(): IEasingFunction;
  26760. /**
  26761. * Sets the easing function of the animation
  26762. * @param easingFunction A custom mathematical formula for animation
  26763. */
  26764. setEasingFunction(easingFunction: EasingFunction): void;
  26765. /**
  26766. * Interpolates a scalar linearly
  26767. * @param startValue Start value of the animation curve
  26768. * @param endValue End value of the animation curve
  26769. * @param gradient Scalar amount to interpolate
  26770. * @returns Interpolated scalar value
  26771. */
  26772. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26773. /**
  26774. * Interpolates a scalar cubically
  26775. * @param startValue Start value of the animation curve
  26776. * @param outTangent End tangent of the animation
  26777. * @param endValue End value of the animation curve
  26778. * @param inTangent Start tangent of the animation curve
  26779. * @param gradient Scalar amount to interpolate
  26780. * @returns Interpolated scalar value
  26781. */
  26782. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26783. /**
  26784. * Interpolates a quaternion using a spherical linear interpolation
  26785. * @param startValue Start value of the animation curve
  26786. * @param endValue End value of the animation curve
  26787. * @param gradient Scalar amount to interpolate
  26788. * @returns Interpolated quaternion value
  26789. */
  26790. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26791. /**
  26792. * Interpolates a quaternion cubically
  26793. * @param startValue Start value of the animation curve
  26794. * @param outTangent End tangent of the animation curve
  26795. * @param endValue End value of the animation curve
  26796. * @param inTangent Start tangent of the animation curve
  26797. * @param gradient Scalar amount to interpolate
  26798. * @returns Interpolated quaternion value
  26799. */
  26800. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26801. /**
  26802. * Interpolates a Vector3 linearl
  26803. * @param startValue Start value of the animation curve
  26804. * @param endValue End value of the animation curve
  26805. * @param gradient Scalar amount to interpolate
  26806. * @returns Interpolated scalar value
  26807. */
  26808. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26809. /**
  26810. * Interpolates a Vector3 cubically
  26811. * @param startValue Start value of the animation curve
  26812. * @param outTangent End tangent of the animation
  26813. * @param endValue End value of the animation curve
  26814. * @param inTangent Start tangent of the animation curve
  26815. * @param gradient Scalar amount to interpolate
  26816. * @returns InterpolatedVector3 value
  26817. */
  26818. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26819. /**
  26820. * Interpolates a Vector2 linearly
  26821. * @param startValue Start value of the animation curve
  26822. * @param endValue End value of the animation curve
  26823. * @param gradient Scalar amount to interpolate
  26824. * @returns Interpolated Vector2 value
  26825. */
  26826. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26827. /**
  26828. * Interpolates a Vector2 cubically
  26829. * @param startValue Start value of the animation curve
  26830. * @param outTangent End tangent of the animation
  26831. * @param endValue End value of the animation curve
  26832. * @param inTangent Start tangent of the animation curve
  26833. * @param gradient Scalar amount to interpolate
  26834. * @returns Interpolated Vector2 value
  26835. */
  26836. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26837. /**
  26838. * Interpolates a size linearly
  26839. * @param startValue Start value of the animation curve
  26840. * @param endValue End value of the animation curve
  26841. * @param gradient Scalar amount to interpolate
  26842. * @returns Interpolated Size value
  26843. */
  26844. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26845. /**
  26846. * Interpolates a Color3 linearly
  26847. * @param startValue Start value of the animation curve
  26848. * @param endValue End value of the animation curve
  26849. * @param gradient Scalar amount to interpolate
  26850. * @returns Interpolated Color3 value
  26851. */
  26852. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26853. /**
  26854. * @hidden Internal use only
  26855. */
  26856. _getKeyValue(value: any): any;
  26857. /**
  26858. * @hidden Internal use only
  26859. */
  26860. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26861. /**
  26862. * Defines the function to use to interpolate matrices
  26863. * @param startValue defines the start matrix
  26864. * @param endValue defines the end matrix
  26865. * @param gradient defines the gradient between both matrices
  26866. * @param result defines an optional target matrix where to store the interpolation
  26867. * @returns the interpolated matrix
  26868. */
  26869. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26870. /**
  26871. * Makes a copy of the animation
  26872. * @returns Cloned animation
  26873. */
  26874. clone(): Animation;
  26875. /**
  26876. * Sets the key frames of the animation
  26877. * @param values The animation key frames to set
  26878. */
  26879. setKeys(values: Array<IAnimationKey>): void;
  26880. /**
  26881. * Serializes the animation to an object
  26882. * @returns Serialized object
  26883. */
  26884. serialize(): any;
  26885. /**
  26886. * Float animation type
  26887. */
  26888. private static _ANIMATIONTYPE_FLOAT;
  26889. /**
  26890. * Vector3 animation type
  26891. */
  26892. private static _ANIMATIONTYPE_VECTOR3;
  26893. /**
  26894. * Quaternion animation type
  26895. */
  26896. private static _ANIMATIONTYPE_QUATERNION;
  26897. /**
  26898. * Matrix animation type
  26899. */
  26900. private static _ANIMATIONTYPE_MATRIX;
  26901. /**
  26902. * Color3 animation type
  26903. */
  26904. private static _ANIMATIONTYPE_COLOR3;
  26905. /**
  26906. * Vector2 animation type
  26907. */
  26908. private static _ANIMATIONTYPE_VECTOR2;
  26909. /**
  26910. * Size animation type
  26911. */
  26912. private static _ANIMATIONTYPE_SIZE;
  26913. /**
  26914. * Relative Loop Mode
  26915. */
  26916. private static _ANIMATIONLOOPMODE_RELATIVE;
  26917. /**
  26918. * Cycle Loop Mode
  26919. */
  26920. private static _ANIMATIONLOOPMODE_CYCLE;
  26921. /**
  26922. * Constant Loop Mode
  26923. */
  26924. private static _ANIMATIONLOOPMODE_CONSTANT;
  26925. /**
  26926. * Get the float animation type
  26927. */
  26928. static readonly ANIMATIONTYPE_FLOAT: number;
  26929. /**
  26930. * Get the Vector3 animation type
  26931. */
  26932. static readonly ANIMATIONTYPE_VECTOR3: number;
  26933. /**
  26934. * Get the Vector2 animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_VECTOR2: number;
  26937. /**
  26938. * Get the Size animation type
  26939. */
  26940. static readonly ANIMATIONTYPE_SIZE: number;
  26941. /**
  26942. * Get the Quaternion animation type
  26943. */
  26944. static readonly ANIMATIONTYPE_QUATERNION: number;
  26945. /**
  26946. * Get the Matrix animation type
  26947. */
  26948. static readonly ANIMATIONTYPE_MATRIX: number;
  26949. /**
  26950. * Get the Color3 animation type
  26951. */
  26952. static readonly ANIMATIONTYPE_COLOR3: number;
  26953. /**
  26954. * Get the Relative Loop Mode
  26955. */
  26956. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26957. /**
  26958. * Get the Cycle Loop Mode
  26959. */
  26960. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26961. /**
  26962. * Get the Constant Loop Mode
  26963. */
  26964. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26965. /** @hidden */
  26966. static _UniversalLerp(left: any, right: any, amount: number): any;
  26967. /**
  26968. * Parses an animation object and creates an animation
  26969. * @param parsedAnimation Parsed animation object
  26970. * @returns Animation object
  26971. */
  26972. static Parse(parsedAnimation: any): Animation;
  26973. /**
  26974. * Appends the serialized animations from the source animations
  26975. * @param source Source containing the animations
  26976. * @param destination Target to store the animations
  26977. */
  26978. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26979. }
  26980. }
  26981. declare module "babylonjs/Materials/Textures/baseTexture" {
  26982. import { Observable } from "babylonjs/Misc/observable";
  26983. import { IAnimatable } from "babylonjs/Misc/tools";
  26984. import { Nullable } from "babylonjs/types";
  26985. import { Scene } from "babylonjs/scene";
  26986. import { Matrix, ISize } from "babylonjs/Maths/math";
  26987. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26989. /**
  26990. * Base class of all the textures in babylon.
  26991. * It groups all the common properties the materials, post process, lights... might need
  26992. * in order to make a correct use of the texture.
  26993. */
  26994. export class BaseTexture implements IAnimatable {
  26995. /**
  26996. * Default anisotropic filtering level for the application.
  26997. * It is set to 4 as a good tradeoff between perf and quality.
  26998. */
  26999. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27000. /**
  27001. * Gets or sets the unique id of the texture
  27002. */
  27003. uniqueId: number;
  27004. /**
  27005. * Define the name of the texture.
  27006. */
  27007. name: string;
  27008. /**
  27009. * Gets or sets an object used to store user defined information.
  27010. */
  27011. metadata: any;
  27012. /**
  27013. * For internal use only. Please do not use.
  27014. */
  27015. reservedDataStore: any;
  27016. private _hasAlpha;
  27017. /**
  27018. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27019. */
  27020. hasAlpha: boolean;
  27021. /**
  27022. * Defines if the alpha value should be determined via the rgb values.
  27023. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27024. */
  27025. getAlphaFromRGB: boolean;
  27026. /**
  27027. * Intensity or strength of the texture.
  27028. * It is commonly used by materials to fine tune the intensity of the texture
  27029. */
  27030. level: number;
  27031. /**
  27032. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27033. * This is part of the texture as textures usually maps to one uv set.
  27034. */
  27035. coordinatesIndex: number;
  27036. private _coordinatesMode;
  27037. /**
  27038. * How a texture is mapped.
  27039. *
  27040. * | Value | Type | Description |
  27041. * | ----- | ----------------------------------- | ----------- |
  27042. * | 0 | EXPLICIT_MODE | |
  27043. * | 1 | SPHERICAL_MODE | |
  27044. * | 2 | PLANAR_MODE | |
  27045. * | 3 | CUBIC_MODE | |
  27046. * | 4 | PROJECTION_MODE | |
  27047. * | 5 | SKYBOX_MODE | |
  27048. * | 6 | INVCUBIC_MODE | |
  27049. * | 7 | EQUIRECTANGULAR_MODE | |
  27050. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27051. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27052. */
  27053. coordinatesMode: number;
  27054. /**
  27055. * | Value | Type | Description |
  27056. * | ----- | ------------------ | ----------- |
  27057. * | 0 | CLAMP_ADDRESSMODE | |
  27058. * | 1 | WRAP_ADDRESSMODE | |
  27059. * | 2 | MIRROR_ADDRESSMODE | |
  27060. */
  27061. wrapU: number;
  27062. /**
  27063. * | Value | Type | Description |
  27064. * | ----- | ------------------ | ----------- |
  27065. * | 0 | CLAMP_ADDRESSMODE | |
  27066. * | 1 | WRAP_ADDRESSMODE | |
  27067. * | 2 | MIRROR_ADDRESSMODE | |
  27068. */
  27069. wrapV: number;
  27070. /**
  27071. * | Value | Type | Description |
  27072. * | ----- | ------------------ | ----------- |
  27073. * | 0 | CLAMP_ADDRESSMODE | |
  27074. * | 1 | WRAP_ADDRESSMODE | |
  27075. * | 2 | MIRROR_ADDRESSMODE | |
  27076. */
  27077. wrapR: number;
  27078. /**
  27079. * With compliant hardware and browser (supporting anisotropic filtering)
  27080. * this defines the level of anisotropic filtering in the texture.
  27081. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27082. */
  27083. anisotropicFilteringLevel: number;
  27084. /**
  27085. * Define if the texture is a cube texture or if false a 2d texture.
  27086. */
  27087. isCube: boolean;
  27088. /**
  27089. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27090. */
  27091. is3D: boolean;
  27092. /**
  27093. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27094. * HDR texture are usually stored in linear space.
  27095. * This only impacts the PBR and Background materials
  27096. */
  27097. gammaSpace: boolean;
  27098. /**
  27099. * Gets whether or not the texture contains RGBD data.
  27100. */
  27101. readonly isRGBD: boolean;
  27102. /**
  27103. * Is Z inverted in the texture (useful in a cube texture).
  27104. */
  27105. invertZ: boolean;
  27106. /**
  27107. * Are mip maps generated for this texture or not.
  27108. */
  27109. readonly noMipmap: boolean;
  27110. /**
  27111. * @hidden
  27112. */
  27113. lodLevelInAlpha: boolean;
  27114. /**
  27115. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27116. */
  27117. lodGenerationOffset: number;
  27118. /**
  27119. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27120. */
  27121. lodGenerationScale: number;
  27122. /**
  27123. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27124. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27125. * average roughness values.
  27126. */
  27127. linearSpecularLOD: boolean;
  27128. /**
  27129. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27130. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27131. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27132. */
  27133. irradianceTexture: Nullable<BaseTexture>;
  27134. /**
  27135. * Define if the texture is a render target.
  27136. */
  27137. isRenderTarget: boolean;
  27138. /**
  27139. * Define the unique id of the texture in the scene.
  27140. */
  27141. readonly uid: string;
  27142. /**
  27143. * Return a string representation of the texture.
  27144. * @returns the texture as a string
  27145. */
  27146. toString(): string;
  27147. /**
  27148. * Get the class name of the texture.
  27149. * @returns "BaseTexture"
  27150. */
  27151. getClassName(): string;
  27152. /**
  27153. * Define the list of animation attached to the texture.
  27154. */
  27155. animations: import("babylonjs/Animations/animation").Animation[];
  27156. /**
  27157. * An event triggered when the texture is disposed.
  27158. */
  27159. onDisposeObservable: Observable<BaseTexture>;
  27160. private _onDisposeObserver;
  27161. /**
  27162. * Callback triggered when the texture has been disposed.
  27163. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27164. */
  27165. onDispose: () => void;
  27166. /**
  27167. * Define the current state of the loading sequence when in delayed load mode.
  27168. */
  27169. delayLoadState: number;
  27170. private _scene;
  27171. /** @hidden */
  27172. _texture: Nullable<InternalTexture>;
  27173. private _uid;
  27174. /**
  27175. * Define if the texture is preventinga material to render or not.
  27176. * If not and the texture is not ready, the engine will use a default black texture instead.
  27177. */
  27178. readonly isBlocking: boolean;
  27179. /**
  27180. * Instantiates a new BaseTexture.
  27181. * Base class of all the textures in babylon.
  27182. * It groups all the common properties the materials, post process, lights... might need
  27183. * in order to make a correct use of the texture.
  27184. * @param scene Define the scene the texture blongs to
  27185. */
  27186. constructor(scene: Nullable<Scene>);
  27187. /**
  27188. * Get the scene the texture belongs to.
  27189. * @returns the scene or null if undefined
  27190. */
  27191. getScene(): Nullable<Scene>;
  27192. /**
  27193. * Get the texture transform matrix used to offset tile the texture for istance.
  27194. * @returns the transformation matrix
  27195. */
  27196. getTextureMatrix(): Matrix;
  27197. /**
  27198. * Get the texture reflection matrix used to rotate/transform the reflection.
  27199. * @returns the reflection matrix
  27200. */
  27201. getReflectionTextureMatrix(): Matrix;
  27202. /**
  27203. * Get the underlying lower level texture from Babylon.
  27204. * @returns the insternal texture
  27205. */
  27206. getInternalTexture(): Nullable<InternalTexture>;
  27207. /**
  27208. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27209. * @returns true if ready or not blocking
  27210. */
  27211. isReadyOrNotBlocking(): boolean;
  27212. /**
  27213. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27214. * @returns true if fully ready
  27215. */
  27216. isReady(): boolean;
  27217. private _cachedSize;
  27218. /**
  27219. * Get the size of the texture.
  27220. * @returns the texture size.
  27221. */
  27222. getSize(): ISize;
  27223. /**
  27224. * Get the base size of the texture.
  27225. * It can be different from the size if the texture has been resized for POT for instance
  27226. * @returns the base size
  27227. */
  27228. getBaseSize(): ISize;
  27229. /**
  27230. * Update the sampling mode of the texture.
  27231. * Default is Trilinear mode.
  27232. *
  27233. * | Value | Type | Description |
  27234. * | ----- | ------------------ | ----------- |
  27235. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27236. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27237. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27238. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27239. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27240. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27241. * | 7 | NEAREST_LINEAR | |
  27242. * | 8 | NEAREST_NEAREST | |
  27243. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27244. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27245. * | 11 | LINEAR_LINEAR | |
  27246. * | 12 | LINEAR_NEAREST | |
  27247. *
  27248. * > _mag_: magnification filter (close to the viewer)
  27249. * > _min_: minification filter (far from the viewer)
  27250. * > _mip_: filter used between mip map levels
  27251. *@param samplingMode Define the new sampling mode of the texture
  27252. */
  27253. updateSamplingMode(samplingMode: number): void;
  27254. /**
  27255. * Scales the texture if is `canRescale()`
  27256. * @param ratio the resize factor we want to use to rescale
  27257. */
  27258. scale(ratio: number): void;
  27259. /**
  27260. * Get if the texture can rescale.
  27261. */
  27262. readonly canRescale: boolean;
  27263. /** @hidden */
  27264. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27265. /** @hidden */
  27266. _rebuild(): void;
  27267. /**
  27268. * Triggers the load sequence in delayed load mode.
  27269. */
  27270. delayLoad(): void;
  27271. /**
  27272. * Clones the texture.
  27273. * @returns the cloned texture
  27274. */
  27275. clone(): Nullable<BaseTexture>;
  27276. /**
  27277. * Get the texture underlying type (INT, FLOAT...)
  27278. */
  27279. readonly textureType: number;
  27280. /**
  27281. * Get the texture underlying format (RGB, RGBA...)
  27282. */
  27283. readonly textureFormat: number;
  27284. /**
  27285. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27286. * This will returns an RGBA array buffer containing either in values (0-255) or
  27287. * float values (0-1) depending of the underlying buffer type.
  27288. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27289. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27290. * @param buffer defines a user defined buffer to fill with data (can be null)
  27291. * @returns The Array buffer containing the pixels data.
  27292. */
  27293. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27294. /**
  27295. * Release and destroy the underlying lower level texture aka internalTexture.
  27296. */
  27297. releaseInternalTexture(): void;
  27298. /**
  27299. * Get the polynomial representation of the texture data.
  27300. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27301. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27302. */
  27303. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27304. /** @hidden */
  27305. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27306. /** @hidden */
  27307. readonly _lodTextureMid: Nullable<BaseTexture>;
  27308. /** @hidden */
  27309. readonly _lodTextureLow: Nullable<BaseTexture>;
  27310. /**
  27311. * Dispose the texture and release its associated resources.
  27312. */
  27313. dispose(): void;
  27314. /**
  27315. * Serialize the texture into a JSON representation that can be parsed later on.
  27316. * @returns the JSON representation of the texture
  27317. */
  27318. serialize(): any;
  27319. /**
  27320. * Helper function to be called back once a list of texture contains only ready textures.
  27321. * @param textures Define the list of textures to wait for
  27322. * @param callback Define the callback triggered once the entire list will be ready
  27323. */
  27324. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27325. }
  27326. }
  27327. declare module "babylonjs/Materials/uniformBuffer" {
  27328. import { Nullable, FloatArray } from "babylonjs/types";
  27329. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27330. import { Engine } from "babylonjs/Engines/engine";
  27331. import { Effect } from "babylonjs/Materials/effect";
  27332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27334. /**
  27335. * Uniform buffer objects.
  27336. *
  27337. * Handles blocks of uniform on the GPU.
  27338. *
  27339. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27340. *
  27341. * For more information, please refer to :
  27342. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27343. */
  27344. export class UniformBuffer {
  27345. private _engine;
  27346. private _buffer;
  27347. private _data;
  27348. private _bufferData;
  27349. private _dynamic?;
  27350. private _uniformLocations;
  27351. private _uniformSizes;
  27352. private _uniformLocationPointer;
  27353. private _needSync;
  27354. private _noUBO;
  27355. private _currentEffect;
  27356. private static _MAX_UNIFORM_SIZE;
  27357. private static _tempBuffer;
  27358. /**
  27359. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27360. * This is dynamic to allow compat with webgl 1 and 2.
  27361. * You will need to pass the name of the uniform as well as the value.
  27362. */
  27363. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27364. /**
  27365. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27366. * This is dynamic to allow compat with webgl 1 and 2.
  27367. * You will need to pass the name of the uniform as well as the value.
  27368. */
  27369. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27370. /**
  27371. * Lambda to Update a single float in a uniform buffer.
  27372. * This is dynamic to allow compat with webgl 1 and 2.
  27373. * You will need to pass the name of the uniform as well as the value.
  27374. */
  27375. updateFloat: (name: string, x: number) => void;
  27376. /**
  27377. * Lambda to Update a vec2 of float in a uniform buffer.
  27378. * This is dynamic to allow compat with webgl 1 and 2.
  27379. * You will need to pass the name of the uniform as well as the value.
  27380. */
  27381. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27382. /**
  27383. * Lambda to Update a vec3 of float in a uniform buffer.
  27384. * This is dynamic to allow compat with webgl 1 and 2.
  27385. * You will need to pass the name of the uniform as well as the value.
  27386. */
  27387. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27388. /**
  27389. * Lambda to Update a vec4 of float in a uniform buffer.
  27390. * This is dynamic to allow compat with webgl 1 and 2.
  27391. * You will need to pass the name of the uniform as well as the value.
  27392. */
  27393. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27394. /**
  27395. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27396. * This is dynamic to allow compat with webgl 1 and 2.
  27397. * You will need to pass the name of the uniform as well as the value.
  27398. */
  27399. updateMatrix: (name: string, mat: Matrix) => void;
  27400. /**
  27401. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27402. * This is dynamic to allow compat with webgl 1 and 2.
  27403. * You will need to pass the name of the uniform as well as the value.
  27404. */
  27405. updateVector3: (name: string, vector: Vector3) => void;
  27406. /**
  27407. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27408. * This is dynamic to allow compat with webgl 1 and 2.
  27409. * You will need to pass the name of the uniform as well as the value.
  27410. */
  27411. updateVector4: (name: string, vector: Vector4) => void;
  27412. /**
  27413. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27414. * This is dynamic to allow compat with webgl 1 and 2.
  27415. * You will need to pass the name of the uniform as well as the value.
  27416. */
  27417. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27418. /**
  27419. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27420. * This is dynamic to allow compat with webgl 1 and 2.
  27421. * You will need to pass the name of the uniform as well as the value.
  27422. */
  27423. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27424. /**
  27425. * Instantiates a new Uniform buffer objects.
  27426. *
  27427. * Handles blocks of uniform on the GPU.
  27428. *
  27429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27430. *
  27431. * For more information, please refer to :
  27432. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27433. * @param engine Define the engine the buffer is associated with
  27434. * @param data Define the data contained in the buffer
  27435. * @param dynamic Define if the buffer is updatable
  27436. */
  27437. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27438. /**
  27439. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27440. * or just falling back on setUniformXXX calls.
  27441. */
  27442. readonly useUbo: boolean;
  27443. /**
  27444. * Indicates if the WebGL underlying uniform buffer is in sync
  27445. * with the javascript cache data.
  27446. */
  27447. readonly isSync: boolean;
  27448. /**
  27449. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27450. * Also, a dynamic UniformBuffer will disable cache verification and always
  27451. * update the underlying WebGL uniform buffer to the GPU.
  27452. * @returns if Dynamic, otherwise false
  27453. */
  27454. isDynamic(): boolean;
  27455. /**
  27456. * The data cache on JS side.
  27457. * @returns the underlying data as a float array
  27458. */
  27459. getData(): Float32Array;
  27460. /**
  27461. * The underlying WebGL Uniform buffer.
  27462. * @returns the webgl buffer
  27463. */
  27464. getBuffer(): Nullable<DataBuffer>;
  27465. /**
  27466. * std140 layout specifies how to align data within an UBO structure.
  27467. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27468. * for specs.
  27469. */
  27470. private _fillAlignment;
  27471. /**
  27472. * Adds an uniform in the buffer.
  27473. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27474. * for the layout to be correct !
  27475. * @param name Name of the uniform, as used in the uniform block in the shader.
  27476. * @param size Data size, or data directly.
  27477. */
  27478. addUniform(name: string, size: number | number[]): void;
  27479. /**
  27480. * Adds a Matrix 4x4 to the uniform buffer.
  27481. * @param name Name of the uniform, as used in the uniform block in the shader.
  27482. * @param mat A 4x4 matrix.
  27483. */
  27484. addMatrix(name: string, mat: Matrix): void;
  27485. /**
  27486. * Adds a vec2 to the uniform buffer.
  27487. * @param name Name of the uniform, as used in the uniform block in the shader.
  27488. * @param x Define the x component value of the vec2
  27489. * @param y Define the y component value of the vec2
  27490. */
  27491. addFloat2(name: string, x: number, y: number): void;
  27492. /**
  27493. * Adds a vec3 to the uniform buffer.
  27494. * @param name Name of the uniform, as used in the uniform block in the shader.
  27495. * @param x Define the x component value of the vec3
  27496. * @param y Define the y component value of the vec3
  27497. * @param z Define the z component value of the vec3
  27498. */
  27499. addFloat3(name: string, x: number, y: number, z: number): void;
  27500. /**
  27501. * Adds a vec3 to the uniform buffer.
  27502. * @param name Name of the uniform, as used in the uniform block in the shader.
  27503. * @param color Define the vec3 from a Color
  27504. */
  27505. addColor3(name: string, color: Color3): void;
  27506. /**
  27507. * Adds a vec4 to the uniform buffer.
  27508. * @param name Name of the uniform, as used in the uniform block in the shader.
  27509. * @param color Define the rgb components from a Color
  27510. * @param alpha Define the a component of the vec4
  27511. */
  27512. addColor4(name: string, color: Color3, alpha: number): void;
  27513. /**
  27514. * Adds a vec3 to the uniform buffer.
  27515. * @param name Name of the uniform, as used in the uniform block in the shader.
  27516. * @param vector Define the vec3 components from a Vector
  27517. */
  27518. addVector3(name: string, vector: Vector3): void;
  27519. /**
  27520. * Adds a Matrix 3x3 to the uniform buffer.
  27521. * @param name Name of the uniform, as used in the uniform block in the shader.
  27522. */
  27523. addMatrix3x3(name: string): void;
  27524. /**
  27525. * Adds a Matrix 2x2 to the uniform buffer.
  27526. * @param name Name of the uniform, as used in the uniform block in the shader.
  27527. */
  27528. addMatrix2x2(name: string): void;
  27529. /**
  27530. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27531. */
  27532. create(): void;
  27533. /** @hidden */
  27534. _rebuild(): void;
  27535. /**
  27536. * Updates the WebGL Uniform Buffer on the GPU.
  27537. * If the `dynamic` flag is set to true, no cache comparison is done.
  27538. * Otherwise, the buffer will be updated only if the cache differs.
  27539. */
  27540. update(): void;
  27541. /**
  27542. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27543. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27544. * @param data Define the flattened data
  27545. * @param size Define the size of the data.
  27546. */
  27547. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27548. private _updateMatrix3x3ForUniform;
  27549. private _updateMatrix3x3ForEffect;
  27550. private _updateMatrix2x2ForEffect;
  27551. private _updateMatrix2x2ForUniform;
  27552. private _updateFloatForEffect;
  27553. private _updateFloatForUniform;
  27554. private _updateFloat2ForEffect;
  27555. private _updateFloat2ForUniform;
  27556. private _updateFloat3ForEffect;
  27557. private _updateFloat3ForUniform;
  27558. private _updateFloat4ForEffect;
  27559. private _updateFloat4ForUniform;
  27560. private _updateMatrixForEffect;
  27561. private _updateMatrixForUniform;
  27562. private _updateVector3ForEffect;
  27563. private _updateVector3ForUniform;
  27564. private _updateVector4ForEffect;
  27565. private _updateVector4ForUniform;
  27566. private _updateColor3ForEffect;
  27567. private _updateColor3ForUniform;
  27568. private _updateColor4ForEffect;
  27569. private _updateColor4ForUniform;
  27570. /**
  27571. * Sets a sampler uniform on the effect.
  27572. * @param name Define the name of the sampler.
  27573. * @param texture Define the texture to set in the sampler
  27574. */
  27575. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27576. /**
  27577. * Directly updates the value of the uniform in the cache AND on the GPU.
  27578. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27579. * @param data Define the flattened data
  27580. */
  27581. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27582. /**
  27583. * Binds this uniform buffer to an effect.
  27584. * @param effect Define the effect to bind the buffer to
  27585. * @param name Name of the uniform block in the shader.
  27586. */
  27587. bindToEffect(effect: Effect, name: string): void;
  27588. /**
  27589. * Disposes the uniform buffer.
  27590. */
  27591. dispose(): void;
  27592. }
  27593. }
  27594. declare module "babylonjs/Audio/analyser" {
  27595. import { Scene } from "babylonjs/scene";
  27596. /**
  27597. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27599. */
  27600. export class Analyser {
  27601. /**
  27602. * Gets or sets the smoothing
  27603. * @ignorenaming
  27604. */
  27605. SMOOTHING: number;
  27606. /**
  27607. * Gets or sets the FFT table size
  27608. * @ignorenaming
  27609. */
  27610. FFT_SIZE: number;
  27611. /**
  27612. * Gets or sets the bar graph amplitude
  27613. * @ignorenaming
  27614. */
  27615. BARGRAPHAMPLITUDE: number;
  27616. /**
  27617. * Gets or sets the position of the debug canvas
  27618. * @ignorenaming
  27619. */
  27620. DEBUGCANVASPOS: {
  27621. x: number;
  27622. y: number;
  27623. };
  27624. /**
  27625. * Gets or sets the debug canvas size
  27626. * @ignorenaming
  27627. */
  27628. DEBUGCANVASSIZE: {
  27629. width: number;
  27630. height: number;
  27631. };
  27632. private _byteFreqs;
  27633. private _byteTime;
  27634. private _floatFreqs;
  27635. private _webAudioAnalyser;
  27636. private _debugCanvas;
  27637. private _debugCanvasContext;
  27638. private _scene;
  27639. private _registerFunc;
  27640. private _audioEngine;
  27641. /**
  27642. * Creates a new analyser
  27643. * @param scene defines hosting scene
  27644. */
  27645. constructor(scene: Scene);
  27646. /**
  27647. * Get the number of data values you will have to play with for the visualization
  27648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27649. * @returns a number
  27650. */
  27651. getFrequencyBinCount(): number;
  27652. /**
  27653. * Gets the current frequency data as a byte array
  27654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27655. * @returns a Uint8Array
  27656. */
  27657. getByteFrequencyData(): Uint8Array;
  27658. /**
  27659. * Gets the current waveform as a byte array
  27660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27661. * @returns a Uint8Array
  27662. */
  27663. getByteTimeDomainData(): Uint8Array;
  27664. /**
  27665. * Gets the current frequency data as a float array
  27666. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27667. * @returns a Float32Array
  27668. */
  27669. getFloatFrequencyData(): Float32Array;
  27670. /**
  27671. * Renders the debug canvas
  27672. */
  27673. drawDebugCanvas(): void;
  27674. /**
  27675. * Stops rendering the debug canvas and removes it
  27676. */
  27677. stopDebugCanvas(): void;
  27678. /**
  27679. * Connects two audio nodes
  27680. * @param inputAudioNode defines first node to connect
  27681. * @param outputAudioNode defines second node to connect
  27682. */
  27683. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27684. /**
  27685. * Releases all associated resources
  27686. */
  27687. dispose(): void;
  27688. }
  27689. }
  27690. declare module "babylonjs/Audio/audioEngine" {
  27691. import { IDisposable } from "babylonjs/scene";
  27692. import { Analyser } from "babylonjs/Audio/analyser";
  27693. import { Nullable } from "babylonjs/types";
  27694. import { Observable } from "babylonjs/Misc/observable";
  27695. /**
  27696. * This represents an audio engine and it is responsible
  27697. * to play, synchronize and analyse sounds throughout the application.
  27698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27699. */
  27700. export interface IAudioEngine extends IDisposable {
  27701. /**
  27702. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27703. */
  27704. readonly canUseWebAudio: boolean;
  27705. /**
  27706. * Gets the current AudioContext if available.
  27707. */
  27708. readonly audioContext: Nullable<AudioContext>;
  27709. /**
  27710. * The master gain node defines the global audio volume of your audio engine.
  27711. */
  27712. readonly masterGain: GainNode;
  27713. /**
  27714. * Gets whether or not mp3 are supported by your browser.
  27715. */
  27716. readonly isMP3supported: boolean;
  27717. /**
  27718. * Gets whether or not ogg are supported by your browser.
  27719. */
  27720. readonly isOGGsupported: boolean;
  27721. /**
  27722. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27723. * @ignoreNaming
  27724. */
  27725. WarnedWebAudioUnsupported: boolean;
  27726. /**
  27727. * Defines if the audio engine relies on a custom unlocked button.
  27728. * In this case, the embedded button will not be displayed.
  27729. */
  27730. useCustomUnlockedButton: boolean;
  27731. /**
  27732. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27733. */
  27734. readonly unlocked: boolean;
  27735. /**
  27736. * Event raised when audio has been unlocked on the browser.
  27737. */
  27738. onAudioUnlockedObservable: Observable<AudioEngine>;
  27739. /**
  27740. * Event raised when audio has been locked on the browser.
  27741. */
  27742. onAudioLockedObservable: Observable<AudioEngine>;
  27743. /**
  27744. * Flags the audio engine in Locked state.
  27745. * This happens due to new browser policies preventing audio to autoplay.
  27746. */
  27747. lock(): void;
  27748. /**
  27749. * Unlocks the audio engine once a user action has been done on the dom.
  27750. * This is helpful to resume play once browser policies have been satisfied.
  27751. */
  27752. unlock(): void;
  27753. }
  27754. /**
  27755. * This represents the default audio engine used in babylon.
  27756. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27758. */
  27759. export class AudioEngine implements IAudioEngine {
  27760. private _audioContext;
  27761. private _audioContextInitialized;
  27762. private _muteButton;
  27763. private _hostElement;
  27764. /**
  27765. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27766. */
  27767. canUseWebAudio: boolean;
  27768. /**
  27769. * The master gain node defines the global audio volume of your audio engine.
  27770. */
  27771. masterGain: GainNode;
  27772. /**
  27773. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27774. * @ignoreNaming
  27775. */
  27776. WarnedWebAudioUnsupported: boolean;
  27777. /**
  27778. * Gets whether or not mp3 are supported by your browser.
  27779. */
  27780. isMP3supported: boolean;
  27781. /**
  27782. * Gets whether or not ogg are supported by your browser.
  27783. */
  27784. isOGGsupported: boolean;
  27785. /**
  27786. * Gets whether audio has been unlocked on the device.
  27787. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27788. * a user interaction has happened.
  27789. */
  27790. unlocked: boolean;
  27791. /**
  27792. * Defines if the audio engine relies on a custom unlocked button.
  27793. * In this case, the embedded button will not be displayed.
  27794. */
  27795. useCustomUnlockedButton: boolean;
  27796. /**
  27797. * Event raised when audio has been unlocked on the browser.
  27798. */
  27799. onAudioUnlockedObservable: Observable<AudioEngine>;
  27800. /**
  27801. * Event raised when audio has been locked on the browser.
  27802. */
  27803. onAudioLockedObservable: Observable<AudioEngine>;
  27804. /**
  27805. * Gets the current AudioContext if available.
  27806. */
  27807. readonly audioContext: Nullable<AudioContext>;
  27808. private _connectedAnalyser;
  27809. /**
  27810. * Instantiates a new audio engine.
  27811. *
  27812. * There should be only one per page as some browsers restrict the number
  27813. * of audio contexts you can create.
  27814. * @param hostElement defines the host element where to display the mute icon if necessary
  27815. */
  27816. constructor(hostElement?: Nullable<HTMLElement>);
  27817. /**
  27818. * Flags the audio engine in Locked state.
  27819. * This happens due to new browser policies preventing audio to autoplay.
  27820. */
  27821. lock(): void;
  27822. /**
  27823. * Unlocks the audio engine once a user action has been done on the dom.
  27824. * This is helpful to resume play once browser policies have been satisfied.
  27825. */
  27826. unlock(): void;
  27827. private _resumeAudioContext;
  27828. private _initializeAudioContext;
  27829. private _tryToRun;
  27830. private _triggerRunningState;
  27831. private _triggerSuspendedState;
  27832. private _displayMuteButton;
  27833. private _moveButtonToTopLeft;
  27834. private _onResize;
  27835. private _hideMuteButton;
  27836. /**
  27837. * Destroy and release the resources associated with the audio ccontext.
  27838. */
  27839. dispose(): void;
  27840. /**
  27841. * Gets the global volume sets on the master gain.
  27842. * @returns the global volume if set or -1 otherwise
  27843. */
  27844. getGlobalVolume(): number;
  27845. /**
  27846. * Sets the global volume of your experience (sets on the master gain).
  27847. * @param newVolume Defines the new global volume of the application
  27848. */
  27849. setGlobalVolume(newVolume: number): void;
  27850. /**
  27851. * Connect the audio engine to an audio analyser allowing some amazing
  27852. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27854. * @param analyser The analyser to connect to the engine
  27855. */
  27856. connectToAnalyser(analyser: Analyser): void;
  27857. }
  27858. }
  27859. declare module "babylonjs/Loading/loadingScreen" {
  27860. /**
  27861. * Interface used to present a loading screen while loading a scene
  27862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27863. */
  27864. export interface ILoadingScreen {
  27865. /**
  27866. * Function called to display the loading screen
  27867. */
  27868. displayLoadingUI: () => void;
  27869. /**
  27870. * Function called to hide the loading screen
  27871. */
  27872. hideLoadingUI: () => void;
  27873. /**
  27874. * Gets or sets the color to use for the background
  27875. */
  27876. loadingUIBackgroundColor: string;
  27877. /**
  27878. * Gets or sets the text to display while loading
  27879. */
  27880. loadingUIText: string;
  27881. }
  27882. /**
  27883. * Class used for the default loading screen
  27884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27885. */
  27886. export class DefaultLoadingScreen implements ILoadingScreen {
  27887. private _renderingCanvas;
  27888. private _loadingText;
  27889. private _loadingDivBackgroundColor;
  27890. private _loadingDiv;
  27891. private _loadingTextDiv;
  27892. /** Gets or sets the logo url to use for the default loading screen */
  27893. static DefaultLogoUrl: string;
  27894. /** Gets or sets the spinner url to use for the default loading screen */
  27895. static DefaultSpinnerUrl: string;
  27896. /**
  27897. * Creates a new default loading screen
  27898. * @param _renderingCanvas defines the canvas used to render the scene
  27899. * @param _loadingText defines the default text to display
  27900. * @param _loadingDivBackgroundColor defines the default background color
  27901. */
  27902. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27903. /**
  27904. * Function called to display the loading screen
  27905. */
  27906. displayLoadingUI(): void;
  27907. /**
  27908. * Function called to hide the loading screen
  27909. */
  27910. hideLoadingUI(): void;
  27911. /**
  27912. * Gets or sets the text to display while loading
  27913. */
  27914. loadingUIText: string;
  27915. /**
  27916. * Gets or sets the color to use for the background
  27917. */
  27918. loadingUIBackgroundColor: string;
  27919. private _resizeLoadingUI;
  27920. }
  27921. }
  27922. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27923. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27924. import { Engine } from "babylonjs/Engines/engine";
  27925. import { Nullable } from "babylonjs/types";
  27926. /** @hidden */
  27927. export class WebGLPipelineContext implements IPipelineContext {
  27928. engine: Engine;
  27929. program: Nullable<WebGLProgram>;
  27930. context?: WebGLRenderingContext;
  27931. vertexShader?: WebGLShader;
  27932. fragmentShader?: WebGLShader;
  27933. isParallelCompiled: boolean;
  27934. onCompiled?: () => void;
  27935. transformFeedback?: WebGLTransformFeedback | null;
  27936. readonly isAsync: boolean;
  27937. readonly isReady: boolean;
  27938. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27939. }
  27940. }
  27941. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27942. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27943. /** @hidden */
  27944. export class WebGLDataBuffer extends DataBuffer {
  27945. private _buffer;
  27946. constructor(resource: WebGLBuffer);
  27947. readonly underlyingResource: any;
  27948. }
  27949. }
  27950. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27951. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27952. /** @hidden */
  27953. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27954. attributeProcessor(attribute: string): string;
  27955. varyingProcessor(varying: string, isFragment: boolean): string;
  27956. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27957. }
  27958. }
  27959. declare module "babylonjs/Materials/Textures/videoTexture" {
  27960. import { Observable } from "babylonjs/Misc/observable";
  27961. import { Nullable } from "babylonjs/types";
  27962. import { Scene } from "babylonjs/scene";
  27963. import { Texture } from "babylonjs/Materials/Textures/texture";
  27964. /**
  27965. * Settings for finer control over video usage
  27966. */
  27967. export interface VideoTextureSettings {
  27968. /**
  27969. * Applies `autoplay` to video, if specified
  27970. */
  27971. autoPlay?: boolean;
  27972. /**
  27973. * Applies `loop` to video, if specified
  27974. */
  27975. loop?: boolean;
  27976. /**
  27977. * Automatically updates internal texture from video at every frame in the render loop
  27978. */
  27979. autoUpdateTexture: boolean;
  27980. /**
  27981. * Image src displayed during the video loading or until the user interacts with the video.
  27982. */
  27983. poster?: string;
  27984. }
  27985. /**
  27986. * If you want to display a video in your scene, this is the special texture for that.
  27987. * This special texture works similar to other textures, with the exception of a few parameters.
  27988. * @see https://doc.babylonjs.com/how_to/video_texture
  27989. */
  27990. export class VideoTexture extends Texture {
  27991. /**
  27992. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27993. */
  27994. readonly autoUpdateTexture: boolean;
  27995. /**
  27996. * The video instance used by the texture internally
  27997. */
  27998. readonly video: HTMLVideoElement;
  27999. private _onUserActionRequestedObservable;
  28000. /**
  28001. * Event triggerd when a dom action is required by the user to play the video.
  28002. * This happens due to recent changes in browser policies preventing video to auto start.
  28003. */
  28004. readonly onUserActionRequestedObservable: Observable<Texture>;
  28005. private _generateMipMaps;
  28006. private _engine;
  28007. private _stillImageCaptured;
  28008. private _displayingPosterTexture;
  28009. private _settings;
  28010. private _createInternalTextureOnEvent;
  28011. /**
  28012. * Creates a video texture.
  28013. * If you want to display a video in your scene, this is the special texture for that.
  28014. * This special texture works similar to other textures, with the exception of a few parameters.
  28015. * @see https://doc.babylonjs.com/how_to/video_texture
  28016. * @param name optional name, will detect from video source, if not defined
  28017. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28018. * @param scene is obviously the current scene.
  28019. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28020. * @param invertY is false by default but can be used to invert video on Y axis
  28021. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28022. * @param settings allows finer control over video usage
  28023. */
  28024. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28025. private _getName;
  28026. private _getVideo;
  28027. private _createInternalTexture;
  28028. private reset;
  28029. /**
  28030. * @hidden Internal method to initiate `update`.
  28031. */
  28032. _rebuild(): void;
  28033. /**
  28034. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28035. */
  28036. update(): void;
  28037. /**
  28038. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28039. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28040. */
  28041. updateTexture(isVisible: boolean): void;
  28042. protected _updateInternalTexture: () => void;
  28043. /**
  28044. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28045. * @param url New url.
  28046. */
  28047. updateURL(url: string): void;
  28048. /**
  28049. * Dispose the texture and release its associated resources.
  28050. */
  28051. dispose(): void;
  28052. /**
  28053. * Creates a video texture straight from a stream.
  28054. * @param scene Define the scene the texture should be created in
  28055. * @param stream Define the stream the texture should be created from
  28056. * @returns The created video texture as a promise
  28057. */
  28058. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28059. /**
  28060. * Creates a video texture straight from your WebCam video feed.
  28061. * @param scene Define the scene the texture should be created in
  28062. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28063. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28064. * @returns The created video texture as a promise
  28065. */
  28066. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28067. minWidth: number;
  28068. maxWidth: number;
  28069. minHeight: number;
  28070. maxHeight: number;
  28071. deviceId: string;
  28072. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28073. /**
  28074. * Creates a video texture straight from your WebCam video feed.
  28075. * @param scene Define the scene the texture should be created in
  28076. * @param onReady Define a callback to triggered once the texture will be ready
  28077. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28078. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28079. */
  28080. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28081. minWidth: number;
  28082. maxWidth: number;
  28083. minHeight: number;
  28084. maxHeight: number;
  28085. deviceId: string;
  28086. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28087. }
  28088. }
  28089. declare module "babylonjs/Engines/engine" {
  28090. import { Observable } from "babylonjs/Misc/observable";
  28091. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28092. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28093. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28094. import { Camera } from "babylonjs/Cameras/camera";
  28095. import { Scene } from "babylonjs/scene";
  28096. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28097. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28099. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28100. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28103. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28104. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28105. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28106. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28107. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28108. import { WebRequest } from "babylonjs/Misc/webRequest";
  28109. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28110. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28111. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28112. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28113. import { Material } from "babylonjs/Materials/material";
  28114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28116. /**
  28117. * Interface for attribute information associated with buffer instanciation
  28118. */
  28119. export class InstancingAttributeInfo {
  28120. /**
  28121. * Index/offset of the attribute in the vertex shader
  28122. */
  28123. index: number;
  28124. /**
  28125. * size of the attribute, 1, 2, 3 or 4
  28126. */
  28127. attributeSize: number;
  28128. /**
  28129. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28130. * default is FLOAT
  28131. */
  28132. attribyteType: number;
  28133. /**
  28134. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28135. */
  28136. normalized: boolean;
  28137. /**
  28138. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28139. */
  28140. offset: number;
  28141. /**
  28142. * Name of the GLSL attribute, for debugging purpose only
  28143. */
  28144. attributeName: string;
  28145. }
  28146. /**
  28147. * Define options used to create a depth texture
  28148. */
  28149. export class DepthTextureCreationOptions {
  28150. /** Specifies whether or not a stencil should be allocated in the texture */
  28151. generateStencil?: boolean;
  28152. /** Specifies whether or not bilinear filtering is enable on the texture */
  28153. bilinearFiltering?: boolean;
  28154. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28155. comparisonFunction?: number;
  28156. /** Specifies if the created texture is a cube texture */
  28157. isCube?: boolean;
  28158. }
  28159. /**
  28160. * Class used to describe the capabilities of the engine relatively to the current browser
  28161. */
  28162. export class EngineCapabilities {
  28163. /** Maximum textures units per fragment shader */
  28164. maxTexturesImageUnits: number;
  28165. /** Maximum texture units per vertex shader */
  28166. maxVertexTextureImageUnits: number;
  28167. /** Maximum textures units in the entire pipeline */
  28168. maxCombinedTexturesImageUnits: number;
  28169. /** Maximum texture size */
  28170. maxTextureSize: number;
  28171. /** Maximum cube texture size */
  28172. maxCubemapTextureSize: number;
  28173. /** Maximum render texture size */
  28174. maxRenderTextureSize: number;
  28175. /** Maximum number of vertex attributes */
  28176. maxVertexAttribs: number;
  28177. /** Maximum number of varyings */
  28178. maxVaryingVectors: number;
  28179. /** Maximum number of uniforms per vertex shader */
  28180. maxVertexUniformVectors: number;
  28181. /** Maximum number of uniforms per fragment shader */
  28182. maxFragmentUniformVectors: number;
  28183. /** Defines if standard derivates (dx/dy) are supported */
  28184. standardDerivatives: boolean;
  28185. /** Defines if s3tc texture compression is supported */
  28186. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28187. /** Defines if pvrtc texture compression is supported */
  28188. pvrtc: any;
  28189. /** Defines if etc1 texture compression is supported */
  28190. etc1: any;
  28191. /** Defines if etc2 texture compression is supported */
  28192. etc2: any;
  28193. /** Defines if astc texture compression is supported */
  28194. astc: any;
  28195. /** Defines if float textures are supported */
  28196. textureFloat: boolean;
  28197. /** Defines if vertex array objects are supported */
  28198. vertexArrayObject: boolean;
  28199. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28200. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28201. /** Gets the maximum level of anisotropy supported */
  28202. maxAnisotropy: number;
  28203. /** Defines if instancing is supported */
  28204. instancedArrays: boolean;
  28205. /** Defines if 32 bits indices are supported */
  28206. uintIndices: boolean;
  28207. /** Defines if high precision shaders are supported */
  28208. highPrecisionShaderSupported: boolean;
  28209. /** Defines if depth reading in the fragment shader is supported */
  28210. fragmentDepthSupported: boolean;
  28211. /** Defines if float texture linear filtering is supported*/
  28212. textureFloatLinearFiltering: boolean;
  28213. /** Defines if rendering to float textures is supported */
  28214. textureFloatRender: boolean;
  28215. /** Defines if half float textures are supported*/
  28216. textureHalfFloat: boolean;
  28217. /** Defines if half float texture linear filtering is supported*/
  28218. textureHalfFloatLinearFiltering: boolean;
  28219. /** Defines if rendering to half float textures is supported */
  28220. textureHalfFloatRender: boolean;
  28221. /** Defines if textureLOD shader command is supported */
  28222. textureLOD: boolean;
  28223. /** Defines if draw buffers extension is supported */
  28224. drawBuffersExtension: boolean;
  28225. /** Defines if depth textures are supported */
  28226. depthTextureExtension: boolean;
  28227. /** Defines if float color buffer are supported */
  28228. colorBufferFloat: boolean;
  28229. /** Gets disjoint timer query extension (null if not supported) */
  28230. timerQuery: EXT_disjoint_timer_query;
  28231. /** Defines if timestamp can be used with timer query */
  28232. canUseTimestampForTimerQuery: boolean;
  28233. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28234. multiview: any;
  28235. /** Function used to let the system compiles shaders in background */
  28236. parallelShaderCompile: {
  28237. COMPLETION_STATUS_KHR: number;
  28238. };
  28239. }
  28240. /** Interface defining initialization parameters for Engine class */
  28241. export interface EngineOptions extends WebGLContextAttributes {
  28242. /**
  28243. * Defines if the engine should no exceed a specified device ratio
  28244. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28245. */
  28246. limitDeviceRatio?: number;
  28247. /**
  28248. * Defines if webvr should be enabled automatically
  28249. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28250. */
  28251. autoEnableWebVR?: boolean;
  28252. /**
  28253. * Defines if webgl2 should be turned off even if supported
  28254. * @see http://doc.babylonjs.com/features/webgl2
  28255. */
  28256. disableWebGL2Support?: boolean;
  28257. /**
  28258. * Defines if webaudio should be initialized as well
  28259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28260. */
  28261. audioEngine?: boolean;
  28262. /**
  28263. * Defines if animations should run using a deterministic lock step
  28264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28265. */
  28266. deterministicLockstep?: boolean;
  28267. /** Defines the maximum steps to use with deterministic lock step mode */
  28268. lockstepMaxSteps?: number;
  28269. /**
  28270. * Defines that engine should ignore context lost events
  28271. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28272. */
  28273. doNotHandleContextLost?: boolean;
  28274. /**
  28275. * Defines that engine should ignore modifying touch action attribute and style
  28276. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28277. */
  28278. doNotHandleTouchAction?: boolean;
  28279. /**
  28280. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28281. */
  28282. useHighPrecisionFloats?: boolean;
  28283. }
  28284. /**
  28285. * Defines the interface used by display changed events
  28286. */
  28287. export interface IDisplayChangedEventArgs {
  28288. /** Gets the vrDisplay object (if any) */
  28289. vrDisplay: Nullable<any>;
  28290. /** Gets a boolean indicating if webVR is supported */
  28291. vrSupported: boolean;
  28292. }
  28293. /**
  28294. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28295. */
  28296. export class Engine {
  28297. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28298. static ExceptionList: ({
  28299. key: string;
  28300. capture: string;
  28301. captureConstraint: number;
  28302. targets: string[];
  28303. } | {
  28304. key: string;
  28305. capture: null;
  28306. captureConstraint: null;
  28307. targets: string[];
  28308. })[];
  28309. /** Gets the list of created engines */
  28310. static readonly Instances: Engine[];
  28311. /**
  28312. * Gets the latest created engine
  28313. */
  28314. static readonly LastCreatedEngine: Nullable<Engine>;
  28315. /**
  28316. * Gets the latest created scene
  28317. */
  28318. static readonly LastCreatedScene: Nullable<Scene>;
  28319. /**
  28320. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28321. * @param flag defines which part of the materials must be marked as dirty
  28322. * @param predicate defines a predicate used to filter which materials should be affected
  28323. */
  28324. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28325. /** @hidden */
  28326. static _TextureLoaders: IInternalTextureLoader[];
  28327. /** Defines that alpha blending is disabled */
  28328. static readonly ALPHA_DISABLE: number;
  28329. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28330. static readonly ALPHA_ADD: number;
  28331. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28332. static readonly ALPHA_COMBINE: number;
  28333. /** Defines that alpha blending to DEST - SRC * DEST */
  28334. static readonly ALPHA_SUBTRACT: number;
  28335. /** Defines that alpha blending to SRC * DEST */
  28336. static readonly ALPHA_MULTIPLY: number;
  28337. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28338. static readonly ALPHA_MAXIMIZED: number;
  28339. /** Defines that alpha blending to SRC + DEST */
  28340. static readonly ALPHA_ONEONE: number;
  28341. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28342. static readonly ALPHA_PREMULTIPLIED: number;
  28343. /**
  28344. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28345. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28346. */
  28347. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28348. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28349. static readonly ALPHA_INTERPOLATE: number;
  28350. /**
  28351. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28352. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28353. */
  28354. static readonly ALPHA_SCREENMODE: number;
  28355. /** Defines that the ressource is not delayed*/
  28356. static readonly DELAYLOADSTATE_NONE: number;
  28357. /** Defines that the ressource was successfully delay loaded */
  28358. static readonly DELAYLOADSTATE_LOADED: number;
  28359. /** Defines that the ressource is currently delay loading */
  28360. static readonly DELAYLOADSTATE_LOADING: number;
  28361. /** Defines that the ressource is delayed and has not started loading */
  28362. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28364. static readonly NEVER: number;
  28365. /** 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 */
  28366. static readonly ALWAYS: number;
  28367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28368. static readonly LESS: number;
  28369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28370. static readonly EQUAL: number;
  28371. /** 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 */
  28372. static readonly LEQUAL: number;
  28373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28374. static readonly GREATER: number;
  28375. /** 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 */
  28376. static readonly GEQUAL: number;
  28377. /** 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 */
  28378. static readonly NOTEQUAL: number;
  28379. /** Passed to stencilOperation to specify that stencil value must be kept */
  28380. static readonly KEEP: number;
  28381. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28382. static readonly REPLACE: number;
  28383. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28384. static readonly INCR: number;
  28385. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28386. static readonly DECR: number;
  28387. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28388. static readonly INVERT: number;
  28389. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28390. static readonly INCR_WRAP: number;
  28391. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28392. static readonly DECR_WRAP: number;
  28393. /** Texture is not repeating outside of 0..1 UVs */
  28394. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28395. /** Texture is repeating outside of 0..1 UVs */
  28396. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28397. /** Texture is repeating and mirrored */
  28398. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28399. /** ALPHA */
  28400. static readonly TEXTUREFORMAT_ALPHA: number;
  28401. /** LUMINANCE */
  28402. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28403. /** LUMINANCE_ALPHA */
  28404. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28405. /** RGB */
  28406. static readonly TEXTUREFORMAT_RGB: number;
  28407. /** RGBA */
  28408. static readonly TEXTUREFORMAT_RGBA: number;
  28409. /** RED */
  28410. static readonly TEXTUREFORMAT_RED: number;
  28411. /** RED (2nd reference) */
  28412. static readonly TEXTUREFORMAT_R: number;
  28413. /** RG */
  28414. static readonly TEXTUREFORMAT_RG: number;
  28415. /** RED_INTEGER */
  28416. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28417. /** RED_INTEGER (2nd reference) */
  28418. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28419. /** RG_INTEGER */
  28420. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28421. /** RGB_INTEGER */
  28422. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28423. /** RGBA_INTEGER */
  28424. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28425. /** UNSIGNED_BYTE */
  28426. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28427. /** UNSIGNED_BYTE (2nd reference) */
  28428. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28429. /** FLOAT */
  28430. static readonly TEXTURETYPE_FLOAT: number;
  28431. /** HALF_FLOAT */
  28432. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28433. /** BYTE */
  28434. static readonly TEXTURETYPE_BYTE: number;
  28435. /** SHORT */
  28436. static readonly TEXTURETYPE_SHORT: number;
  28437. /** UNSIGNED_SHORT */
  28438. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28439. /** INT */
  28440. static readonly TEXTURETYPE_INT: number;
  28441. /** UNSIGNED_INT */
  28442. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28443. /** UNSIGNED_SHORT_4_4_4_4 */
  28444. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28445. /** UNSIGNED_SHORT_5_5_5_1 */
  28446. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28447. /** UNSIGNED_SHORT_5_6_5 */
  28448. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28449. /** UNSIGNED_INT_2_10_10_10_REV */
  28450. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28451. /** UNSIGNED_INT_24_8 */
  28452. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28453. /** UNSIGNED_INT_10F_11F_11F_REV */
  28454. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28455. /** UNSIGNED_INT_5_9_9_9_REV */
  28456. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28457. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28458. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28459. /** nearest is mag = nearest and min = nearest and mip = linear */
  28460. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28461. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28462. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28463. /** Trilinear is mag = linear and min = linear and mip = linear */
  28464. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28465. /** nearest is mag = nearest and min = nearest and mip = linear */
  28466. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28468. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28469. /** Trilinear is mag = linear and min = linear and mip = linear */
  28470. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28471. /** mag = nearest and min = nearest and mip = nearest */
  28472. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28473. /** mag = nearest and min = linear and mip = nearest */
  28474. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28475. /** mag = nearest and min = linear and mip = linear */
  28476. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28477. /** mag = nearest and min = linear and mip = none */
  28478. static readonly TEXTURE_NEAREST_LINEAR: number;
  28479. /** mag = nearest and min = nearest and mip = none */
  28480. static readonly TEXTURE_NEAREST_NEAREST: number;
  28481. /** mag = linear and min = nearest and mip = nearest */
  28482. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28483. /** mag = linear and min = nearest and mip = linear */
  28484. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28485. /** mag = linear and min = linear and mip = none */
  28486. static readonly TEXTURE_LINEAR_LINEAR: number;
  28487. /** mag = linear and min = nearest and mip = none */
  28488. static readonly TEXTURE_LINEAR_NEAREST: number;
  28489. /** Explicit coordinates mode */
  28490. static readonly TEXTURE_EXPLICIT_MODE: number;
  28491. /** Spherical coordinates mode */
  28492. static readonly TEXTURE_SPHERICAL_MODE: number;
  28493. /** Planar coordinates mode */
  28494. static readonly TEXTURE_PLANAR_MODE: number;
  28495. /** Cubic coordinates mode */
  28496. static readonly TEXTURE_CUBIC_MODE: number;
  28497. /** Projection coordinates mode */
  28498. static readonly TEXTURE_PROJECTION_MODE: number;
  28499. /** Skybox coordinates mode */
  28500. static readonly TEXTURE_SKYBOX_MODE: number;
  28501. /** Inverse Cubic coordinates mode */
  28502. static readonly TEXTURE_INVCUBIC_MODE: number;
  28503. /** Equirectangular coordinates mode */
  28504. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28505. /** Equirectangular Fixed coordinates mode */
  28506. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28507. /** Equirectangular Fixed Mirrored coordinates mode */
  28508. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28509. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28510. static readonly SCALEMODE_FLOOR: number;
  28511. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28512. static readonly SCALEMODE_NEAREST: number;
  28513. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28514. static readonly SCALEMODE_CEILING: number;
  28515. /**
  28516. * Returns the current npm package of the sdk
  28517. */
  28518. static readonly NpmPackage: string;
  28519. /**
  28520. * Returns the current version of the framework
  28521. */
  28522. static readonly Version: string;
  28523. /**
  28524. * Returns a string describing the current engine
  28525. */
  28526. readonly description: string;
  28527. /**
  28528. * Gets or sets the epsilon value used by collision engine
  28529. */
  28530. static CollisionsEpsilon: number;
  28531. /**
  28532. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28533. */
  28534. static ShadersRepository: string;
  28535. /**
  28536. * Method called to create the default loading screen.
  28537. * This can be overriden in your own app.
  28538. * @param canvas The rendering canvas element
  28539. * @returns The loading screen
  28540. */
  28541. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28542. /**
  28543. * Method called to create the default rescale post process on each engine.
  28544. */
  28545. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28546. /** @hidden */
  28547. _shaderProcessor: IShaderProcessor;
  28548. /**
  28549. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28550. */
  28551. forcePOTTextures: boolean;
  28552. /**
  28553. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28554. */
  28555. isFullscreen: boolean;
  28556. /**
  28557. * Gets a boolean indicating if the pointer is currently locked
  28558. */
  28559. isPointerLock: boolean;
  28560. /**
  28561. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28562. */
  28563. cullBackFaces: boolean;
  28564. /**
  28565. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28566. */
  28567. renderEvenInBackground: boolean;
  28568. /**
  28569. * Gets or sets a boolean indicating that cache can be kept between frames
  28570. */
  28571. preventCacheWipeBetweenFrames: boolean;
  28572. /**
  28573. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28574. **/
  28575. enableOfflineSupport: boolean;
  28576. /**
  28577. * 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)
  28578. **/
  28579. disableManifestCheck: boolean;
  28580. /**
  28581. * Gets the list of created scenes
  28582. */
  28583. scenes: Scene[];
  28584. /**
  28585. * Event raised when a new scene is created
  28586. */
  28587. onNewSceneAddedObservable: Observable<Scene>;
  28588. /**
  28589. * Gets the list of created postprocesses
  28590. */
  28591. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28592. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28593. validateShaderPrograms: boolean;
  28594. /**
  28595. * Observable event triggered each time the rendering canvas is resized
  28596. */
  28597. onResizeObservable: Observable<Engine>;
  28598. /**
  28599. * Observable event triggered each time the canvas loses focus
  28600. */
  28601. onCanvasBlurObservable: Observable<Engine>;
  28602. /**
  28603. * Observable event triggered each time the canvas gains focus
  28604. */
  28605. onCanvasFocusObservable: Observable<Engine>;
  28606. /**
  28607. * Observable event triggered each time the canvas receives pointerout event
  28608. */
  28609. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28610. /**
  28611. * Observable event triggered before each texture is initialized
  28612. */
  28613. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28614. /**
  28615. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28616. */
  28617. disableUniformBuffers: boolean;
  28618. /** @hidden */
  28619. _uniformBuffers: UniformBuffer[];
  28620. /**
  28621. * Gets a boolean indicating that the engine supports uniform buffers
  28622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28623. */
  28624. readonly supportsUniformBuffers: boolean;
  28625. /**
  28626. * Observable raised when the engine begins a new frame
  28627. */
  28628. onBeginFrameObservable: Observable<Engine>;
  28629. /**
  28630. * If set, will be used to request the next animation frame for the render loop
  28631. */
  28632. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28633. /**
  28634. * Observable raised when the engine ends the current frame
  28635. */
  28636. onEndFrameObservable: Observable<Engine>;
  28637. /**
  28638. * Observable raised when the engine is about to compile a shader
  28639. */
  28640. onBeforeShaderCompilationObservable: Observable<Engine>;
  28641. /**
  28642. * Observable raised when the engine has jsut compiled a shader
  28643. */
  28644. onAfterShaderCompilationObservable: Observable<Engine>;
  28645. /** @hidden */
  28646. _gl: WebGLRenderingContext;
  28647. private _renderingCanvas;
  28648. private _windowIsBackground;
  28649. private _webGLVersion;
  28650. protected _highPrecisionShadersAllowed: boolean;
  28651. /** @hidden */
  28652. readonly _shouldUseHighPrecisionShader: boolean;
  28653. /**
  28654. * Gets a boolean indicating that only power of 2 textures are supported
  28655. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28656. */
  28657. readonly needPOTTextures: boolean;
  28658. /** @hidden */
  28659. _badOS: boolean;
  28660. /** @hidden */
  28661. _badDesktopOS: boolean;
  28662. /**
  28663. * Gets the audio engine
  28664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28665. * @ignorenaming
  28666. */
  28667. static audioEngine: IAudioEngine;
  28668. /**
  28669. * Default AudioEngine factory responsible of creating the Audio Engine.
  28670. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28671. */
  28672. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28673. /**
  28674. * Default offline support factory responsible of creating a tool used to store data locally.
  28675. * By default, this will create a Database object if the workload has been embedded.
  28676. */
  28677. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28678. private _onFocus;
  28679. private _onBlur;
  28680. private _onCanvasPointerOut;
  28681. private _onCanvasBlur;
  28682. private _onCanvasFocus;
  28683. private _onFullscreenChange;
  28684. private _onPointerLockChange;
  28685. private _hardwareScalingLevel;
  28686. /** @hidden */
  28687. _caps: EngineCapabilities;
  28688. private _pointerLockRequested;
  28689. private _isStencilEnable;
  28690. private _colorWrite;
  28691. private _loadingScreen;
  28692. /** @hidden */
  28693. _drawCalls: PerfCounter;
  28694. private _glVersion;
  28695. private _glRenderer;
  28696. private _glVendor;
  28697. private _videoTextureSupported;
  28698. private _renderingQueueLaunched;
  28699. private _activeRenderLoops;
  28700. private _deterministicLockstep;
  28701. private _lockstepMaxSteps;
  28702. /**
  28703. * Observable signaled when a context lost event is raised
  28704. */
  28705. onContextLostObservable: Observable<Engine>;
  28706. /**
  28707. * Observable signaled when a context restored event is raised
  28708. */
  28709. onContextRestoredObservable: Observable<Engine>;
  28710. private _onContextLost;
  28711. private _onContextRestored;
  28712. private _contextWasLost;
  28713. /** @hidden */
  28714. _doNotHandleContextLost: boolean;
  28715. /**
  28716. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28718. */
  28719. doNotHandleContextLost: boolean;
  28720. private _performanceMonitor;
  28721. private _fps;
  28722. private _deltaTime;
  28723. /**
  28724. * Turn this value on if you want to pause FPS computation when in background
  28725. */
  28726. disablePerformanceMonitorInBackground: boolean;
  28727. /**
  28728. * Gets the performance monitor attached to this engine
  28729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28730. */
  28731. readonly performanceMonitor: PerformanceMonitor;
  28732. /**
  28733. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28734. */
  28735. disableVertexArrayObjects: boolean;
  28736. /** @hidden */
  28737. protected _depthCullingState: _DepthCullingState;
  28738. /** @hidden */
  28739. protected _stencilState: _StencilState;
  28740. /** @hidden */
  28741. protected _alphaState: _AlphaState;
  28742. /** @hidden */
  28743. protected _alphaMode: number;
  28744. /** @hidden */
  28745. _internalTexturesCache: InternalTexture[];
  28746. /** @hidden */
  28747. protected _activeChannel: number;
  28748. private _currentTextureChannel;
  28749. /** @hidden */
  28750. protected _boundTexturesCache: {
  28751. [key: string]: Nullable<InternalTexture>;
  28752. };
  28753. /** @hidden */
  28754. protected _currentEffect: Nullable<Effect>;
  28755. /** @hidden */
  28756. protected _currentProgram: Nullable<WebGLProgram>;
  28757. private _compiledEffects;
  28758. private _vertexAttribArraysEnabled;
  28759. /** @hidden */
  28760. protected _cachedViewport: Nullable<Viewport>;
  28761. private _cachedVertexArrayObject;
  28762. /** @hidden */
  28763. protected _cachedVertexBuffers: any;
  28764. /** @hidden */
  28765. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28766. /** @hidden */
  28767. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28768. /** @hidden */
  28769. _currentRenderTarget: Nullable<InternalTexture>;
  28770. private _uintIndicesCurrentlySet;
  28771. private _currentBoundBuffer;
  28772. /** @hidden */
  28773. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28774. private _currentBufferPointers;
  28775. private _currentInstanceLocations;
  28776. private _currentInstanceBuffers;
  28777. private _textureUnits;
  28778. /** @hidden */
  28779. _workingCanvas: Nullable<HTMLCanvasElement>;
  28780. /** @hidden */
  28781. _workingContext: Nullable<CanvasRenderingContext2D>;
  28782. private _rescalePostProcess;
  28783. private _dummyFramebuffer;
  28784. private _externalData;
  28785. /** @hidden */
  28786. _bindedRenderFunction: any;
  28787. private _vaoRecordInProgress;
  28788. private _mustWipeVertexAttributes;
  28789. private _emptyTexture;
  28790. private _emptyCubeTexture;
  28791. private _emptyTexture3D;
  28792. /** @hidden */
  28793. _frameHandler: number;
  28794. private _nextFreeTextureSlots;
  28795. private _maxSimultaneousTextures;
  28796. private _activeRequests;
  28797. private _texturesSupported;
  28798. /** @hidden */
  28799. _textureFormatInUse: Nullable<string>;
  28800. /**
  28801. * Gets the list of texture formats supported
  28802. */
  28803. readonly texturesSupported: Array<string>;
  28804. /**
  28805. * Gets the list of texture formats in use
  28806. */
  28807. readonly textureFormatInUse: Nullable<string>;
  28808. /**
  28809. * Gets the current viewport
  28810. */
  28811. readonly currentViewport: Nullable<Viewport>;
  28812. /**
  28813. * Gets the default empty texture
  28814. */
  28815. readonly emptyTexture: InternalTexture;
  28816. /**
  28817. * Gets the default empty 3D texture
  28818. */
  28819. readonly emptyTexture3D: InternalTexture;
  28820. /**
  28821. * Gets the default empty cube texture
  28822. */
  28823. readonly emptyCubeTexture: InternalTexture;
  28824. /**
  28825. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28826. */
  28827. readonly premultipliedAlpha: boolean;
  28828. /**
  28829. * Creates a new engine
  28830. * @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
  28831. * @param antialias defines enable antialiasing (default: false)
  28832. * @param options defines further options to be sent to the getContext() function
  28833. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28834. */
  28835. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28836. /**
  28837. * Initializes a webVR display and starts listening to display change events
  28838. * The onVRDisplayChangedObservable will be notified upon these changes
  28839. * @returns The onVRDisplayChangedObservable
  28840. */
  28841. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28842. /** @hidden */
  28843. _prepareVRComponent(): void;
  28844. /** @hidden */
  28845. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28846. /** @hidden */
  28847. _submitVRFrame(): void;
  28848. /**
  28849. * Call this function to leave webVR mode
  28850. * Will do nothing if webVR is not supported or if there is no webVR device
  28851. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28852. */
  28853. disableVR(): void;
  28854. /**
  28855. * Gets a boolean indicating that the system is in VR mode and is presenting
  28856. * @returns true if VR mode is engaged
  28857. */
  28858. isVRPresenting(): boolean;
  28859. /** @hidden */
  28860. _requestVRFrame(): void;
  28861. private _disableTouchAction;
  28862. private _rebuildInternalTextures;
  28863. private _rebuildEffects;
  28864. /**
  28865. * Gets a boolean indicating if all created effects are ready
  28866. * @returns true if all effects are ready
  28867. */
  28868. areAllEffectsReady(): boolean;
  28869. private _rebuildBuffers;
  28870. private _initGLContext;
  28871. /**
  28872. * Gets version of the current webGL context
  28873. */
  28874. readonly webGLVersion: number;
  28875. /**
  28876. * Gets a string idenfifying the name of the class
  28877. * @returns "Engine" string
  28878. */
  28879. getClassName(): string;
  28880. /**
  28881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28882. */
  28883. readonly isStencilEnable: boolean;
  28884. /** @hidden */
  28885. _prepareWorkingCanvas(): void;
  28886. /**
  28887. * Reset the texture cache to empty state
  28888. */
  28889. resetTextureCache(): void;
  28890. /**
  28891. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28893. * @returns true if engine is in deterministic lock step mode
  28894. */
  28895. isDeterministicLockStep(): boolean;
  28896. /**
  28897. * Gets the max steps when engine is running in deterministic lock step
  28898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28899. * @returns the max steps
  28900. */
  28901. getLockstepMaxSteps(): number;
  28902. /**
  28903. * Gets an object containing information about the current webGL context
  28904. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28905. */
  28906. getGlInfo(): {
  28907. vendor: string;
  28908. renderer: string;
  28909. version: string;
  28910. };
  28911. /**
  28912. * Gets current aspect ratio
  28913. * @param camera defines the camera to use to get the aspect ratio
  28914. * @param useScreen defines if screen size must be used (or the current render target if any)
  28915. * @returns a number defining the aspect ratio
  28916. */
  28917. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28918. /**
  28919. * Gets current screen aspect ratio
  28920. * @returns a number defining the aspect ratio
  28921. */
  28922. getScreenAspectRatio(): number;
  28923. /**
  28924. * Gets the current render width
  28925. * @param useScreen defines if screen size must be used (or the current render target if any)
  28926. * @returns a number defining the current render width
  28927. */
  28928. getRenderWidth(useScreen?: boolean): number;
  28929. /**
  28930. * Gets the current render height
  28931. * @param useScreen defines if screen size must be used (or the current render target if any)
  28932. * @returns a number defining the current render height
  28933. */
  28934. getRenderHeight(useScreen?: boolean): number;
  28935. /**
  28936. * Gets the HTML canvas attached with the current webGL context
  28937. * @returns a HTML canvas
  28938. */
  28939. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28940. /**
  28941. * Gets the client rect of the HTML canvas attached with the current webGL context
  28942. * @returns a client rectanglee
  28943. */
  28944. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28945. /**
  28946. * Defines the hardware scaling level.
  28947. * By default the hardware scaling level is computed from the window device ratio.
  28948. * 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.
  28949. * @param level defines the level to use
  28950. */
  28951. setHardwareScalingLevel(level: number): void;
  28952. /**
  28953. * Gets the current hardware scaling level.
  28954. * By default the hardware scaling level is computed from the window device ratio.
  28955. * 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.
  28956. * @returns a number indicating the current hardware scaling level
  28957. */
  28958. getHardwareScalingLevel(): number;
  28959. /**
  28960. * Gets the list of loaded textures
  28961. * @returns an array containing all loaded textures
  28962. */
  28963. getLoadedTexturesCache(): InternalTexture[];
  28964. /**
  28965. * Gets the object containing all engine capabilities
  28966. * @returns the EngineCapabilities object
  28967. */
  28968. getCaps(): EngineCapabilities;
  28969. /**
  28970. * Gets the current depth function
  28971. * @returns a number defining the depth function
  28972. */
  28973. getDepthFunction(): Nullable<number>;
  28974. /**
  28975. * Sets the current depth function
  28976. * @param depthFunc defines the function to use
  28977. */
  28978. setDepthFunction(depthFunc: number): void;
  28979. /**
  28980. * Sets the current depth function to GREATER
  28981. */
  28982. setDepthFunctionToGreater(): void;
  28983. /**
  28984. * Sets the current depth function to GEQUAL
  28985. */
  28986. setDepthFunctionToGreaterOrEqual(): void;
  28987. /**
  28988. * Sets the current depth function to LESS
  28989. */
  28990. setDepthFunctionToLess(): void;
  28991. private _cachedStencilBuffer;
  28992. private _cachedStencilFunction;
  28993. private _cachedStencilMask;
  28994. private _cachedStencilOperationPass;
  28995. private _cachedStencilOperationFail;
  28996. private _cachedStencilOperationDepthFail;
  28997. private _cachedStencilReference;
  28998. /**
  28999. * Caches the the state of the stencil buffer
  29000. */
  29001. cacheStencilState(): void;
  29002. /**
  29003. * Restores the state of the stencil buffer
  29004. */
  29005. restoreStencilState(): void;
  29006. /**
  29007. * Sets the current depth function to LEQUAL
  29008. */
  29009. setDepthFunctionToLessOrEqual(): void;
  29010. /**
  29011. * Gets a boolean indicating if stencil buffer is enabled
  29012. * @returns the current stencil buffer state
  29013. */
  29014. getStencilBuffer(): boolean;
  29015. /**
  29016. * Enable or disable the stencil buffer
  29017. * @param enable defines if the stencil buffer must be enabled or disabled
  29018. */
  29019. setStencilBuffer(enable: boolean): void;
  29020. /**
  29021. * Gets the current stencil mask
  29022. * @returns a number defining the new stencil mask to use
  29023. */
  29024. getStencilMask(): number;
  29025. /**
  29026. * Sets the current stencil mask
  29027. * @param mask defines the new stencil mask to use
  29028. */
  29029. setStencilMask(mask: number): void;
  29030. /**
  29031. * Gets the current stencil function
  29032. * @returns a number defining the stencil function to use
  29033. */
  29034. getStencilFunction(): number;
  29035. /**
  29036. * Gets the current stencil reference value
  29037. * @returns a number defining the stencil reference value to use
  29038. */
  29039. getStencilFunctionReference(): number;
  29040. /**
  29041. * Gets the current stencil mask
  29042. * @returns a number defining the stencil mask to use
  29043. */
  29044. getStencilFunctionMask(): number;
  29045. /**
  29046. * Sets the current stencil function
  29047. * @param stencilFunc defines the new stencil function to use
  29048. */
  29049. setStencilFunction(stencilFunc: number): void;
  29050. /**
  29051. * Sets the current stencil reference
  29052. * @param reference defines the new stencil reference to use
  29053. */
  29054. setStencilFunctionReference(reference: number): void;
  29055. /**
  29056. * Sets the current stencil mask
  29057. * @param mask defines the new stencil mask to use
  29058. */
  29059. setStencilFunctionMask(mask: number): void;
  29060. /**
  29061. * Gets the current stencil operation when stencil fails
  29062. * @returns a number defining stencil operation to use when stencil fails
  29063. */
  29064. getStencilOperationFail(): number;
  29065. /**
  29066. * Gets the current stencil operation when depth fails
  29067. * @returns a number defining stencil operation to use when depth fails
  29068. */
  29069. getStencilOperationDepthFail(): number;
  29070. /**
  29071. * Gets the current stencil operation when stencil passes
  29072. * @returns a number defining stencil operation to use when stencil passes
  29073. */
  29074. getStencilOperationPass(): number;
  29075. /**
  29076. * Sets the stencil operation to use when stencil fails
  29077. * @param operation defines the stencil operation to use when stencil fails
  29078. */
  29079. setStencilOperationFail(operation: number): void;
  29080. /**
  29081. * Sets the stencil operation to use when depth fails
  29082. * @param operation defines the stencil operation to use when depth fails
  29083. */
  29084. setStencilOperationDepthFail(operation: number): void;
  29085. /**
  29086. * Sets the stencil operation to use when stencil passes
  29087. * @param operation defines the stencil operation to use when stencil passes
  29088. */
  29089. setStencilOperationPass(operation: number): void;
  29090. /**
  29091. * Sets a boolean indicating if the dithering state is enabled or disabled
  29092. * @param value defines the dithering state
  29093. */
  29094. setDitheringState(value: boolean): void;
  29095. /**
  29096. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29097. * @param value defines the rasterizer state
  29098. */
  29099. setRasterizerState(value: boolean): void;
  29100. /**
  29101. * stop executing a render loop function and remove it from the execution array
  29102. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29103. */
  29104. stopRenderLoop(renderFunction?: () => void): void;
  29105. /** @hidden */
  29106. _renderLoop(): void;
  29107. /**
  29108. * Register and execute a render loop. The engine can have more than one render function
  29109. * @param renderFunction defines the function to continuously execute
  29110. */
  29111. runRenderLoop(renderFunction: () => void): void;
  29112. /**
  29113. * Toggle full screen mode
  29114. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29115. */
  29116. switchFullscreen(requestPointerLock: boolean): void;
  29117. /**
  29118. * Enters full screen mode
  29119. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29120. */
  29121. enterFullscreen(requestPointerLock: boolean): void;
  29122. /**
  29123. * Exits full screen mode
  29124. */
  29125. exitFullscreen(): void;
  29126. /**
  29127. * Enters Pointerlock mode
  29128. */
  29129. enterPointerlock(): void;
  29130. /**
  29131. * Exits Pointerlock mode
  29132. */
  29133. exitPointerlock(): void;
  29134. /**
  29135. * Clear the current render buffer or the current render target (if any is set up)
  29136. * @param color defines the color to use
  29137. * @param backBuffer defines if the back buffer must be cleared
  29138. * @param depth defines if the depth buffer must be cleared
  29139. * @param stencil defines if the stencil buffer must be cleared
  29140. */
  29141. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29142. /**
  29143. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29144. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29145. * @param y defines the y-coordinate of the corner of the clear rectangle
  29146. * @param width defines the width of the clear rectangle
  29147. * @param height defines the height of the clear rectangle
  29148. * @param clearColor defines the clear color
  29149. */
  29150. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29151. /**
  29152. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29153. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29154. * @param y defines the y-coordinate of the corner of the clear rectangle
  29155. * @param width defines the width of the clear rectangle
  29156. * @param height defines the height of the clear rectangle
  29157. */
  29158. enableScissor(x: number, y: number, width: number, height: number): void;
  29159. /**
  29160. * Disable previously set scissor test rectangle
  29161. */
  29162. disableScissor(): void;
  29163. private _viewportCached;
  29164. /** @hidden */
  29165. _viewport(x: number, y: number, width: number, height: number): void;
  29166. /**
  29167. * Set the WebGL's viewport
  29168. * @param viewport defines the viewport element to be used
  29169. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29170. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29171. */
  29172. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29173. /**
  29174. * Directly set the WebGL Viewport
  29175. * @param x defines the x coordinate of the viewport (in screen space)
  29176. * @param y defines the y coordinate of the viewport (in screen space)
  29177. * @param width defines the width of the viewport (in screen space)
  29178. * @param height defines the height of the viewport (in screen space)
  29179. * @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
  29180. */
  29181. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29182. /**
  29183. * Begin a new frame
  29184. */
  29185. beginFrame(): void;
  29186. /**
  29187. * Enf the current frame
  29188. */
  29189. endFrame(): void;
  29190. /**
  29191. * Resize the view according to the canvas' size
  29192. */
  29193. resize(): void;
  29194. /**
  29195. * Force a specific size of the canvas
  29196. * @param width defines the new canvas' width
  29197. * @param height defines the new canvas' height
  29198. */
  29199. setSize(width: number, height: number): void;
  29200. /**
  29201. * Binds the frame buffer to the specified texture.
  29202. * @param texture The texture to render to or null for the default canvas
  29203. * @param faceIndex The face of the texture to render to in case of cube texture
  29204. * @param requiredWidth The width of the target to render to
  29205. * @param requiredHeight The height of the target to render to
  29206. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29207. * @param depthStencilTexture The depth stencil texture to use to render
  29208. * @param lodLevel defines le lod level to bind to the frame buffer
  29209. */
  29210. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29211. /** @hidden */
  29212. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29213. /**
  29214. * Unbind the current render target texture from the webGL context
  29215. * @param texture defines the render target texture to unbind
  29216. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29217. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29218. */
  29219. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29220. /**
  29221. * Force the mipmap generation for the given render target texture
  29222. * @param texture defines the render target texture to use
  29223. */
  29224. generateMipMapsForCubemap(texture: InternalTexture): void;
  29225. /**
  29226. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29227. */
  29228. flushFramebuffer(): void;
  29229. /**
  29230. * Unbind the current render target and bind the default framebuffer
  29231. */
  29232. restoreDefaultFramebuffer(): void;
  29233. /**
  29234. * Create an uniform buffer
  29235. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29236. * @param elements defines the content of the uniform buffer
  29237. * @returns the webGL uniform buffer
  29238. */
  29239. createUniformBuffer(elements: FloatArray): DataBuffer;
  29240. /**
  29241. * Create a dynamic uniform buffer
  29242. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29243. * @param elements defines the content of the uniform buffer
  29244. * @returns the webGL uniform buffer
  29245. */
  29246. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29247. /**
  29248. * Update an existing uniform buffer
  29249. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29250. * @param uniformBuffer defines the target uniform buffer
  29251. * @param elements defines the content to update
  29252. * @param offset defines the offset in the uniform buffer where update should start
  29253. * @param count defines the size of the data to update
  29254. */
  29255. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29256. private _resetVertexBufferBinding;
  29257. /**
  29258. * Creates a vertex buffer
  29259. * @param data the data for the vertex buffer
  29260. * @returns the new WebGL static buffer
  29261. */
  29262. createVertexBuffer(data: DataArray): DataBuffer;
  29263. /**
  29264. * Creates a dynamic vertex buffer
  29265. * @param data the data for the dynamic vertex buffer
  29266. * @returns the new WebGL dynamic buffer
  29267. */
  29268. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29269. /**
  29270. * Update a dynamic index buffer
  29271. * @param indexBuffer defines the target index buffer
  29272. * @param indices defines the data to update
  29273. * @param offset defines the offset in the target index buffer where update should start
  29274. */
  29275. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29276. /**
  29277. * Updates a dynamic vertex buffer.
  29278. * @param vertexBuffer the vertex buffer to update
  29279. * @param data the data used to update the vertex buffer
  29280. * @param byteOffset the byte offset of the data
  29281. * @param byteLength the byte length of the data
  29282. */
  29283. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29284. private _resetIndexBufferBinding;
  29285. /**
  29286. * Creates a new index buffer
  29287. * @param indices defines the content of the index buffer
  29288. * @param updatable defines if the index buffer must be updatable
  29289. * @returns a new webGL buffer
  29290. */
  29291. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29292. /**
  29293. * Bind a webGL buffer to the webGL context
  29294. * @param buffer defines the buffer to bind
  29295. */
  29296. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29297. /**
  29298. * Bind an uniform buffer to the current webGL context
  29299. * @param buffer defines the buffer to bind
  29300. */
  29301. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29302. /**
  29303. * Bind a buffer to the current webGL context at a given location
  29304. * @param buffer defines the buffer to bind
  29305. * @param location defines the index where to bind the buffer
  29306. */
  29307. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29308. /**
  29309. * Bind a specific block at a given index in a specific shader program
  29310. * @param pipelineContext defines the pipeline context to use
  29311. * @param blockName defines the block name
  29312. * @param index defines the index where to bind the block
  29313. */
  29314. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29315. private bindIndexBuffer;
  29316. private bindBuffer;
  29317. /**
  29318. * update the bound buffer with the given data
  29319. * @param data defines the data to update
  29320. */
  29321. updateArrayBuffer(data: Float32Array): void;
  29322. private _vertexAttribPointer;
  29323. private _bindIndexBufferWithCache;
  29324. private _bindVertexBuffersAttributes;
  29325. /**
  29326. * Records a vertex array object
  29327. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29328. * @param vertexBuffers defines the list of vertex buffers to store
  29329. * @param indexBuffer defines the index buffer to store
  29330. * @param effect defines the effect to store
  29331. * @returns the new vertex array object
  29332. */
  29333. recordVertexArrayObject(vertexBuffers: {
  29334. [key: string]: VertexBuffer;
  29335. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29336. /**
  29337. * Bind a specific vertex array object
  29338. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29339. * @param vertexArrayObject defines the vertex array object to bind
  29340. * @param indexBuffer defines the index buffer to bind
  29341. */
  29342. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29343. /**
  29344. * Bind webGl buffers directly to the webGL context
  29345. * @param vertexBuffer defines the vertex buffer to bind
  29346. * @param indexBuffer defines the index buffer to bind
  29347. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29348. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29349. * @param effect defines the effect associated with the vertex buffer
  29350. */
  29351. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29352. private _unbindVertexArrayObject;
  29353. /**
  29354. * Bind a list of vertex buffers to the webGL context
  29355. * @param vertexBuffers defines the list of vertex buffers to bind
  29356. * @param indexBuffer defines the index buffer to bind
  29357. * @param effect defines the effect associated with the vertex buffers
  29358. */
  29359. bindBuffers(vertexBuffers: {
  29360. [key: string]: Nullable<VertexBuffer>;
  29361. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29362. /**
  29363. * Unbind all instance attributes
  29364. */
  29365. unbindInstanceAttributes(): void;
  29366. /**
  29367. * Release and free the memory of a vertex array object
  29368. * @param vao defines the vertex array object to delete
  29369. */
  29370. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29371. /** @hidden */
  29372. _releaseBuffer(buffer: DataBuffer): boolean;
  29373. /**
  29374. * Creates a webGL buffer to use with instanciation
  29375. * @param capacity defines the size of the buffer
  29376. * @returns the webGL buffer
  29377. */
  29378. createInstancesBuffer(capacity: number): DataBuffer;
  29379. /**
  29380. * Delete a webGL buffer used with instanciation
  29381. * @param buffer defines the webGL buffer to delete
  29382. */
  29383. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29384. /**
  29385. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29386. * @param instancesBuffer defines the webGL buffer to update and bind
  29387. * @param data defines the data to store in the buffer
  29388. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29389. */
  29390. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29391. /**
  29392. * Apply all cached states (depth, culling, stencil and alpha)
  29393. */
  29394. applyStates(): void;
  29395. /**
  29396. * Send a draw order
  29397. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29398. * @param indexStart defines the starting index
  29399. * @param indexCount defines the number of index to draw
  29400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29401. */
  29402. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29403. /**
  29404. * Draw a list of points
  29405. * @param verticesStart defines the index of first vertex to draw
  29406. * @param verticesCount defines the count of vertices to draw
  29407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29408. */
  29409. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29410. /**
  29411. * Draw a list of unindexed primitives
  29412. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29413. * @param verticesStart defines the index of first vertex to draw
  29414. * @param verticesCount defines the count of vertices to draw
  29415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29416. */
  29417. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29418. /**
  29419. * Draw a list of indexed primitives
  29420. * @param fillMode defines the primitive to use
  29421. * @param indexStart defines the starting index
  29422. * @param indexCount defines the number of index to draw
  29423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29424. */
  29425. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29426. /**
  29427. * Draw a list of unindexed primitives
  29428. * @param fillMode defines the primitive to use
  29429. * @param verticesStart defines the index of first vertex to draw
  29430. * @param verticesCount defines the count of vertices to draw
  29431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29432. */
  29433. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29434. private _drawMode;
  29435. /** @hidden */
  29436. _releaseEffect(effect: Effect): void;
  29437. /** @hidden */
  29438. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29439. /**
  29440. * Create a new effect (used to store vertex/fragment shaders)
  29441. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29442. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29443. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29444. * @param samplers defines an array of string used to represent textures
  29445. * @param defines defines the string containing the defines to use to compile the shaders
  29446. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29447. * @param onCompiled defines a function to call when the effect creation is successful
  29448. * @param onError defines a function to call when the effect creation has failed
  29449. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29450. * @returns the new Effect
  29451. */
  29452. 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;
  29453. private _compileShader;
  29454. private _compileRawShader;
  29455. /**
  29456. * Directly creates a webGL program
  29457. * @param pipelineContext defines the pipeline context to attach to
  29458. * @param vertexCode defines the vertex shader code to use
  29459. * @param fragmentCode defines the fragment shader code to use
  29460. * @param context defines the webGL context to use (if not set, the current one will be used)
  29461. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29462. * @returns the new webGL program
  29463. */
  29464. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29465. /**
  29466. * Creates a webGL program
  29467. * @param pipelineContext defines the pipeline context to attach to
  29468. * @param vertexCode defines the vertex shader code to use
  29469. * @param fragmentCode defines the fragment shader code to use
  29470. * @param defines defines the string containing the defines to use to compile the shaders
  29471. * @param context defines the webGL context to use (if not set, the current one will be used)
  29472. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29473. * @returns the new webGL program
  29474. */
  29475. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29476. /**
  29477. * Creates a new pipeline context
  29478. * @returns the new pipeline
  29479. */
  29480. createPipelineContext(): WebGLPipelineContext;
  29481. private _createShaderProgram;
  29482. private _finalizePipelineContext;
  29483. /** @hidden */
  29484. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29485. /** @hidden */
  29486. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29487. /** @hidden */
  29488. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29489. /**
  29490. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29491. * @param pipelineContext defines the pipeline context to use
  29492. * @param uniformsNames defines the list of uniform names
  29493. * @returns an array of webGL uniform locations
  29494. */
  29495. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29496. /**
  29497. * Gets the lsit of active attributes for a given webGL program
  29498. * @param pipelineContext defines the pipeline context to use
  29499. * @param attributesNames defines the list of attribute names to get
  29500. * @returns an array of indices indicating the offset of each attribute
  29501. */
  29502. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29503. /**
  29504. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29505. * @param effect defines the effect to activate
  29506. */
  29507. enableEffect(effect: Nullable<Effect>): void;
  29508. /**
  29509. * Set the value of an uniform to an array of int32
  29510. * @param uniform defines the webGL uniform location where to store the value
  29511. * @param array defines the array of int32 to store
  29512. */
  29513. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29514. /**
  29515. * Set the value of an uniform to an array of int32 (stored as vec2)
  29516. * @param uniform defines the webGL uniform location where to store the value
  29517. * @param array defines the array of int32 to store
  29518. */
  29519. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29520. /**
  29521. * Set the value of an uniform to an array of int32 (stored as vec3)
  29522. * @param uniform defines the webGL uniform location where to store the value
  29523. * @param array defines the array of int32 to store
  29524. */
  29525. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29526. /**
  29527. * Set the value of an uniform to an array of int32 (stored as vec4)
  29528. * @param uniform defines the webGL uniform location where to store the value
  29529. * @param array defines the array of int32 to store
  29530. */
  29531. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29532. /**
  29533. * Set the value of an uniform to an array of float32
  29534. * @param uniform defines the webGL uniform location where to store the value
  29535. * @param array defines the array of float32 to store
  29536. */
  29537. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29538. /**
  29539. * Set the value of an uniform to an array of float32 (stored as vec2)
  29540. * @param uniform defines the webGL uniform location where to store the value
  29541. * @param array defines the array of float32 to store
  29542. */
  29543. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29544. /**
  29545. * Set the value of an uniform to an array of float32 (stored as vec3)
  29546. * @param uniform defines the webGL uniform location where to store the value
  29547. * @param array defines the array of float32 to store
  29548. */
  29549. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29550. /**
  29551. * Set the value of an uniform to an array of float32 (stored as vec4)
  29552. * @param uniform defines the webGL uniform location where to store the value
  29553. * @param array defines the array of float32 to store
  29554. */
  29555. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29556. /**
  29557. * Set the value of an uniform to an array of number
  29558. * @param uniform defines the webGL uniform location where to store the value
  29559. * @param array defines the array of number to store
  29560. */
  29561. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29562. /**
  29563. * Set the value of an uniform to an array of number (stored as vec2)
  29564. * @param uniform defines the webGL uniform location where to store the value
  29565. * @param array defines the array of number to store
  29566. */
  29567. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29568. /**
  29569. * Set the value of an uniform to an array of number (stored as vec3)
  29570. * @param uniform defines the webGL uniform location where to store the value
  29571. * @param array defines the array of number to store
  29572. */
  29573. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29574. /**
  29575. * Set the value of an uniform to an array of number (stored as vec4)
  29576. * @param uniform defines the webGL uniform location where to store the value
  29577. * @param array defines the array of number to store
  29578. */
  29579. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29580. /**
  29581. * Set the value of an uniform to an array of float32 (stored as matrices)
  29582. * @param uniform defines the webGL uniform location where to store the value
  29583. * @param matrices defines the array of float32 to store
  29584. */
  29585. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29586. /**
  29587. * Set the value of an uniform to a matrix
  29588. * @param uniform defines the webGL uniform location where to store the value
  29589. * @param matrix defines the matrix to store
  29590. */
  29591. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29592. /**
  29593. * Set the value of an uniform to a matrix (3x3)
  29594. * @param uniform defines the webGL uniform location where to store the value
  29595. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29596. */
  29597. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29598. /**
  29599. * Set the value of an uniform to a matrix (2x2)
  29600. * @param uniform defines the webGL uniform location where to store the value
  29601. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29602. */
  29603. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29604. /**
  29605. * Set the value of an uniform to a number (int)
  29606. * @param uniform defines the webGL uniform location where to store the value
  29607. * @param value defines the int number to store
  29608. */
  29609. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29610. /**
  29611. * Set the value of an uniform to a number (float)
  29612. * @param uniform defines the webGL uniform location where to store the value
  29613. * @param value defines the float number to store
  29614. */
  29615. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29616. /**
  29617. * Set the value of an uniform to a vec2
  29618. * @param uniform defines the webGL uniform location where to store the value
  29619. * @param x defines the 1st component of the value
  29620. * @param y defines the 2nd component of the value
  29621. */
  29622. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29623. /**
  29624. * Set the value of an uniform to a vec3
  29625. * @param uniform defines the webGL uniform location where to store the value
  29626. * @param x defines the 1st component of the value
  29627. * @param y defines the 2nd component of the value
  29628. * @param z defines the 3rd component of the value
  29629. */
  29630. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29631. /**
  29632. * Set the value of an uniform to a boolean
  29633. * @param uniform defines the webGL uniform location where to store the value
  29634. * @param bool defines the boolean to store
  29635. */
  29636. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29637. /**
  29638. * Set the value of an uniform to a vec4
  29639. * @param uniform defines the webGL uniform location where to store the value
  29640. * @param x defines the 1st component of the value
  29641. * @param y defines the 2nd component of the value
  29642. * @param z defines the 3rd component of the value
  29643. * @param w defines the 4th component of the value
  29644. */
  29645. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29646. /**
  29647. * Set the value of an uniform to a Color3
  29648. * @param uniform defines the webGL uniform location where to store the value
  29649. * @param color3 defines the color to store
  29650. */
  29651. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29652. /**
  29653. * Set the value of an uniform to a Color3 and an alpha value
  29654. * @param uniform defines the webGL uniform location where to store the value
  29655. * @param color3 defines the color to store
  29656. * @param alpha defines the alpha component to store
  29657. */
  29658. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29659. /**
  29660. * Sets a Color4 on a uniform variable
  29661. * @param uniform defines the uniform location
  29662. * @param color4 defines the value to be set
  29663. */
  29664. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29665. /**
  29666. * Set various states to the webGL context
  29667. * @param culling defines backface culling state
  29668. * @param zOffset defines the value to apply to zOffset (0 by default)
  29669. * @param force defines if states must be applied even if cache is up to date
  29670. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29671. */
  29672. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29673. /**
  29674. * Set the z offset to apply to current rendering
  29675. * @param value defines the offset to apply
  29676. */
  29677. setZOffset(value: number): void;
  29678. /**
  29679. * Gets the current value of the zOffset
  29680. * @returns the current zOffset state
  29681. */
  29682. getZOffset(): number;
  29683. /**
  29684. * Enable or disable depth buffering
  29685. * @param enable defines the state to set
  29686. */
  29687. setDepthBuffer(enable: boolean): void;
  29688. /**
  29689. * Gets a boolean indicating if depth writing is enabled
  29690. * @returns the current depth writing state
  29691. */
  29692. getDepthWrite(): boolean;
  29693. /**
  29694. * Enable or disable depth writing
  29695. * @param enable defines the state to set
  29696. */
  29697. setDepthWrite(enable: boolean): void;
  29698. /**
  29699. * Enable or disable color writing
  29700. * @param enable defines the state to set
  29701. */
  29702. setColorWrite(enable: boolean): void;
  29703. /**
  29704. * Gets a boolean indicating if color writing is enabled
  29705. * @returns the current color writing state
  29706. */
  29707. getColorWrite(): boolean;
  29708. /**
  29709. * Sets alpha constants used by some alpha blending modes
  29710. * @param r defines the red component
  29711. * @param g defines the green component
  29712. * @param b defines the blue component
  29713. * @param a defines the alpha component
  29714. */
  29715. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29716. /**
  29717. * Sets the current alpha mode
  29718. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29719. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29721. */
  29722. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29723. /**
  29724. * Gets the current alpha mode
  29725. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29726. * @returns the current alpha mode
  29727. */
  29728. getAlphaMode(): number;
  29729. /**
  29730. * Clears the list of texture accessible through engine.
  29731. * This can help preventing texture load conflict due to name collision.
  29732. */
  29733. clearInternalTexturesCache(): void;
  29734. /**
  29735. * Force the entire cache to be cleared
  29736. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29737. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29738. */
  29739. wipeCaches(bruteForce?: boolean): void;
  29740. /**
  29741. * Set the compressed texture format to use, based on the formats you have, and the formats
  29742. * supported by the hardware / browser.
  29743. *
  29744. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29745. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29746. * to API arguments needed to compressed textures. This puts the burden on the container
  29747. * generator to house the arcane code for determining these for current & future formats.
  29748. *
  29749. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29750. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29751. *
  29752. * Note: The result of this call is not taken into account when a texture is base64.
  29753. *
  29754. * @param formatsAvailable defines the list of those format families you have created
  29755. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29756. *
  29757. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29758. * @returns The extension selected.
  29759. */
  29760. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29761. /** @hidden */
  29762. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29763. min: number;
  29764. mag: number;
  29765. };
  29766. /** @hidden */
  29767. _createTexture(): WebGLTexture;
  29768. /**
  29769. * Usually called from Texture.ts.
  29770. * Passed information to create a WebGLTexture
  29771. * @param urlArg defines a value which contains one of the following:
  29772. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29773. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29774. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29776. * @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)
  29777. * @param scene needed for loading to the correct scene
  29778. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29779. * @param onLoad optional callback to be called upon successful completion
  29780. * @param onError optional callback to be called upon failure
  29781. * @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
  29782. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29783. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29784. * @param forcedExtension defines the extension to use to pick the right loader
  29785. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29786. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29787. */
  29788. 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;
  29789. /**
  29790. * @hidden
  29791. * Rescales a texture
  29792. * @param source input texutre
  29793. * @param destination destination texture
  29794. * @param scene scene to use to render the resize
  29795. * @param internalFormat format to use when resizing
  29796. * @param onComplete callback to be called when resize has completed
  29797. */
  29798. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29799. private _unpackFlipYCached;
  29800. /**
  29801. * In case you are sharing the context with other applications, it might
  29802. * be interested to not cache the unpack flip y state to ensure a consistent
  29803. * value would be set.
  29804. */
  29805. enableUnpackFlipYCached: boolean;
  29806. /** @hidden */
  29807. _unpackFlipY(value: boolean): void;
  29808. /** @hidden */
  29809. _getUnpackAlignement(): number;
  29810. /**
  29811. * Creates a dynamic texture
  29812. * @param width defines the width of the texture
  29813. * @param height defines the height of the texture
  29814. * @param generateMipMaps defines if the engine should generate the mip levels
  29815. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29816. * @returns the dynamic texture inside an InternalTexture
  29817. */
  29818. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29819. /**
  29820. * Update the sampling mode of a given texture
  29821. * @param samplingMode defines the required sampling mode
  29822. * @param texture defines the texture to update
  29823. */
  29824. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29825. /**
  29826. * Update the content of a dynamic texture
  29827. * @param texture defines the texture to update
  29828. * @param canvas defines the canvas containing the source
  29829. * @param invertY defines if data must be stored with Y axis inverted
  29830. * @param premulAlpha defines if alpha is stored as premultiplied
  29831. * @param format defines the format of the data
  29832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29833. */
  29834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29835. /**
  29836. * Update a video texture
  29837. * @param texture defines the texture to update
  29838. * @param video defines the video element to use
  29839. * @param invertY defines if data must be stored with Y axis inverted
  29840. */
  29841. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29842. /**
  29843. * Updates a depth texture Comparison Mode and Function.
  29844. * If the comparison Function is equal to 0, the mode will be set to none.
  29845. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29846. * @param texture The texture to set the comparison function for
  29847. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29848. */
  29849. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29850. /** @hidden */
  29851. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29852. width: number;
  29853. height: number;
  29854. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29855. /**
  29856. * Creates a depth stencil texture.
  29857. * This is only available in WebGL 2 or with the depth texture extension available.
  29858. * @param size The size of face edge in the texture.
  29859. * @param options The options defining the texture.
  29860. * @returns The texture
  29861. */
  29862. createDepthStencilTexture(size: number | {
  29863. width: number;
  29864. height: number;
  29865. }, options: DepthTextureCreationOptions): InternalTexture;
  29866. /**
  29867. * Creates a depth stencil texture.
  29868. * This is only available in WebGL 2 or with the depth texture extension available.
  29869. * @param size The size of face edge in the texture.
  29870. * @param options The options defining the texture.
  29871. * @returns The texture
  29872. */
  29873. private _createDepthStencilTexture;
  29874. /**
  29875. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29876. * @param renderTarget The render target to set the frame buffer for
  29877. */
  29878. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29879. /**
  29880. * Creates a new render target texture
  29881. * @param size defines the size of the texture
  29882. * @param options defines the options used to create the texture
  29883. * @returns a new render target texture stored in an InternalTexture
  29884. */
  29885. createRenderTargetTexture(size: number | {
  29886. width: number;
  29887. height: number;
  29888. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29889. /** @hidden */
  29890. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29891. /**
  29892. * Updates the sample count of a render target texture
  29893. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29894. * @param texture defines the texture to update
  29895. * @param samples defines the sample count to set
  29896. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29897. */
  29898. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29899. /** @hidden */
  29900. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29901. /** @hidden */
  29902. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29903. /** @hidden */
  29904. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29905. /** @hidden */
  29906. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29907. /**
  29908. * @hidden
  29909. */
  29910. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29911. private _prepareWebGLTextureContinuation;
  29912. private _prepareWebGLTexture;
  29913. /** @hidden */
  29914. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29915. /** @hidden */
  29916. _releaseFramebufferObjects(texture: InternalTexture): void;
  29917. /** @hidden */
  29918. _releaseTexture(texture: InternalTexture): void;
  29919. private setProgram;
  29920. private _boundUniforms;
  29921. /**
  29922. * Binds an effect to the webGL context
  29923. * @param effect defines the effect to bind
  29924. */
  29925. bindSamplers(effect: Effect): void;
  29926. private _activateCurrentTexture;
  29927. /** @hidden */
  29928. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29929. /** @hidden */
  29930. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29931. /**
  29932. * Sets a texture to the webGL context from a postprocess
  29933. * @param channel defines the channel to use
  29934. * @param postProcess defines the source postprocess
  29935. */
  29936. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29937. /**
  29938. * Binds the output of the passed in post process to the texture channel specified
  29939. * @param channel The channel the texture should be bound to
  29940. * @param postProcess The post process which's output should be bound
  29941. */
  29942. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29943. /**
  29944. * Unbind all textures from the webGL context
  29945. */
  29946. unbindAllTextures(): void;
  29947. /**
  29948. * Sets a texture to the according uniform.
  29949. * @param channel The texture channel
  29950. * @param uniform The uniform to set
  29951. * @param texture The texture to apply
  29952. */
  29953. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29954. /**
  29955. * Sets a depth stencil texture from a render target to the according uniform.
  29956. * @param channel The texture channel
  29957. * @param uniform The uniform to set
  29958. * @param texture The render target texture containing the depth stencil texture to apply
  29959. */
  29960. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29961. private _bindSamplerUniformToChannel;
  29962. private _getTextureWrapMode;
  29963. private _setTexture;
  29964. /**
  29965. * Sets an array of texture to the webGL context
  29966. * @param channel defines the channel where the texture array must be set
  29967. * @param uniform defines the associated uniform location
  29968. * @param textures defines the array of textures to bind
  29969. */
  29970. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29971. /** @hidden */
  29972. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29973. private _setTextureParameterFloat;
  29974. private _setTextureParameterInteger;
  29975. /**
  29976. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29977. * @param x defines the x coordinate of the rectangle where pixels must be read
  29978. * @param y defines the y coordinate of the rectangle where pixels must be read
  29979. * @param width defines the width of the rectangle where pixels must be read
  29980. * @param height defines the height of the rectangle where pixels must be read
  29981. * @returns a Uint8Array containing RGBA colors
  29982. */
  29983. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29984. /**
  29985. * Add an externaly attached data from its key.
  29986. * This method call will fail and return false, if such key already exists.
  29987. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29988. * @param key the unique key that identifies the data
  29989. * @param data the data object to associate to the key for this Engine instance
  29990. * @return true if no such key were already present and the data was added successfully, false otherwise
  29991. */
  29992. addExternalData<T>(key: string, data: T): boolean;
  29993. /**
  29994. * Get an externaly attached data from its key
  29995. * @param key the unique key that identifies the data
  29996. * @return the associated data, if present (can be null), or undefined if not present
  29997. */
  29998. getExternalData<T>(key: string): T;
  29999. /**
  30000. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30001. * @param key the unique key that identifies the data
  30002. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30003. * @return the associated data, can be null if the factory returned null.
  30004. */
  30005. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30006. /**
  30007. * Remove an externaly attached data from the Engine instance
  30008. * @param key the unique key that identifies the data
  30009. * @return true if the data was successfully removed, false if it doesn't exist
  30010. */
  30011. removeExternalData(key: string): boolean;
  30012. /**
  30013. * Unbind all vertex attributes from the webGL context
  30014. */
  30015. unbindAllAttributes(): void;
  30016. /**
  30017. * 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
  30018. */
  30019. releaseEffects(): void;
  30020. /**
  30021. * Dispose and release all associated resources
  30022. */
  30023. dispose(): void;
  30024. /**
  30025. * Display the loading screen
  30026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30027. */
  30028. displayLoadingUI(): void;
  30029. /**
  30030. * Hide the loading screen
  30031. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30032. */
  30033. hideLoadingUI(): void;
  30034. /**
  30035. * Gets the current loading screen object
  30036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30037. */
  30038. /**
  30039. * Sets the current loading screen object
  30040. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30041. */
  30042. loadingScreen: ILoadingScreen;
  30043. /**
  30044. * Sets the current loading screen text
  30045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30046. */
  30047. loadingUIText: string;
  30048. /**
  30049. * Sets the current loading screen background color
  30050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30051. */
  30052. loadingUIBackgroundColor: string;
  30053. /**
  30054. * Attach a new callback raised when context lost event is fired
  30055. * @param callback defines the callback to call
  30056. */
  30057. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30058. /**
  30059. * Attach a new callback raised when context restored event is fired
  30060. * @param callback defines the callback to call
  30061. */
  30062. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30063. /**
  30064. * Gets the source code of the vertex shader associated with a specific webGL program
  30065. * @param program defines the program to use
  30066. * @returns a string containing the source code of the vertex shader associated with the program
  30067. */
  30068. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30069. /**
  30070. * Gets the source code of the fragment shader associated with a specific webGL program
  30071. * @param program defines the program to use
  30072. * @returns a string containing the source code of the fragment shader associated with the program
  30073. */
  30074. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30075. /**
  30076. * Get the current error code of the webGL context
  30077. * @returns the error code
  30078. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30079. */
  30080. getError(): number;
  30081. /**
  30082. * Gets the current framerate
  30083. * @returns a number representing the framerate
  30084. */
  30085. getFps(): number;
  30086. /**
  30087. * Gets the time spent between current and previous frame
  30088. * @returns a number representing the delta time in ms
  30089. */
  30090. getDeltaTime(): number;
  30091. private _measureFps;
  30092. /** @hidden */
  30093. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30094. private _canRenderToFloatFramebuffer;
  30095. private _canRenderToHalfFloatFramebuffer;
  30096. private _canRenderToFramebuffer;
  30097. /** @hidden */
  30098. _getWebGLTextureType(type: number): number;
  30099. /** @hidden */
  30100. _getInternalFormat(format: number): number;
  30101. /** @hidden */
  30102. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30103. /** @hidden */
  30104. _getRGBAMultiSampleBufferFormat(type: number): number;
  30105. /** @hidden */
  30106. _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;
  30107. /** @hidden */
  30108. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30109. /**
  30110. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30111. * @returns true if the engine can be created
  30112. * @ignorenaming
  30113. */
  30114. static isSupported(): boolean;
  30115. }
  30116. }
  30117. declare module "babylonjs/Materials/effect" {
  30118. import { Observable } from "babylonjs/Misc/observable";
  30119. import { Nullable } from "babylonjs/types";
  30120. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30121. import { IDisposable } from "babylonjs/scene";
  30122. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30123. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30124. import { Engine } from "babylonjs/Engines/engine";
  30125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30128. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30130. /**
  30131. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30132. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30133. */
  30134. export class EffectFallbacks {
  30135. private _defines;
  30136. private _currentRank;
  30137. private _maxRank;
  30138. private _mesh;
  30139. /**
  30140. * Removes the fallback from the bound mesh.
  30141. */
  30142. unBindMesh(): void;
  30143. /**
  30144. * Adds a fallback on the specified property.
  30145. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30146. * @param define The name of the define in the shader
  30147. */
  30148. addFallback(rank: number, define: string): void;
  30149. /**
  30150. * Sets the mesh to use CPU skinning when needing to fallback.
  30151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30152. * @param mesh The mesh to use the fallbacks.
  30153. */
  30154. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30155. /**
  30156. * Checks to see if more fallbacks are still availible.
  30157. */
  30158. readonly isMoreFallbacks: boolean;
  30159. /**
  30160. * Removes the defines that should be removed when falling back.
  30161. * @param currentDefines defines the current define statements for the shader.
  30162. * @param effect defines the current effect we try to compile
  30163. * @returns The resulting defines with defines of the current rank removed.
  30164. */
  30165. reduce(currentDefines: string, effect: Effect): string;
  30166. }
  30167. /**
  30168. * Options to be used when creating an effect.
  30169. */
  30170. export class EffectCreationOptions {
  30171. /**
  30172. * Atrributes that will be used in the shader.
  30173. */
  30174. attributes: string[];
  30175. /**
  30176. * Uniform varible names that will be set in the shader.
  30177. */
  30178. uniformsNames: string[];
  30179. /**
  30180. * Uniform buffer varible names that will be set in the shader.
  30181. */
  30182. uniformBuffersNames: string[];
  30183. /**
  30184. * Sampler texture variable names that will be set in the shader.
  30185. */
  30186. samplers: string[];
  30187. /**
  30188. * Define statements that will be set in the shader.
  30189. */
  30190. defines: any;
  30191. /**
  30192. * Possible fallbacks for this effect to improve performance when needed.
  30193. */
  30194. fallbacks: Nullable<EffectFallbacks>;
  30195. /**
  30196. * Callback that will be called when the shader is compiled.
  30197. */
  30198. onCompiled: Nullable<(effect: Effect) => void>;
  30199. /**
  30200. * Callback that will be called if an error occurs during shader compilation.
  30201. */
  30202. onError: Nullable<(effect: Effect, errors: string) => void>;
  30203. /**
  30204. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30205. */
  30206. indexParameters: any;
  30207. /**
  30208. * Max number of lights that can be used in the shader.
  30209. */
  30210. maxSimultaneousLights: number;
  30211. /**
  30212. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30213. */
  30214. transformFeedbackVaryings: Nullable<string[]>;
  30215. }
  30216. /**
  30217. * Effect containing vertex and fragment shader that can be executed on an object.
  30218. */
  30219. export class Effect implements IDisposable {
  30220. /**
  30221. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30222. */
  30223. static ShadersRepository: string;
  30224. /**
  30225. * Name of the effect.
  30226. */
  30227. name: any;
  30228. /**
  30229. * String container all the define statements that should be set on the shader.
  30230. */
  30231. defines: string;
  30232. /**
  30233. * Callback that will be called when the shader is compiled.
  30234. */
  30235. onCompiled: Nullable<(effect: Effect) => void>;
  30236. /**
  30237. * Callback that will be called if an error occurs during shader compilation.
  30238. */
  30239. onError: Nullable<(effect: Effect, errors: string) => void>;
  30240. /**
  30241. * Callback that will be called when effect is bound.
  30242. */
  30243. onBind: Nullable<(effect: Effect) => void>;
  30244. /**
  30245. * Unique ID of the effect.
  30246. */
  30247. uniqueId: number;
  30248. /**
  30249. * Observable that will be called when the shader is compiled.
  30250. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30251. */
  30252. onCompileObservable: Observable<Effect>;
  30253. /**
  30254. * Observable that will be called if an error occurs during shader compilation.
  30255. */
  30256. onErrorObservable: Observable<Effect>;
  30257. /** @hidden */
  30258. _onBindObservable: Nullable<Observable<Effect>>;
  30259. /**
  30260. * Observable that will be called when effect is bound.
  30261. */
  30262. readonly onBindObservable: Observable<Effect>;
  30263. /** @hidden */
  30264. _bonesComputationForcedToCPU: boolean;
  30265. private static _uniqueIdSeed;
  30266. private _engine;
  30267. private _uniformBuffersNames;
  30268. private _uniformsNames;
  30269. private _samplerList;
  30270. private _samplers;
  30271. private _isReady;
  30272. private _compilationError;
  30273. private _attributesNames;
  30274. private _attributes;
  30275. private _uniforms;
  30276. /**
  30277. * Key for the effect.
  30278. * @hidden
  30279. */
  30280. _key: string;
  30281. private _indexParameters;
  30282. private _fallbacks;
  30283. private _vertexSourceCode;
  30284. private _fragmentSourceCode;
  30285. private _vertexSourceCodeOverride;
  30286. private _fragmentSourceCodeOverride;
  30287. private _transformFeedbackVaryings;
  30288. /**
  30289. * Compiled shader to webGL program.
  30290. * @hidden
  30291. */
  30292. _pipelineContext: Nullable<IPipelineContext>;
  30293. private _valueCache;
  30294. private static _baseCache;
  30295. /**
  30296. * Instantiates an effect.
  30297. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30298. * @param baseName Name of the effect.
  30299. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30300. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30301. * @param samplers List of sampler variables that will be passed to the shader.
  30302. * @param engine Engine to be used to render the effect
  30303. * @param defines Define statements to be added to the shader.
  30304. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30305. * @param onCompiled Callback that will be called when the shader is compiled.
  30306. * @param onError Callback that will be called if an error occurs during shader compilation.
  30307. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30308. */
  30309. 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);
  30310. private _useFinalCode;
  30311. /**
  30312. * Unique key for this effect
  30313. */
  30314. readonly key: string;
  30315. /**
  30316. * If the effect has been compiled and prepared.
  30317. * @returns if the effect is compiled and prepared.
  30318. */
  30319. isReady(): boolean;
  30320. /**
  30321. * The engine the effect was initialized with.
  30322. * @returns the engine.
  30323. */
  30324. getEngine(): Engine;
  30325. /**
  30326. * The pipeline context for this effect
  30327. * @returns the associated pipeline context
  30328. */
  30329. getPipelineContext(): Nullable<IPipelineContext>;
  30330. /**
  30331. * The set of names of attribute variables for the shader.
  30332. * @returns An array of attribute names.
  30333. */
  30334. getAttributesNames(): string[];
  30335. /**
  30336. * Returns the attribute at the given index.
  30337. * @param index The index of the attribute.
  30338. * @returns The location of the attribute.
  30339. */
  30340. getAttributeLocation(index: number): number;
  30341. /**
  30342. * Returns the attribute based on the name of the variable.
  30343. * @param name of the attribute to look up.
  30344. * @returns the attribute location.
  30345. */
  30346. getAttributeLocationByName(name: string): number;
  30347. /**
  30348. * The number of attributes.
  30349. * @returns the numnber of attributes.
  30350. */
  30351. getAttributesCount(): number;
  30352. /**
  30353. * Gets the index of a uniform variable.
  30354. * @param uniformName of the uniform to look up.
  30355. * @returns the index.
  30356. */
  30357. getUniformIndex(uniformName: string): number;
  30358. /**
  30359. * Returns the attribute based on the name of the variable.
  30360. * @param uniformName of the uniform to look up.
  30361. * @returns the location of the uniform.
  30362. */
  30363. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30364. /**
  30365. * Returns an array of sampler variable names
  30366. * @returns The array of sampler variable neames.
  30367. */
  30368. getSamplers(): string[];
  30369. /**
  30370. * The error from the last compilation.
  30371. * @returns the error string.
  30372. */
  30373. getCompilationError(): string;
  30374. /**
  30375. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30376. * @param func The callback to be used.
  30377. */
  30378. executeWhenCompiled(func: (effect: Effect) => void): void;
  30379. private _checkIsReady;
  30380. /** @hidden */
  30381. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30382. /** @hidden */
  30383. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30384. /** @hidden */
  30385. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30386. /**
  30387. * Recompiles the webGL program
  30388. * @param vertexSourceCode The source code for the vertex shader.
  30389. * @param fragmentSourceCode The source code for the fragment shader.
  30390. * @param onCompiled Callback called when completed.
  30391. * @param onError Callback called on error.
  30392. * @hidden
  30393. */
  30394. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30395. /**
  30396. * Prepares the effect
  30397. * @hidden
  30398. */
  30399. _prepareEffect(): void;
  30400. /**
  30401. * Checks if the effect is supported. (Must be called after compilation)
  30402. */
  30403. readonly isSupported: boolean;
  30404. /**
  30405. * Binds a texture to the engine to be used as output of the shader.
  30406. * @param channel Name of the output variable.
  30407. * @param texture Texture to bind.
  30408. * @hidden
  30409. */
  30410. _bindTexture(channel: string, texture: InternalTexture): void;
  30411. /**
  30412. * Sets a texture on the engine to be used in the shader.
  30413. * @param channel Name of the sampler variable.
  30414. * @param texture Texture to set.
  30415. */
  30416. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30417. /**
  30418. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30419. * @param channel Name of the sampler variable.
  30420. * @param texture Texture to set.
  30421. */
  30422. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30423. /**
  30424. * Sets an array of textures on the engine to be used in the shader.
  30425. * @param channel Name of the variable.
  30426. * @param textures Textures to set.
  30427. */
  30428. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30429. /**
  30430. * 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)
  30431. * @param channel Name of the sampler variable.
  30432. * @param postProcess Post process to get the input texture from.
  30433. */
  30434. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30435. /**
  30436. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30437. * 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)
  30438. * @param channel Name of the sampler variable.
  30439. * @param postProcess Post process to get the output texture from.
  30440. */
  30441. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30442. /** @hidden */
  30443. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30444. /** @hidden */
  30445. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30446. /** @hidden */
  30447. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30448. /** @hidden */
  30449. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30450. /**
  30451. * Binds a buffer to a uniform.
  30452. * @param buffer Buffer to bind.
  30453. * @param name Name of the uniform variable to bind to.
  30454. */
  30455. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30456. /**
  30457. * Binds block to a uniform.
  30458. * @param blockName Name of the block to bind.
  30459. * @param index Index to bind.
  30460. */
  30461. bindUniformBlock(blockName: string, index: number): void;
  30462. /**
  30463. * Sets an interger value on a uniform variable.
  30464. * @param uniformName Name of the variable.
  30465. * @param value Value to be set.
  30466. * @returns this effect.
  30467. */
  30468. setInt(uniformName: string, value: number): Effect;
  30469. /**
  30470. * Sets an int array on a uniform variable.
  30471. * @param uniformName Name of the variable.
  30472. * @param array array to be set.
  30473. * @returns this effect.
  30474. */
  30475. setIntArray(uniformName: string, array: Int32Array): Effect;
  30476. /**
  30477. * 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)
  30478. * @param uniformName Name of the variable.
  30479. * @param array array to be set.
  30480. * @returns this effect.
  30481. */
  30482. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30483. /**
  30484. * 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)
  30485. * @param uniformName Name of the variable.
  30486. * @param array array to be set.
  30487. * @returns this effect.
  30488. */
  30489. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30490. /**
  30491. * 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)
  30492. * @param uniformName Name of the variable.
  30493. * @param array array to be set.
  30494. * @returns this effect.
  30495. */
  30496. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30497. /**
  30498. * Sets an float array on a uniform variable.
  30499. * @param uniformName Name of the variable.
  30500. * @param array array to be set.
  30501. * @returns this effect.
  30502. */
  30503. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30504. /**
  30505. * 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)
  30506. * @param uniformName Name of the variable.
  30507. * @param array array to be set.
  30508. * @returns this effect.
  30509. */
  30510. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30511. /**
  30512. * 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)
  30513. * @param uniformName Name of the variable.
  30514. * @param array array to be set.
  30515. * @returns this effect.
  30516. */
  30517. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30518. /**
  30519. * 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)
  30520. * @param uniformName Name of the variable.
  30521. * @param array array to be set.
  30522. * @returns this effect.
  30523. */
  30524. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30525. /**
  30526. * Sets an array on a uniform variable.
  30527. * @param uniformName Name of the variable.
  30528. * @param array array to be set.
  30529. * @returns this effect.
  30530. */
  30531. setArray(uniformName: string, array: number[]): Effect;
  30532. /**
  30533. * 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)
  30534. * @param uniformName Name of the variable.
  30535. * @param array array to be set.
  30536. * @returns this effect.
  30537. */
  30538. setArray2(uniformName: string, array: number[]): Effect;
  30539. /**
  30540. * 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)
  30541. * @param uniformName Name of the variable.
  30542. * @param array array to be set.
  30543. * @returns this effect.
  30544. */
  30545. setArray3(uniformName: string, array: number[]): Effect;
  30546. /**
  30547. * 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)
  30548. * @param uniformName Name of the variable.
  30549. * @param array array to be set.
  30550. * @returns this effect.
  30551. */
  30552. setArray4(uniformName: string, array: number[]): Effect;
  30553. /**
  30554. * Sets matrices on a uniform variable.
  30555. * @param uniformName Name of the variable.
  30556. * @param matrices matrices to be set.
  30557. * @returns this effect.
  30558. */
  30559. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30560. /**
  30561. * Sets matrix on a uniform variable.
  30562. * @param uniformName Name of the variable.
  30563. * @param matrix matrix to be set.
  30564. * @returns this effect.
  30565. */
  30566. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30567. /**
  30568. * 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)
  30569. * @param uniformName Name of the variable.
  30570. * @param matrix matrix to be set.
  30571. * @returns this effect.
  30572. */
  30573. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30574. /**
  30575. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30576. * @param uniformName Name of the variable.
  30577. * @param matrix matrix to be set.
  30578. * @returns this effect.
  30579. */
  30580. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30581. /**
  30582. * Sets a float on a uniform variable.
  30583. * @param uniformName Name of the variable.
  30584. * @param value value to be set.
  30585. * @returns this effect.
  30586. */
  30587. setFloat(uniformName: string, value: number): Effect;
  30588. /**
  30589. * Sets a boolean on a uniform variable.
  30590. * @param uniformName Name of the variable.
  30591. * @param bool value to be set.
  30592. * @returns this effect.
  30593. */
  30594. setBool(uniformName: string, bool: boolean): Effect;
  30595. /**
  30596. * Sets a Vector2 on a uniform variable.
  30597. * @param uniformName Name of the variable.
  30598. * @param vector2 vector2 to be set.
  30599. * @returns this effect.
  30600. */
  30601. setVector2(uniformName: string, vector2: Vector2): Effect;
  30602. /**
  30603. * Sets a float2 on a uniform variable.
  30604. * @param uniformName Name of the variable.
  30605. * @param x First float in float2.
  30606. * @param y Second float in float2.
  30607. * @returns this effect.
  30608. */
  30609. setFloat2(uniformName: string, x: number, y: number): Effect;
  30610. /**
  30611. * Sets a Vector3 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param vector3 Value to be set.
  30614. * @returns this effect.
  30615. */
  30616. setVector3(uniformName: string, vector3: Vector3): Effect;
  30617. /**
  30618. * Sets a float3 on a uniform variable.
  30619. * @param uniformName Name of the variable.
  30620. * @param x First float in float3.
  30621. * @param y Second float in float3.
  30622. * @param z Third float in float3.
  30623. * @returns this effect.
  30624. */
  30625. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30626. /**
  30627. * Sets a Vector4 on a uniform variable.
  30628. * @param uniformName Name of the variable.
  30629. * @param vector4 Value to be set.
  30630. * @returns this effect.
  30631. */
  30632. setVector4(uniformName: string, vector4: Vector4): Effect;
  30633. /**
  30634. * Sets a float4 on a uniform variable.
  30635. * @param uniformName Name of the variable.
  30636. * @param x First float in float4.
  30637. * @param y Second float in float4.
  30638. * @param z Third float in float4.
  30639. * @param w Fourth float in float4.
  30640. * @returns this effect.
  30641. */
  30642. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30643. /**
  30644. * Sets a Color3 on a uniform variable.
  30645. * @param uniformName Name of the variable.
  30646. * @param color3 Value to be set.
  30647. * @returns this effect.
  30648. */
  30649. setColor3(uniformName: string, color3: Color3): Effect;
  30650. /**
  30651. * Sets a Color4 on a uniform variable.
  30652. * @param uniformName Name of the variable.
  30653. * @param color3 Value to be set.
  30654. * @param alpha Alpha value to be set.
  30655. * @returns this effect.
  30656. */
  30657. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30658. /**
  30659. * Sets a Color4 on a uniform variable
  30660. * @param uniformName defines the name of the variable
  30661. * @param color4 defines the value to be set
  30662. * @returns this effect.
  30663. */
  30664. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30665. /** Release all associated resources */
  30666. dispose(): void;
  30667. /**
  30668. * This function will add a new shader to the shader store
  30669. * @param name the name of the shader
  30670. * @param pixelShader optional pixel shader content
  30671. * @param vertexShader optional vertex shader content
  30672. */
  30673. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30674. /**
  30675. * Store of each shader (The can be looked up using effect.key)
  30676. */
  30677. static ShadersStore: {
  30678. [key: string]: string;
  30679. };
  30680. /**
  30681. * Store of each included file for a shader (The can be looked up using effect.key)
  30682. */
  30683. static IncludesShadersStore: {
  30684. [key: string]: string;
  30685. };
  30686. /**
  30687. * Resets the cache of effects.
  30688. */
  30689. static ResetCache(): void;
  30690. }
  30691. }
  30692. declare module "babylonjs/Materials/colorCurves" {
  30693. import { Effect } from "babylonjs/Materials/effect";
  30694. /**
  30695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30697. * 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;
  30698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30699. */
  30700. export class ColorCurves {
  30701. private _dirty;
  30702. private _tempColor;
  30703. private _globalCurve;
  30704. private _highlightsCurve;
  30705. private _midtonesCurve;
  30706. private _shadowsCurve;
  30707. private _positiveCurve;
  30708. private _negativeCurve;
  30709. private _globalHue;
  30710. private _globalDensity;
  30711. private _globalSaturation;
  30712. private _globalExposure;
  30713. /**
  30714. * Gets the global Hue value.
  30715. * 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).
  30716. */
  30717. /**
  30718. * Sets the global Hue value.
  30719. * 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).
  30720. */
  30721. globalHue: number;
  30722. /**
  30723. * Gets the global Density value.
  30724. * 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.
  30725. * Values less than zero provide a filter of opposite hue.
  30726. */
  30727. /**
  30728. * Sets the global Density value.
  30729. * 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.
  30730. * Values less than zero provide a filter of opposite hue.
  30731. */
  30732. globalDensity: number;
  30733. /**
  30734. * Gets the global Saturation value.
  30735. * 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.
  30736. */
  30737. /**
  30738. * Sets the global Saturation value.
  30739. * 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.
  30740. */
  30741. globalSaturation: number;
  30742. /**
  30743. * Gets the global Exposure value.
  30744. * 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.
  30745. */
  30746. /**
  30747. * Sets the global Exposure value.
  30748. * 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.
  30749. */
  30750. globalExposure: number;
  30751. private _highlightsHue;
  30752. private _highlightsDensity;
  30753. private _highlightsSaturation;
  30754. private _highlightsExposure;
  30755. /**
  30756. * Gets the highlights Hue value.
  30757. * 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).
  30758. */
  30759. /**
  30760. * Sets the highlights Hue value.
  30761. * 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).
  30762. */
  30763. highlightsHue: number;
  30764. /**
  30765. * Gets the highlights Density value.
  30766. * 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.
  30767. * Values less than zero provide a filter of opposite hue.
  30768. */
  30769. /**
  30770. * Sets the highlights Density value.
  30771. * 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.
  30772. * Values less than zero provide a filter of opposite hue.
  30773. */
  30774. highlightsDensity: number;
  30775. /**
  30776. * Gets the highlights Saturation value.
  30777. * 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.
  30778. */
  30779. /**
  30780. * Sets the highlights Saturation value.
  30781. * 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.
  30782. */
  30783. highlightsSaturation: number;
  30784. /**
  30785. * Gets the highlights Exposure value.
  30786. * 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.
  30787. */
  30788. /**
  30789. * Sets the highlights Exposure value.
  30790. * 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.
  30791. */
  30792. highlightsExposure: number;
  30793. private _midtonesHue;
  30794. private _midtonesDensity;
  30795. private _midtonesSaturation;
  30796. private _midtonesExposure;
  30797. /**
  30798. * Gets the midtones Hue value.
  30799. * 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).
  30800. */
  30801. /**
  30802. * Sets the midtones Hue value.
  30803. * 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).
  30804. */
  30805. midtonesHue: number;
  30806. /**
  30807. * Gets the midtones Density value.
  30808. * 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.
  30809. * Values less than zero provide a filter of opposite hue.
  30810. */
  30811. /**
  30812. * Sets the midtones Density value.
  30813. * 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.
  30814. * Values less than zero provide a filter of opposite hue.
  30815. */
  30816. midtonesDensity: number;
  30817. /**
  30818. * Gets the midtones Saturation value.
  30819. * 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.
  30820. */
  30821. /**
  30822. * Sets the midtones Saturation value.
  30823. * 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.
  30824. */
  30825. midtonesSaturation: number;
  30826. /**
  30827. * Gets the midtones Exposure value.
  30828. * 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.
  30829. */
  30830. /**
  30831. * Sets the midtones Exposure value.
  30832. * 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.
  30833. */
  30834. midtonesExposure: number;
  30835. private _shadowsHue;
  30836. private _shadowsDensity;
  30837. private _shadowsSaturation;
  30838. private _shadowsExposure;
  30839. /**
  30840. * Gets the shadows Hue value.
  30841. * 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).
  30842. */
  30843. /**
  30844. * Sets the shadows Hue value.
  30845. * 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).
  30846. */
  30847. shadowsHue: number;
  30848. /**
  30849. * Gets the shadows Density value.
  30850. * 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.
  30851. * Values less than zero provide a filter of opposite hue.
  30852. */
  30853. /**
  30854. * Sets the shadows Density value.
  30855. * 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.
  30856. * Values less than zero provide a filter of opposite hue.
  30857. */
  30858. shadowsDensity: number;
  30859. /**
  30860. * Gets the shadows Saturation value.
  30861. * 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.
  30862. */
  30863. /**
  30864. * Sets the shadows Saturation value.
  30865. * 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.
  30866. */
  30867. shadowsSaturation: number;
  30868. /**
  30869. * Gets the shadows Exposure value.
  30870. * 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.
  30871. */
  30872. /**
  30873. * Sets the shadows Exposure value.
  30874. * 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.
  30875. */
  30876. shadowsExposure: number;
  30877. /**
  30878. * Returns the class name
  30879. * @returns The class name
  30880. */
  30881. getClassName(): string;
  30882. /**
  30883. * Binds the color curves to the shader.
  30884. * @param colorCurves The color curve to bind
  30885. * @param effect The effect to bind to
  30886. * @param positiveUniform The positive uniform shader parameter
  30887. * @param neutralUniform The neutral uniform shader parameter
  30888. * @param negativeUniform The negative uniform shader parameter
  30889. */
  30890. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30891. /**
  30892. * Prepare the list of uniforms associated with the ColorCurves effects.
  30893. * @param uniformsList The list of uniforms used in the effect
  30894. */
  30895. static PrepareUniforms(uniformsList: string[]): void;
  30896. /**
  30897. * Returns color grading data based on a hue, density, saturation and exposure value.
  30898. * @param filterHue The hue of the color filter.
  30899. * @param filterDensity The density of the color filter.
  30900. * @param saturation The saturation.
  30901. * @param exposure The exposure.
  30902. * @param result The result data container.
  30903. */
  30904. private getColorGradingDataToRef;
  30905. /**
  30906. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30907. * @param value The input slider value in range [-100,100].
  30908. * @returns Adjusted value.
  30909. */
  30910. private static applyColorGradingSliderNonlinear;
  30911. /**
  30912. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30913. * @param hue The hue (H) input.
  30914. * @param saturation The saturation (S) input.
  30915. * @param brightness The brightness (B) input.
  30916. * @result An RGBA color represented as Vector4.
  30917. */
  30918. private static fromHSBToRef;
  30919. /**
  30920. * Returns a value clamped between min and max
  30921. * @param value The value to clamp
  30922. * @param min The minimum of value
  30923. * @param max The maximum of value
  30924. * @returns The clamped value.
  30925. */
  30926. private static clamp;
  30927. /**
  30928. * Clones the current color curve instance.
  30929. * @return The cloned curves
  30930. */
  30931. clone(): ColorCurves;
  30932. /**
  30933. * Serializes the current color curve instance to a json representation.
  30934. * @return a JSON representation
  30935. */
  30936. serialize(): any;
  30937. /**
  30938. * Parses the color curve from a json representation.
  30939. * @param source the JSON source to parse
  30940. * @return The parsed curves
  30941. */
  30942. static Parse(source: any): ColorCurves;
  30943. }
  30944. }
  30945. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30946. import { Observable } from "babylonjs/Misc/observable";
  30947. import { Nullable } from "babylonjs/types";
  30948. import { Color4 } from "babylonjs/Maths/math";
  30949. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30950. import { Effect } from "babylonjs/Materials/effect";
  30951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30952. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30953. /**
  30954. * Interface to follow in your material defines to integrate easily the
  30955. * Image proccessing functions.
  30956. * @hidden
  30957. */
  30958. export interface IImageProcessingConfigurationDefines {
  30959. IMAGEPROCESSING: boolean;
  30960. VIGNETTE: boolean;
  30961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30962. VIGNETTEBLENDMODEOPAQUE: boolean;
  30963. TONEMAPPING: boolean;
  30964. TONEMAPPING_ACES: boolean;
  30965. CONTRAST: boolean;
  30966. EXPOSURE: boolean;
  30967. COLORCURVES: boolean;
  30968. COLORGRADING: boolean;
  30969. COLORGRADING3D: boolean;
  30970. SAMPLER3DGREENDEPTH: boolean;
  30971. SAMPLER3DBGRMAP: boolean;
  30972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30973. }
  30974. /**
  30975. * @hidden
  30976. */
  30977. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30978. IMAGEPROCESSING: boolean;
  30979. VIGNETTE: boolean;
  30980. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30981. VIGNETTEBLENDMODEOPAQUE: boolean;
  30982. TONEMAPPING: boolean;
  30983. TONEMAPPING_ACES: boolean;
  30984. CONTRAST: boolean;
  30985. COLORCURVES: boolean;
  30986. COLORGRADING: boolean;
  30987. COLORGRADING3D: boolean;
  30988. SAMPLER3DGREENDEPTH: boolean;
  30989. SAMPLER3DBGRMAP: boolean;
  30990. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30991. EXPOSURE: boolean;
  30992. constructor();
  30993. }
  30994. /**
  30995. * This groups together the common properties used for image processing either in direct forward pass
  30996. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30997. * or not.
  30998. */
  30999. export class ImageProcessingConfiguration {
  31000. /**
  31001. * Default tone mapping applied in BabylonJS.
  31002. */
  31003. static readonly TONEMAPPING_STANDARD: number;
  31004. /**
  31005. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  31006. * to other engines rendering to increase portability.
  31007. */
  31008. static readonly TONEMAPPING_ACES: number;
  31009. /**
  31010. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  31011. */
  31012. colorCurves: Nullable<ColorCurves>;
  31013. private _colorCurvesEnabled;
  31014. /**
  31015. * Gets wether the color curves effect is enabled.
  31016. */
  31017. /**
  31018. * Sets wether the color curves effect is enabled.
  31019. */
  31020. colorCurvesEnabled: boolean;
  31021. private _colorGradingTexture;
  31022. /**
  31023. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31024. */
  31025. /**
  31026. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31027. */
  31028. colorGradingTexture: Nullable<BaseTexture>;
  31029. private _colorGradingEnabled;
  31030. /**
  31031. * Gets wether the color grading effect is enabled.
  31032. */
  31033. /**
  31034. * Sets wether the color grading effect is enabled.
  31035. */
  31036. colorGradingEnabled: boolean;
  31037. private _colorGradingWithGreenDepth;
  31038. /**
  31039. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31040. */
  31041. /**
  31042. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31043. */
  31044. colorGradingWithGreenDepth: boolean;
  31045. private _colorGradingBGR;
  31046. /**
  31047. * Gets wether the color grading texture contains BGR values.
  31048. */
  31049. /**
  31050. * Sets wether the color grading texture contains BGR values.
  31051. */
  31052. colorGradingBGR: boolean;
  31053. /** @hidden */
  31054. _exposure: number;
  31055. /**
  31056. * Gets the Exposure used in the effect.
  31057. */
  31058. /**
  31059. * Sets the Exposure used in the effect.
  31060. */
  31061. exposure: number;
  31062. private _toneMappingEnabled;
  31063. /**
  31064. * Gets wether the tone mapping effect is enabled.
  31065. */
  31066. /**
  31067. * Sets wether the tone mapping effect is enabled.
  31068. */
  31069. toneMappingEnabled: boolean;
  31070. private _toneMappingType;
  31071. /**
  31072. * Gets the type of tone mapping effect.
  31073. */
  31074. /**
  31075. * Sets the type of tone mapping effect used in BabylonJS.
  31076. */
  31077. toneMappingType: number;
  31078. protected _contrast: number;
  31079. /**
  31080. * Gets the contrast used in the effect.
  31081. */
  31082. /**
  31083. * Sets the contrast used in the effect.
  31084. */
  31085. contrast: number;
  31086. /**
  31087. * Vignette stretch size.
  31088. */
  31089. vignetteStretch: number;
  31090. /**
  31091. * Vignette centre X Offset.
  31092. */
  31093. vignetteCentreX: number;
  31094. /**
  31095. * Vignette centre Y Offset.
  31096. */
  31097. vignetteCentreY: number;
  31098. /**
  31099. * Vignette weight or intensity of the vignette effect.
  31100. */
  31101. vignetteWeight: number;
  31102. /**
  31103. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31104. * if vignetteEnabled is set to true.
  31105. */
  31106. vignetteColor: Color4;
  31107. /**
  31108. * Camera field of view used by the Vignette effect.
  31109. */
  31110. vignetteCameraFov: number;
  31111. private _vignetteBlendMode;
  31112. /**
  31113. * Gets the vignette blend mode allowing different kind of effect.
  31114. */
  31115. /**
  31116. * Sets the vignette blend mode allowing different kind of effect.
  31117. */
  31118. vignetteBlendMode: number;
  31119. private _vignetteEnabled;
  31120. /**
  31121. * Gets wether the vignette effect is enabled.
  31122. */
  31123. /**
  31124. * Sets wether the vignette effect is enabled.
  31125. */
  31126. vignetteEnabled: boolean;
  31127. private _applyByPostProcess;
  31128. /**
  31129. * Gets wether the image processing is applied through a post process or not.
  31130. */
  31131. /**
  31132. * Sets wether the image processing is applied through a post process or not.
  31133. */
  31134. applyByPostProcess: boolean;
  31135. private _isEnabled;
  31136. /**
  31137. * Gets wether the image processing is enabled or not.
  31138. */
  31139. /**
  31140. * Sets wether the image processing is enabled or not.
  31141. */
  31142. isEnabled: boolean;
  31143. /**
  31144. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31145. */
  31146. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31147. /**
  31148. * Method called each time the image processing information changes requires to recompile the effect.
  31149. */
  31150. protected _updateParameters(): void;
  31151. /**
  31152. * Gets the current class name.
  31153. * @return "ImageProcessingConfiguration"
  31154. */
  31155. getClassName(): string;
  31156. /**
  31157. * Prepare the list of uniforms associated with the Image Processing effects.
  31158. * @param uniforms The list of uniforms used in the effect
  31159. * @param defines the list of defines currently in use
  31160. */
  31161. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31162. /**
  31163. * Prepare the list of samplers associated with the Image Processing effects.
  31164. * @param samplersList The list of uniforms used in the effect
  31165. * @param defines the list of defines currently in use
  31166. */
  31167. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31168. /**
  31169. * Prepare the list of defines associated to the shader.
  31170. * @param defines the list of defines to complete
  31171. * @param forPostProcess Define if we are currently in post process mode or not
  31172. */
  31173. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31174. /**
  31175. * Returns true if all the image processing information are ready.
  31176. * @returns True if ready, otherwise, false
  31177. */
  31178. isReady(): boolean;
  31179. /**
  31180. * Binds the image processing to the shader.
  31181. * @param effect The effect to bind to
  31182. * @param aspectRatio Define the current aspect ratio of the effect
  31183. */
  31184. bind(effect: Effect, aspectRatio?: number): void;
  31185. /**
  31186. * Clones the current image processing instance.
  31187. * @return The cloned image processing
  31188. */
  31189. clone(): ImageProcessingConfiguration;
  31190. /**
  31191. * Serializes the current image processing instance to a json representation.
  31192. * @return a JSON representation
  31193. */
  31194. serialize(): any;
  31195. /**
  31196. * Parses the image processing from a json representation.
  31197. * @param source the JSON source to parse
  31198. * @return The parsed image processing
  31199. */
  31200. static Parse(source: any): ImageProcessingConfiguration;
  31201. private static _VIGNETTEMODE_MULTIPLY;
  31202. private static _VIGNETTEMODE_OPAQUE;
  31203. /**
  31204. * Used to apply the vignette as a mix with the pixel color.
  31205. */
  31206. static readonly VIGNETTEMODE_MULTIPLY: number;
  31207. /**
  31208. * Used to apply the vignette as a replacement of the pixel color.
  31209. */
  31210. static readonly VIGNETTEMODE_OPAQUE: number;
  31211. }
  31212. }
  31213. declare module "babylonjs/Materials/fresnelParameters" {
  31214. import { Color3 } from "babylonjs/Maths/math";
  31215. /**
  31216. * This represents all the required information to add a fresnel effect on a material:
  31217. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31218. */
  31219. export class FresnelParameters {
  31220. private _isEnabled;
  31221. /**
  31222. * Define if the fresnel effect is enable or not.
  31223. */
  31224. isEnabled: boolean;
  31225. /**
  31226. * Define the color used on edges (grazing angle)
  31227. */
  31228. leftColor: Color3;
  31229. /**
  31230. * Define the color used on center
  31231. */
  31232. rightColor: Color3;
  31233. /**
  31234. * Define bias applied to computed fresnel term
  31235. */
  31236. bias: number;
  31237. /**
  31238. * Defined the power exponent applied to fresnel term
  31239. */
  31240. power: number;
  31241. /**
  31242. * Clones the current fresnel and its valuues
  31243. * @returns a clone fresnel configuration
  31244. */
  31245. clone(): FresnelParameters;
  31246. /**
  31247. * Serializes the current fresnel parameters to a JSON representation.
  31248. * @return the JSON serialization
  31249. */
  31250. serialize(): any;
  31251. /**
  31252. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31253. * @param parsedFresnelParameters Define the JSON representation
  31254. * @returns the parsed parameters
  31255. */
  31256. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31257. }
  31258. }
  31259. declare module "babylonjs/Misc/decorators" {
  31260. import { Nullable } from "babylonjs/types";
  31261. import { Scene } from "babylonjs/scene";
  31262. import { IAnimatable } from "babylonjs/Misc/tools";
  31263. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31264. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31265. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31266. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31267. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31268. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31269. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31270. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31271. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31272. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31273. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31274. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31275. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31276. /**
  31277. * Decorator used to define property that can be serialized as reference to a camera
  31278. * @param sourceName defines the name of the property to decorate
  31279. */
  31280. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31281. /**
  31282. * Class used to help serialization objects
  31283. */
  31284. export class SerializationHelper {
  31285. /** @hidden */
  31286. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31287. /** @hidden */
  31288. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31289. /** @hidden */
  31290. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31291. /** @hidden */
  31292. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31293. /**
  31294. * Appends the serialized animations from the source animations
  31295. * @param source Source containing the animations
  31296. * @param destination Target to store the animations
  31297. */
  31298. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31299. /**
  31300. * Static function used to serialized a specific entity
  31301. * @param entity defines the entity to serialize
  31302. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31303. * @returns a JSON compatible object representing the serialization of the entity
  31304. */
  31305. static Serialize<T>(entity: T, serializationObject?: any): any;
  31306. /**
  31307. * Creates a new entity from a serialization data object
  31308. * @param creationFunction defines a function used to instanciated the new entity
  31309. * @param source defines the source serialization data
  31310. * @param scene defines the hosting scene
  31311. * @param rootUrl defines the root url for resources
  31312. * @returns a new entity
  31313. */
  31314. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31315. /**
  31316. * Clones an object
  31317. * @param creationFunction defines the function used to instanciate the new object
  31318. * @param source defines the source object
  31319. * @returns the cloned object
  31320. */
  31321. static Clone<T>(creationFunction: () => T, source: T): T;
  31322. /**
  31323. * Instanciates a new object based on a source one (some data will be shared between both object)
  31324. * @param creationFunction defines the function used to instanciate the new object
  31325. * @param source defines the source object
  31326. * @returns the new object
  31327. */
  31328. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31329. }
  31330. }
  31331. declare module "babylonjs/Cameras/camera" {
  31332. import { SmartArray } from "babylonjs/Misc/smartArray";
  31333. import { Observable } from "babylonjs/Misc/observable";
  31334. import { Nullable } from "babylonjs/types";
  31335. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31336. import { Scene } from "babylonjs/scene";
  31337. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31338. import { Node } from "babylonjs/node";
  31339. import { Mesh } from "babylonjs/Meshes/mesh";
  31340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31341. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31342. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31344. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31345. import { Ray } from "babylonjs/Culling/ray";
  31346. /**
  31347. * This is the base class of all the camera used in the application.
  31348. * @see http://doc.babylonjs.com/features/cameras
  31349. */
  31350. export class Camera extends Node {
  31351. /** @hidden */
  31352. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31353. /**
  31354. * This is the default projection mode used by the cameras.
  31355. * It helps recreating a feeling of perspective and better appreciate depth.
  31356. * This is the best way to simulate real life cameras.
  31357. */
  31358. static readonly PERSPECTIVE_CAMERA: number;
  31359. /**
  31360. * This helps creating camera with an orthographic mode.
  31361. * 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.
  31362. */
  31363. static readonly ORTHOGRAPHIC_CAMERA: number;
  31364. /**
  31365. * This is the default FOV mode for perspective cameras.
  31366. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31367. */
  31368. static readonly FOVMODE_VERTICAL_FIXED: number;
  31369. /**
  31370. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31371. */
  31372. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31373. /**
  31374. * This specifies ther is no need for a camera rig.
  31375. * Basically only one eye is rendered corresponding to the camera.
  31376. */
  31377. static readonly RIG_MODE_NONE: number;
  31378. /**
  31379. * Simulates a camera Rig with one blue eye and one red eye.
  31380. * This can be use with 3d blue and red glasses.
  31381. */
  31382. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31383. /**
  31384. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31385. */
  31386. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31387. /**
  31388. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31389. */
  31390. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31391. /**
  31392. * Defines that both eyes of the camera will be rendered over under each other.
  31393. */
  31394. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31395. /**
  31396. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31397. */
  31398. static readonly RIG_MODE_VR: number;
  31399. /**
  31400. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31401. */
  31402. static readonly RIG_MODE_WEBVR: number;
  31403. /**
  31404. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31405. */
  31406. static readonly RIG_MODE_CUSTOM: number;
  31407. /**
  31408. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31409. */
  31410. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31411. /**
  31412. * Define the input manager associated with the camera.
  31413. */
  31414. inputs: CameraInputsManager<Camera>;
  31415. /** @hidden */
  31416. _position: Vector3;
  31417. /**
  31418. * Define the current local position of the camera in the scene
  31419. */
  31420. position: Vector3;
  31421. /**
  31422. * The vector the camera should consider as up.
  31423. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31424. */
  31425. upVector: Vector3;
  31426. /**
  31427. * Define the current limit on the left side for an orthographic camera
  31428. * In scene unit
  31429. */
  31430. orthoLeft: Nullable<number>;
  31431. /**
  31432. * Define the current limit on the right side for an orthographic camera
  31433. * In scene unit
  31434. */
  31435. orthoRight: Nullable<number>;
  31436. /**
  31437. * Define the current limit on the bottom side for an orthographic camera
  31438. * In scene unit
  31439. */
  31440. orthoBottom: Nullable<number>;
  31441. /**
  31442. * Define the current limit on the top side for an orthographic camera
  31443. * In scene unit
  31444. */
  31445. orthoTop: Nullable<number>;
  31446. /**
  31447. * Field Of View is set in Radians. (default is 0.8)
  31448. */
  31449. fov: number;
  31450. /**
  31451. * Define the minimum distance the camera can see from.
  31452. * This is important to note that the depth buffer are not infinite and the closer it starts
  31453. * the more your scene might encounter depth fighting issue.
  31454. */
  31455. minZ: number;
  31456. /**
  31457. * Define the maximum distance the camera can see to.
  31458. * This is important to note that the depth buffer are not infinite and the further it end
  31459. * the more your scene might encounter depth fighting issue.
  31460. */
  31461. maxZ: number;
  31462. /**
  31463. * Define the default inertia of the camera.
  31464. * This helps giving a smooth feeling to the camera movement.
  31465. */
  31466. inertia: number;
  31467. /**
  31468. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31469. */
  31470. mode: number;
  31471. /**
  31472. * Define wether the camera is intermediate.
  31473. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31474. */
  31475. isIntermediate: boolean;
  31476. /**
  31477. * Define the viewport of the camera.
  31478. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31479. */
  31480. viewport: Viewport;
  31481. /**
  31482. * Restricts the camera to viewing objects with the same layerMask.
  31483. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31484. */
  31485. layerMask: number;
  31486. /**
  31487. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31488. */
  31489. fovMode: number;
  31490. /**
  31491. * Rig mode of the camera.
  31492. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31493. * This is normally controlled byt the camera themselves as internal use.
  31494. */
  31495. cameraRigMode: number;
  31496. /**
  31497. * Defines the distance between both "eyes" in case of a RIG
  31498. */
  31499. interaxialDistance: number;
  31500. /**
  31501. * Defines if stereoscopic rendering is done side by side or over under.
  31502. */
  31503. isStereoscopicSideBySide: boolean;
  31504. /**
  31505. * 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
  31506. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31507. * else in the scene.
  31508. */
  31509. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31510. /**
  31511. * When set, the camera will render to this render target instead of the default canvas
  31512. */
  31513. outputRenderTarget: Nullable<RenderTargetTexture>;
  31514. /**
  31515. * Observable triggered when the camera view matrix has changed.
  31516. */
  31517. onViewMatrixChangedObservable: Observable<Camera>;
  31518. /**
  31519. * Observable triggered when the camera Projection matrix has changed.
  31520. */
  31521. onProjectionMatrixChangedObservable: Observable<Camera>;
  31522. /**
  31523. * Observable triggered when the inputs have been processed.
  31524. */
  31525. onAfterCheckInputsObservable: Observable<Camera>;
  31526. /**
  31527. * Observable triggered when reset has been called and applied to the camera.
  31528. */
  31529. onRestoreStateObservable: Observable<Camera>;
  31530. /** @hidden */
  31531. _cameraRigParams: any;
  31532. /** @hidden */
  31533. _rigCameras: Camera[];
  31534. /** @hidden */
  31535. _rigPostProcess: Nullable<PostProcess>;
  31536. protected _webvrViewMatrix: Matrix;
  31537. /** @hidden */
  31538. _skipRendering: boolean;
  31539. /** @hidden */
  31540. _projectionMatrix: Matrix;
  31541. /** @hidden */
  31542. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31543. /** @hidden */
  31544. _activeMeshes: SmartArray<AbstractMesh>;
  31545. protected _globalPosition: Vector3;
  31546. /** @hidden */
  31547. _computedViewMatrix: Matrix;
  31548. private _doNotComputeProjectionMatrix;
  31549. private _transformMatrix;
  31550. private _frustumPlanes;
  31551. private _refreshFrustumPlanes;
  31552. private _storedFov;
  31553. private _stateStored;
  31554. /**
  31555. * Instantiates a new camera object.
  31556. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31557. * @see http://doc.babylonjs.com/features/cameras
  31558. * @param name Defines the name of the camera in the scene
  31559. * @param position Defines the position of the camera
  31560. * @param scene Defines the scene the camera belongs too
  31561. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31562. */
  31563. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31564. /**
  31565. * Store current camera state (fov, position, etc..)
  31566. * @returns the camera
  31567. */
  31568. storeState(): Camera;
  31569. /**
  31570. * Restores the camera state values if it has been stored. You must call storeState() first
  31571. */
  31572. protected _restoreStateValues(): boolean;
  31573. /**
  31574. * Restored camera state. You must call storeState() first.
  31575. * @returns true if restored and false otherwise
  31576. */
  31577. restoreState(): boolean;
  31578. /**
  31579. * Gets the class name of the camera.
  31580. * @returns the class name
  31581. */
  31582. getClassName(): string;
  31583. /** @hidden */
  31584. readonly _isCamera: boolean;
  31585. /**
  31586. * Gets a string representation of the camera useful for debug purpose.
  31587. * @param fullDetails Defines that a more verboe level of logging is required
  31588. * @returns the string representation
  31589. */
  31590. toString(fullDetails?: boolean): string;
  31591. /**
  31592. * Gets the current world space position of the camera.
  31593. */
  31594. readonly globalPosition: Vector3;
  31595. /**
  31596. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31597. * @returns the active meshe list
  31598. */
  31599. getActiveMeshes(): SmartArray<AbstractMesh>;
  31600. /**
  31601. * Check wether a mesh is part of the current active mesh list of the camera
  31602. * @param mesh Defines the mesh to check
  31603. * @returns true if active, false otherwise
  31604. */
  31605. isActiveMesh(mesh: Mesh): boolean;
  31606. /**
  31607. * Is this camera ready to be used/rendered
  31608. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31609. * @return true if the camera is ready
  31610. */
  31611. isReady(completeCheck?: boolean): boolean;
  31612. /** @hidden */
  31613. _initCache(): void;
  31614. /** @hidden */
  31615. _updateCache(ignoreParentClass?: boolean): void;
  31616. /** @hidden */
  31617. _isSynchronized(): boolean;
  31618. /** @hidden */
  31619. _isSynchronizedViewMatrix(): boolean;
  31620. /** @hidden */
  31621. _isSynchronizedProjectionMatrix(): boolean;
  31622. /**
  31623. * Attach the input controls to a specific dom element to get the input from.
  31624. * @param element Defines the element the controls should be listened from
  31625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31626. */
  31627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31628. /**
  31629. * Detach the current controls from the specified dom element.
  31630. * @param element Defines the element to stop listening the inputs from
  31631. */
  31632. detachControl(element: HTMLElement): void;
  31633. /**
  31634. * Update the camera state according to the different inputs gathered during the frame.
  31635. */
  31636. update(): void;
  31637. /** @hidden */
  31638. _checkInputs(): void;
  31639. /** @hidden */
  31640. readonly rigCameras: Camera[];
  31641. /**
  31642. * Gets the post process used by the rig cameras
  31643. */
  31644. readonly rigPostProcess: Nullable<PostProcess>;
  31645. /**
  31646. * Internal, gets the first post proces.
  31647. * @returns the first post process to be run on this camera.
  31648. */
  31649. _getFirstPostProcess(): Nullable<PostProcess>;
  31650. private _cascadePostProcessesToRigCams;
  31651. /**
  31652. * Attach a post process to the camera.
  31653. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31654. * @param postProcess The post process to attach to the camera
  31655. * @param insertAt The position of the post process in case several of them are in use in the scene
  31656. * @returns the position the post process has been inserted at
  31657. */
  31658. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31659. /**
  31660. * Detach a post process to the camera.
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31662. * @param postProcess The post process to detach from the camera
  31663. */
  31664. detachPostProcess(postProcess: PostProcess): void;
  31665. /**
  31666. * Gets the current world matrix of the camera
  31667. */
  31668. getWorldMatrix(): Matrix;
  31669. /** @hidden */
  31670. _getViewMatrix(): Matrix;
  31671. /**
  31672. * Gets the current view matrix of the camera.
  31673. * @param force forces the camera to recompute the matrix without looking at the cached state
  31674. * @returns the view matrix
  31675. */
  31676. getViewMatrix(force?: boolean): Matrix;
  31677. /**
  31678. * Freeze the projection matrix.
  31679. * It will prevent the cache check of the camera projection compute and can speed up perf
  31680. * if no parameter of the camera are meant to change
  31681. * @param projection Defines manually a projection if necessary
  31682. */
  31683. freezeProjectionMatrix(projection?: Matrix): void;
  31684. /**
  31685. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31686. */
  31687. unfreezeProjectionMatrix(): void;
  31688. /**
  31689. * Gets the current projection matrix of the camera.
  31690. * @param force forces the camera to recompute the matrix without looking at the cached state
  31691. * @returns the projection matrix
  31692. */
  31693. getProjectionMatrix(force?: boolean): Matrix;
  31694. /**
  31695. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31696. * @returns a Matrix
  31697. */
  31698. getTransformationMatrix(): Matrix;
  31699. private _updateFrustumPlanes;
  31700. /**
  31701. * Checks if a cullable object (mesh...) is in the camera frustum
  31702. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31703. * @param target The object to check
  31704. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31705. * @returns true if the object is in frustum otherwise false
  31706. */
  31707. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31708. /**
  31709. * Checks if a cullable object (mesh...) is in the camera frustum
  31710. * Unlike isInFrustum this cheks the full bounding box
  31711. * @param target The object to check
  31712. * @returns true if the object is in frustum otherwise false
  31713. */
  31714. isCompletelyInFrustum(target: ICullable): boolean;
  31715. /**
  31716. * Gets a ray in the forward direction from the camera.
  31717. * @param length Defines the length of the ray to create
  31718. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31719. * @param origin Defines the start point of the ray which defaults to the camera position
  31720. * @returns the forward ray
  31721. */
  31722. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31723. /**
  31724. * Releases resources associated with this node.
  31725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31727. */
  31728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31729. /** @hidden */
  31730. _isLeftCamera: boolean;
  31731. /**
  31732. * Gets the left camera of a rig setup in case of Rigged Camera
  31733. */
  31734. readonly isLeftCamera: boolean;
  31735. /** @hidden */
  31736. _isRightCamera: boolean;
  31737. /**
  31738. * Gets the right camera of a rig setup in case of Rigged Camera
  31739. */
  31740. readonly isRightCamera: boolean;
  31741. /**
  31742. * Gets the left camera of a rig setup in case of Rigged Camera
  31743. */
  31744. readonly leftCamera: Nullable<FreeCamera>;
  31745. /**
  31746. * Gets the right camera of a rig setup in case of Rigged Camera
  31747. */
  31748. readonly rightCamera: Nullable<FreeCamera>;
  31749. /**
  31750. * Gets the left camera target of a rig setup in case of Rigged Camera
  31751. * @returns the target position
  31752. */
  31753. getLeftTarget(): Nullable<Vector3>;
  31754. /**
  31755. * Gets the right camera target of a rig setup in case of Rigged Camera
  31756. * @returns the target position
  31757. */
  31758. getRightTarget(): Nullable<Vector3>;
  31759. /**
  31760. * @hidden
  31761. */
  31762. setCameraRigMode(mode: number, rigParams: any): void;
  31763. /** @hidden */
  31764. static _setStereoscopicRigMode(camera: Camera): void;
  31765. /** @hidden */
  31766. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31767. /** @hidden */
  31768. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31769. /** @hidden */
  31770. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31771. /** @hidden */
  31772. _getVRProjectionMatrix(): Matrix;
  31773. protected _updateCameraRotationMatrix(): void;
  31774. protected _updateWebVRCameraRotationMatrix(): void;
  31775. /**
  31776. * This function MUST be overwritten by the different WebVR cameras available.
  31777. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31778. * @hidden
  31779. */
  31780. _getWebVRProjectionMatrix(): Matrix;
  31781. /**
  31782. * This function MUST be overwritten by the different WebVR cameras available.
  31783. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31784. * @hidden
  31785. */
  31786. _getWebVRViewMatrix(): Matrix;
  31787. /** @hidden */
  31788. setCameraRigParameter(name: string, value: any): void;
  31789. /**
  31790. * needs to be overridden by children so sub has required properties to be copied
  31791. * @hidden
  31792. */
  31793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31794. /**
  31795. * May need to be overridden by children
  31796. * @hidden
  31797. */
  31798. _updateRigCameras(): void;
  31799. /** @hidden */
  31800. _setupInputs(): void;
  31801. /**
  31802. * Serialiaze the camera setup to a json represention
  31803. * @returns the JSON representation
  31804. */
  31805. serialize(): any;
  31806. /**
  31807. * Clones the current camera.
  31808. * @param name The cloned camera name
  31809. * @returns the cloned camera
  31810. */
  31811. clone(name: string): Camera;
  31812. /**
  31813. * Gets the direction of the camera relative to a given local axis.
  31814. * @param localAxis Defines the reference axis to provide a relative direction.
  31815. * @return the direction
  31816. */
  31817. getDirection(localAxis: Vector3): Vector3;
  31818. /**
  31819. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31820. * @param localAxis Defines the reference axis to provide a relative direction.
  31821. * @param result Defines the vector to store the result in
  31822. */
  31823. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31824. /**
  31825. * Gets a camera constructor for a given camera type
  31826. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31827. * @param name The name of the camera the result will be able to instantiate
  31828. * @param scene The scene the result will construct the camera in
  31829. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31830. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31831. * @returns a factory method to construc the camera
  31832. */
  31833. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31834. /**
  31835. * Compute the world matrix of the camera.
  31836. * @returns the camera workd matrix
  31837. */
  31838. computeWorldMatrix(): Matrix;
  31839. /**
  31840. * Parse a JSON and creates the camera from the parsed information
  31841. * @param parsedCamera The JSON to parse
  31842. * @param scene The scene to instantiate the camera in
  31843. * @returns the newly constructed camera
  31844. */
  31845. static Parse(parsedCamera: any, scene: Scene): Camera;
  31846. }
  31847. }
  31848. declare module "babylonjs/Misc/tools" {
  31849. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31850. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31851. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31852. import { Observable } from "babylonjs/Misc/observable";
  31853. import { DomManagement } from "babylonjs/Misc/domManagement";
  31854. import { WebRequest } from "babylonjs/Misc/webRequest";
  31855. import { Camera } from "babylonjs/Cameras/camera";
  31856. import { Engine } from "babylonjs/Engines/engine";
  31857. import { Animation } from "babylonjs/Animations/animation";
  31858. /**
  31859. * Interface for any object that can request an animation frame
  31860. */
  31861. export interface ICustomAnimationFrameRequester {
  31862. /**
  31863. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31864. */
  31865. renderFunction?: Function;
  31866. /**
  31867. * Called to request the next frame to render to
  31868. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31869. */
  31870. requestAnimationFrame: Function;
  31871. /**
  31872. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31873. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31874. */
  31875. requestID?: number;
  31876. }
  31877. /**
  31878. * Interface containing an array of animations
  31879. */
  31880. export interface IAnimatable {
  31881. /**
  31882. * Array of animations
  31883. */
  31884. animations: Nullable<Array<Animation>>;
  31885. }
  31886. /** Interface used by value gradients (color, factor, ...) */
  31887. export interface IValueGradient {
  31888. /**
  31889. * Gets or sets the gradient value (between 0 and 1)
  31890. */
  31891. gradient: number;
  31892. }
  31893. /** Class used to store color4 gradient */
  31894. export class ColorGradient implements IValueGradient {
  31895. /**
  31896. * Gets or sets the gradient value (between 0 and 1)
  31897. */
  31898. gradient: number;
  31899. /**
  31900. * Gets or sets first associated color
  31901. */
  31902. color1: Color4;
  31903. /**
  31904. * Gets or sets second associated color
  31905. */
  31906. color2?: Color4;
  31907. /**
  31908. * Will get a color picked randomly between color1 and color2.
  31909. * If color2 is undefined then color1 will be used
  31910. * @param result defines the target Color4 to store the result in
  31911. */
  31912. getColorToRef(result: Color4): void;
  31913. }
  31914. /** Class used to store color 3 gradient */
  31915. export class Color3Gradient implements IValueGradient {
  31916. /**
  31917. * Gets or sets the gradient value (between 0 and 1)
  31918. */
  31919. gradient: number;
  31920. /**
  31921. * Gets or sets the associated color
  31922. */
  31923. color: Color3;
  31924. }
  31925. /** Class used to store factor gradient */
  31926. export class FactorGradient implements IValueGradient {
  31927. /**
  31928. * Gets or sets the gradient value (between 0 and 1)
  31929. */
  31930. gradient: number;
  31931. /**
  31932. * Gets or sets first associated factor
  31933. */
  31934. factor1: number;
  31935. /**
  31936. * Gets or sets second associated factor
  31937. */
  31938. factor2?: number;
  31939. /**
  31940. * Will get a number picked randomly between factor1 and factor2.
  31941. * If factor2 is undefined then factor1 will be used
  31942. * @returns the picked number
  31943. */
  31944. getFactor(): number;
  31945. }
  31946. /**
  31947. * @ignore
  31948. * Application error to support additional information when loading a file
  31949. */
  31950. export class LoadFileError extends Error {
  31951. /** defines the optional web request */
  31952. request?: WebRequest | undefined;
  31953. private static _setPrototypeOf;
  31954. /**
  31955. * Creates a new LoadFileError
  31956. * @param message defines the message of the error
  31957. * @param request defines the optional web request
  31958. */
  31959. constructor(message: string,
  31960. /** defines the optional web request */
  31961. request?: WebRequest | undefined);
  31962. }
  31963. /**
  31964. * Class used to define a retry strategy when error happens while loading assets
  31965. */
  31966. export class RetryStrategy {
  31967. /**
  31968. * Function used to defines an exponential back off strategy
  31969. * @param maxRetries defines the maximum number of retries (3 by default)
  31970. * @param baseInterval defines the interval between retries
  31971. * @returns the strategy function to use
  31972. */
  31973. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31974. }
  31975. /**
  31976. * File request interface
  31977. */
  31978. export interface IFileRequest {
  31979. /**
  31980. * Raised when the request is complete (success or error).
  31981. */
  31982. onCompleteObservable: Observable<IFileRequest>;
  31983. /**
  31984. * Aborts the request for a file.
  31985. */
  31986. abort: () => void;
  31987. }
  31988. /**
  31989. * Class containing a set of static utilities functions
  31990. */
  31991. export class Tools {
  31992. /**
  31993. * Gets or sets the base URL to use to load assets
  31994. */
  31995. static BaseUrl: string;
  31996. /**
  31997. * Enable/Disable Custom HTTP Request Headers globally.
  31998. * default = false
  31999. * @see CustomRequestHeaders
  32000. */
  32001. static UseCustomRequestHeaders: boolean;
  32002. /**
  32003. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32004. * i.e. when loading files, where the server/service expects an Authorization header
  32005. */
  32006. static CustomRequestHeaders: {
  32007. [key: string]: string;
  32008. };
  32009. /**
  32010. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32011. */
  32012. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32013. /**
  32014. * Default behaviour for cors in the application.
  32015. * It can be a string if the expected behavior is identical in the entire app.
  32016. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32017. */
  32018. static CorsBehavior: string | ((url: string | string[]) => string);
  32019. /**
  32020. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32021. * @ignorenaming
  32022. */
  32023. static UseFallbackTexture: boolean;
  32024. /**
  32025. * Use this object to register external classes like custom textures or material
  32026. * to allow the laoders to instantiate them
  32027. */
  32028. static RegisteredExternalClasses: {
  32029. [key: string]: Object;
  32030. };
  32031. /**
  32032. * Texture content used if a texture cannot loaded
  32033. * @ignorenaming
  32034. */
  32035. static fallbackTexture: string;
  32036. /**
  32037. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32038. * @param u defines the coordinate on X axis
  32039. * @param v defines the coordinate on Y axis
  32040. * @param width defines the width of the source data
  32041. * @param height defines the height of the source data
  32042. * @param pixels defines the source byte array
  32043. * @param color defines the output color
  32044. */
  32045. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32046. /**
  32047. * Interpolates between a and b via alpha
  32048. * @param a The lower value (returned when alpha = 0)
  32049. * @param b The upper value (returned when alpha = 1)
  32050. * @param alpha The interpolation-factor
  32051. * @return The mixed value
  32052. */
  32053. static Mix(a: number, b: number, alpha: number): number;
  32054. /**
  32055. * Tries to instantiate a new object from a given class name
  32056. * @param className defines the class name to instantiate
  32057. * @returns the new object or null if the system was not able to do the instantiation
  32058. */
  32059. static Instantiate(className: string): any;
  32060. /**
  32061. * Provides a slice function that will work even on IE
  32062. * @param data defines the array to slice
  32063. * @param start defines the start of the data (optional)
  32064. * @param end defines the end of the data (optional)
  32065. * @returns the new sliced array
  32066. */
  32067. static Slice<T>(data: T, start?: number, end?: number): T;
  32068. /**
  32069. * Polyfill for setImmediate
  32070. * @param action defines the action to execute after the current execution block
  32071. */
  32072. static SetImmediate(action: () => void): void;
  32073. /**
  32074. * Function indicating if a number is an exponent of 2
  32075. * @param value defines the value to test
  32076. * @returns true if the value is an exponent of 2
  32077. */
  32078. static IsExponentOfTwo(value: number): boolean;
  32079. private static _tmpFloatArray;
  32080. /**
  32081. * Returns the nearest 32-bit single precision float representation of a Number
  32082. * @param value A Number. If the parameter is of a different type, it will get converted
  32083. * to a number or to NaN if it cannot be converted
  32084. * @returns number
  32085. */
  32086. static FloatRound(value: number): number;
  32087. /**
  32088. * Find the next highest power of two.
  32089. * @param x Number to start search from.
  32090. * @return Next highest power of two.
  32091. */
  32092. static CeilingPOT(x: number): number;
  32093. /**
  32094. * Find the next lowest power of two.
  32095. * @param x Number to start search from.
  32096. * @return Next lowest power of two.
  32097. */
  32098. static FloorPOT(x: number): number;
  32099. /**
  32100. * Find the nearest power of two.
  32101. * @param x Number to start search from.
  32102. * @return Next nearest power of two.
  32103. */
  32104. static NearestPOT(x: number): number;
  32105. /**
  32106. * Get the closest exponent of two
  32107. * @param value defines the value to approximate
  32108. * @param max defines the maximum value to return
  32109. * @param mode defines how to define the closest value
  32110. * @returns closest exponent of two of the given value
  32111. */
  32112. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32113. /**
  32114. * Extracts the filename from a path
  32115. * @param path defines the path to use
  32116. * @returns the filename
  32117. */
  32118. static GetFilename(path: string): string;
  32119. /**
  32120. * Extracts the "folder" part of a path (everything before the filename).
  32121. * @param uri The URI to extract the info from
  32122. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32123. * @returns The "folder" part of the path
  32124. */
  32125. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32126. /**
  32127. * Extracts text content from a DOM element hierarchy
  32128. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32129. */
  32130. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32131. /**
  32132. * Convert an angle in radians to degrees
  32133. * @param angle defines the angle to convert
  32134. * @returns the angle in degrees
  32135. */
  32136. static ToDegrees(angle: number): number;
  32137. /**
  32138. * Convert an angle in degrees to radians
  32139. * @param angle defines the angle to convert
  32140. * @returns the angle in radians
  32141. */
  32142. static ToRadians(angle: number): number;
  32143. /**
  32144. * Encode a buffer to a base64 string
  32145. * @param buffer defines the buffer to encode
  32146. * @returns the encoded string
  32147. */
  32148. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32149. /**
  32150. * Extracts minimum and maximum values from a list of indexed positions
  32151. * @param positions defines the positions to use
  32152. * @param indices defines the indices to the positions
  32153. * @param indexStart defines the start index
  32154. * @param indexCount defines the end index
  32155. * @param bias defines bias value to add to the result
  32156. * @return minimum and maximum values
  32157. */
  32158. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32159. minimum: Vector3;
  32160. maximum: Vector3;
  32161. };
  32162. /**
  32163. * Extracts minimum and maximum values from a list of positions
  32164. * @param positions defines the positions to use
  32165. * @param start defines the start index in the positions array
  32166. * @param count defines the number of positions to handle
  32167. * @param bias defines bias value to add to the result
  32168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32169. * @return minimum and maximum values
  32170. */
  32171. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32172. minimum: Vector3;
  32173. maximum: Vector3;
  32174. };
  32175. /**
  32176. * Returns an array if obj is not an array
  32177. * @param obj defines the object to evaluate as an array
  32178. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32179. * @returns either obj directly if obj is an array or a new array containing obj
  32180. */
  32181. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32182. /**
  32183. * Gets the pointer prefix to use
  32184. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32185. */
  32186. static GetPointerPrefix(): string;
  32187. /**
  32188. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32189. * @param func - the function to be called
  32190. * @param requester - the object that will request the next frame. Falls back to window.
  32191. * @returns frame number
  32192. */
  32193. static QueueNewFrame(func: () => void, requester?: any): number;
  32194. /**
  32195. * Ask the browser to promote the current element to fullscreen rendering mode
  32196. * @param element defines the DOM element to promote
  32197. */
  32198. static RequestFullscreen(element: HTMLElement): void;
  32199. /**
  32200. * Asks the browser to exit fullscreen mode
  32201. */
  32202. static ExitFullscreen(): void;
  32203. /**
  32204. * Ask the browser to promote the current element to pointerlock mode
  32205. * @param element defines the DOM element to promote
  32206. */
  32207. static RequestPointerlock(element: HTMLElement): void;
  32208. /**
  32209. * Asks the browser to exit pointerlock mode
  32210. */
  32211. static ExitPointerlock(): void;
  32212. /**
  32213. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32214. * @param url define the url we are trying
  32215. * @param element define the dom element where to configure the cors policy
  32216. */
  32217. static SetCorsBehavior(url: string | string[], element: {
  32218. crossOrigin: string | null;
  32219. }): void;
  32220. /**
  32221. * Removes unwanted characters from an url
  32222. * @param url defines the url to clean
  32223. * @returns the cleaned url
  32224. */
  32225. static CleanUrl(url: string): string;
  32226. /**
  32227. * Gets or sets a function used to pre-process url before using them to load assets
  32228. */
  32229. static PreprocessUrl: (url: string) => string;
  32230. /**
  32231. * Loads an image as an HTMLImageElement.
  32232. * @param input url string, ArrayBuffer, or Blob to load
  32233. * @param onLoad callback called when the image successfully loads
  32234. * @param onError callback called when the image fails to load
  32235. * @param offlineProvider offline provider for caching
  32236. * @returns the HTMLImageElement of the loaded image
  32237. */
  32238. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32239. /**
  32240. * Loads a file
  32241. * @param url url string, ArrayBuffer, or Blob to load
  32242. * @param onSuccess callback called when the file successfully loads
  32243. * @param onProgress callback called while file is loading (if the server supports this mode)
  32244. * @param offlineProvider defines the offline provider for caching
  32245. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32246. * @param onError callback called when the file fails to load
  32247. * @returns a file request object
  32248. */
  32249. 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;
  32250. /**
  32251. * Loads a file from a url
  32252. * @param url the file url to load
  32253. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32254. */
  32255. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32256. /**
  32257. * Load a script (identified by an url). When the url returns, the
  32258. * content of this file is added into a new script element, attached to the DOM (body element)
  32259. * @param scriptUrl defines the url of the script to laod
  32260. * @param onSuccess defines the callback called when the script is loaded
  32261. * @param onError defines the callback to call if an error occurs
  32262. * @param scriptId defines the id of the script element
  32263. */
  32264. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32265. /**
  32266. * Load an asynchronous script (identified by an url). When the url returns, the
  32267. * content of this file is added into a new script element, attached to the DOM (body element)
  32268. * @param scriptUrl defines the url of the script to laod
  32269. * @param scriptId defines the id of the script element
  32270. * @returns a promise request object
  32271. */
  32272. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32273. /**
  32274. * Loads a file from a blob
  32275. * @param fileToLoad defines the blob to use
  32276. * @param callback defines the callback to call when data is loaded
  32277. * @param progressCallback defines the callback to call during loading process
  32278. * @returns a file request object
  32279. */
  32280. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32281. /**
  32282. * Loads a file
  32283. * @param fileToLoad defines the file to load
  32284. * @param callback defines the callback to call when data is loaded
  32285. * @param progressCallBack defines the callback to call during loading process
  32286. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32287. * @returns a file request object
  32288. */
  32289. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32290. /**
  32291. * Creates a data url from a given string content
  32292. * @param content defines the content to convert
  32293. * @returns the new data url link
  32294. */
  32295. static FileAsURL(content: string): string;
  32296. /**
  32297. * Format the given number to a specific decimal format
  32298. * @param value defines the number to format
  32299. * @param decimals defines the number of decimals to use
  32300. * @returns the formatted string
  32301. */
  32302. static Format(value: number, decimals?: number): string;
  32303. /**
  32304. * Checks if a given vector is inside a specific range
  32305. * @param v defines the vector to test
  32306. * @param min defines the minimum range
  32307. * @param max defines the maximum range
  32308. */
  32309. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32310. /**
  32311. * Tries to copy an object by duplicating every property
  32312. * @param source defines the source object
  32313. * @param destination defines the target object
  32314. * @param doNotCopyList defines a list of properties to avoid
  32315. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32316. */
  32317. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32318. /**
  32319. * Gets a boolean indicating if the given object has no own property
  32320. * @param obj defines the object to test
  32321. * @returns true if object has no own property
  32322. */
  32323. static IsEmpty(obj: any): boolean;
  32324. /**
  32325. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32326. * @param str Source string
  32327. * @param suffix Suffix to search for in the source string
  32328. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32329. */
  32330. static EndsWith(str: string, suffix: string): boolean;
  32331. /**
  32332. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32333. * @param str Source string
  32334. * @param suffix Suffix to search for in the source string
  32335. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32336. */
  32337. static StartsWith(str: string, suffix: string): boolean;
  32338. /**
  32339. * Function used to register events at window level
  32340. * @param events defines the events to register
  32341. */
  32342. static RegisterTopRootEvents(events: {
  32343. name: string;
  32344. handler: Nullable<(e: FocusEvent) => any>;
  32345. }[]): void;
  32346. /**
  32347. * Function used to unregister events from window level
  32348. * @param events defines the events to unregister
  32349. */
  32350. static UnregisterTopRootEvents(events: {
  32351. name: string;
  32352. handler: Nullable<(e: FocusEvent) => any>;
  32353. }[]): void;
  32354. /**
  32355. * @ignore
  32356. */
  32357. static _ScreenshotCanvas: HTMLCanvasElement;
  32358. /**
  32359. * Dumps the current bound framebuffer
  32360. * @param width defines the rendering width
  32361. * @param height defines the rendering height
  32362. * @param engine defines the hosting engine
  32363. * @param successCallback defines the callback triggered once the data are available
  32364. * @param mimeType defines the mime type of the result
  32365. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32366. */
  32367. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32368. /**
  32369. * Converts the canvas data to blob.
  32370. * This acts as a polyfill for browsers not supporting the to blob function.
  32371. * @param canvas Defines the canvas to extract the data from
  32372. * @param successCallback Defines the callback triggered once the data are available
  32373. * @param mimeType Defines the mime type of the result
  32374. */
  32375. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32376. /**
  32377. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32378. * @param successCallback defines the callback triggered once the data are available
  32379. * @param mimeType defines the mime type of the result
  32380. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32381. */
  32382. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32383. /**
  32384. * Downloads a blob in the browser
  32385. * @param blob defines the blob to download
  32386. * @param fileName defines the name of the downloaded file
  32387. */
  32388. static Download(blob: Blob, fileName: string): void;
  32389. /**
  32390. * Captures a screenshot of the current rendering
  32391. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32392. * @param engine defines the rendering engine
  32393. * @param camera defines the source camera
  32394. * @param size This parameter can be set to a single number or to an object with the
  32395. * following (optional) properties: precision, width, height. If a single number is passed,
  32396. * it will be used for both width and height. If an object is passed, the screenshot size
  32397. * will be derived from the parameters. The precision property is a multiplier allowing
  32398. * rendering at a higher or lower resolution
  32399. * @param successCallback defines the callback receives a single parameter which contains the
  32400. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32401. * src parameter of an <img> to display it
  32402. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32403. * Check your browser for supported MIME types
  32404. */
  32405. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32406. /**
  32407. * Generates an image screenshot from the specified camera.
  32408. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32409. * @param engine The engine to use for rendering
  32410. * @param camera The camera to use for rendering
  32411. * @param size This parameter can be set to a single number or to an object with the
  32412. * following (optional) properties: precision, width, height. If a single number is passed,
  32413. * it will be used for both width and height. If an object is passed, the screenshot size
  32414. * will be derived from the parameters. The precision property is a multiplier allowing
  32415. * rendering at a higher or lower resolution
  32416. * @param successCallback The callback receives a single parameter which contains the
  32417. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32418. * src parameter of an <img> to display it
  32419. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32420. * Check your browser for supported MIME types
  32421. * @param samples Texture samples (default: 1)
  32422. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32423. * @param fileName A name for for the downloaded file.
  32424. */
  32425. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32426. /**
  32427. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32428. * Be aware Math.random() could cause collisions, but:
  32429. * "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"
  32430. * @returns a pseudo random id
  32431. */
  32432. static RandomId(): string;
  32433. /**
  32434. * Test if the given uri is a base64 string
  32435. * @param uri The uri to test
  32436. * @return True if the uri is a base64 string or false otherwise
  32437. */
  32438. static IsBase64(uri: string): boolean;
  32439. /**
  32440. * Decode the given base64 uri.
  32441. * @param uri The uri to decode
  32442. * @return The decoded base64 data.
  32443. */
  32444. static DecodeBase64(uri: string): ArrayBuffer;
  32445. /**
  32446. * Gets the absolute url.
  32447. * @param url the input url
  32448. * @return the absolute url
  32449. */
  32450. static GetAbsoluteUrl(url: string): string;
  32451. /**
  32452. * No log
  32453. */
  32454. static readonly NoneLogLevel: number;
  32455. /**
  32456. * Only message logs
  32457. */
  32458. static readonly MessageLogLevel: number;
  32459. /**
  32460. * Only warning logs
  32461. */
  32462. static readonly WarningLogLevel: number;
  32463. /**
  32464. * Only error logs
  32465. */
  32466. static readonly ErrorLogLevel: number;
  32467. /**
  32468. * All logs
  32469. */
  32470. static readonly AllLogLevel: number;
  32471. /**
  32472. * Gets a value indicating the number of loading errors
  32473. * @ignorenaming
  32474. */
  32475. static readonly errorsCount: number;
  32476. /**
  32477. * Callback called when a new log is added
  32478. */
  32479. static OnNewCacheEntry: (entry: string) => void;
  32480. /**
  32481. * Log a message to the console
  32482. * @param message defines the message to log
  32483. */
  32484. static Log(message: string): void;
  32485. /**
  32486. * Write a warning message to the console
  32487. * @param message defines the message to log
  32488. */
  32489. static Warn(message: string): void;
  32490. /**
  32491. * Write an error message to the console
  32492. * @param message defines the message to log
  32493. */
  32494. static Error(message: string): void;
  32495. /**
  32496. * Gets current log cache (list of logs)
  32497. */
  32498. static readonly LogCache: string;
  32499. /**
  32500. * Clears the log cache
  32501. */
  32502. static ClearLogCache(): void;
  32503. /**
  32504. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32505. */
  32506. static LogLevels: number;
  32507. /**
  32508. * Checks if the loaded document was accessed via `file:`-Protocol.
  32509. * @returns boolean
  32510. */
  32511. static IsFileURL(): boolean;
  32512. /**
  32513. * Checks if the window object exists
  32514. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32515. */
  32516. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32517. /**
  32518. * No performance log
  32519. */
  32520. static readonly PerformanceNoneLogLevel: number;
  32521. /**
  32522. * Use user marks to log performance
  32523. */
  32524. static readonly PerformanceUserMarkLogLevel: number;
  32525. /**
  32526. * Log performance to the console
  32527. */
  32528. static readonly PerformanceConsoleLogLevel: number;
  32529. private static _performance;
  32530. /**
  32531. * Sets the current performance log level
  32532. */
  32533. static PerformanceLogLevel: number;
  32534. private static _StartPerformanceCounterDisabled;
  32535. private static _EndPerformanceCounterDisabled;
  32536. private static _StartUserMark;
  32537. private static _EndUserMark;
  32538. private static _StartPerformanceConsole;
  32539. private static _EndPerformanceConsole;
  32540. /**
  32541. * Starts a performance counter
  32542. */
  32543. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32544. /**
  32545. * Ends a specific performance coutner
  32546. */
  32547. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32548. /**
  32549. * Gets either window.performance.now() if supported or Date.now() else
  32550. */
  32551. static readonly Now: number;
  32552. /**
  32553. * This method will return the name of the class used to create the instance of the given object.
  32554. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32555. * @param object the object to get the class name from
  32556. * @param isType defines if the object is actually a type
  32557. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32558. */
  32559. static GetClassName(object: any, isType?: boolean): string;
  32560. /**
  32561. * Gets the first element of an array satisfying a given predicate
  32562. * @param array defines the array to browse
  32563. * @param predicate defines the predicate to use
  32564. * @returns null if not found or the element
  32565. */
  32566. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32567. /**
  32568. * This method will return the name of the full name of the class, including its owning module (if any).
  32569. * 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).
  32570. * @param object the object to get the class name from
  32571. * @param isType defines if the object is actually a type
  32572. * @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.
  32573. * @ignorenaming
  32574. */
  32575. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32576. /**
  32577. * Returns a promise that resolves after the given amount of time.
  32578. * @param delay Number of milliseconds to delay
  32579. * @returns Promise that resolves after the given amount of time
  32580. */
  32581. static DelayAsync(delay: number): Promise<void>;
  32582. /**
  32583. * Gets the current gradient from an array of IValueGradient
  32584. * @param ratio defines the current ratio to get
  32585. * @param gradients defines the array of IValueGradient
  32586. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32587. */
  32588. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32589. }
  32590. /**
  32591. * This class is used to track a performance counter which is number based.
  32592. * The user has access to many properties which give statistics of different nature.
  32593. *
  32594. * The implementer can track two kinds of Performance Counter: time and count.
  32595. * 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.
  32596. * 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.
  32597. */
  32598. export class PerfCounter {
  32599. /**
  32600. * Gets or sets a global boolean to turn on and off all the counters
  32601. */
  32602. static Enabled: boolean;
  32603. /**
  32604. * Returns the smallest value ever
  32605. */
  32606. readonly min: number;
  32607. /**
  32608. * Returns the biggest value ever
  32609. */
  32610. readonly max: number;
  32611. /**
  32612. * Returns the average value since the performance counter is running
  32613. */
  32614. readonly average: number;
  32615. /**
  32616. * Returns the average value of the last second the counter was monitored
  32617. */
  32618. readonly lastSecAverage: number;
  32619. /**
  32620. * Returns the current value
  32621. */
  32622. readonly current: number;
  32623. /**
  32624. * Gets the accumulated total
  32625. */
  32626. readonly total: number;
  32627. /**
  32628. * Gets the total value count
  32629. */
  32630. readonly count: number;
  32631. /**
  32632. * Creates a new counter
  32633. */
  32634. constructor();
  32635. /**
  32636. * Call this method to start monitoring a new frame.
  32637. * 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.
  32638. */
  32639. fetchNewFrame(): void;
  32640. /**
  32641. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32642. * @param newCount the count value to add to the monitored count
  32643. * @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.
  32644. */
  32645. addCount(newCount: number, fetchResult: boolean): void;
  32646. /**
  32647. * Start monitoring this performance counter
  32648. */
  32649. beginMonitoring(): void;
  32650. /**
  32651. * Compute the time lapsed since the previous beginMonitoring() call.
  32652. * @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
  32653. */
  32654. endMonitoring(newFrame?: boolean): void;
  32655. private _fetchResult;
  32656. private _startMonitoringTime;
  32657. private _min;
  32658. private _max;
  32659. private _average;
  32660. private _current;
  32661. private _totalValueCount;
  32662. private _totalAccumulated;
  32663. private _lastSecAverage;
  32664. private _lastSecAccumulated;
  32665. private _lastSecTime;
  32666. private _lastSecValueCount;
  32667. }
  32668. /**
  32669. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32670. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32671. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32672. * @param name The name of the class, case should be preserved
  32673. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32674. */
  32675. export function className(name: string, module?: string): (target: Object) => void;
  32676. /**
  32677. * An implementation of a loop for asynchronous functions.
  32678. */
  32679. export class AsyncLoop {
  32680. /**
  32681. * Defines the number of iterations for the loop
  32682. */
  32683. iterations: number;
  32684. /**
  32685. * Defines the current index of the loop.
  32686. */
  32687. index: number;
  32688. private _done;
  32689. private _fn;
  32690. private _successCallback;
  32691. /**
  32692. * Constructor.
  32693. * @param iterations the number of iterations.
  32694. * @param func the function to run each iteration
  32695. * @param successCallback the callback that will be called upon succesful execution
  32696. * @param offset starting offset.
  32697. */
  32698. constructor(
  32699. /**
  32700. * Defines the number of iterations for the loop
  32701. */
  32702. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32703. /**
  32704. * Execute the next iteration. Must be called after the last iteration was finished.
  32705. */
  32706. executeNext(): void;
  32707. /**
  32708. * Break the loop and run the success callback.
  32709. */
  32710. breakLoop(): void;
  32711. /**
  32712. * Create and run an async loop.
  32713. * @param iterations the number of iterations.
  32714. * @param fn the function to run each iteration
  32715. * @param successCallback the callback that will be called upon succesful execution
  32716. * @param offset starting offset.
  32717. * @returns the created async loop object
  32718. */
  32719. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32720. /**
  32721. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32722. * @param iterations total number of iterations
  32723. * @param syncedIterations number of synchronous iterations in each async iteration.
  32724. * @param fn the function to call each iteration.
  32725. * @param callback a success call back that will be called when iterating stops.
  32726. * @param breakFunction a break condition (optional)
  32727. * @param timeout timeout settings for the setTimeout function. default - 0.
  32728. * @returns the created async loop object
  32729. */
  32730. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32731. }
  32732. }
  32733. declare module "babylonjs/Collisions/collisionCoordinator" {
  32734. import { Nullable } from "babylonjs/types";
  32735. import { Scene } from "babylonjs/scene";
  32736. import { Vector3 } from "babylonjs/Maths/math";
  32737. import { Collider } from "babylonjs/Collisions/collider";
  32738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32739. /** @hidden */
  32740. export interface ICollisionCoordinator {
  32741. createCollider(): Collider;
  32742. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32743. init(scene: Scene): void;
  32744. }
  32745. /** @hidden */
  32746. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32747. private _scene;
  32748. private _scaledPosition;
  32749. private _scaledVelocity;
  32750. private _finalPosition;
  32751. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32752. createCollider(): Collider;
  32753. init(scene: Scene): void;
  32754. private _collideWithWorld;
  32755. }
  32756. }
  32757. declare module "babylonjs/Inputs/scene.inputManager" {
  32758. import { Nullable } from "babylonjs/types";
  32759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32760. import { Vector2 } from "babylonjs/Maths/math";
  32761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32762. import { Scene } from "babylonjs/scene";
  32763. /**
  32764. * Class used to manage all inputs for the scene.
  32765. */
  32766. export class InputManager {
  32767. /** The distance in pixel that you have to move to prevent some events */
  32768. static DragMovementThreshold: number;
  32769. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32770. static LongPressDelay: number;
  32771. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32772. static DoubleClickDelay: number;
  32773. /** If you need to check double click without raising a single click at first click, enable this flag */
  32774. static ExclusiveDoubleClickMode: boolean;
  32775. private _wheelEventName;
  32776. private _onPointerMove;
  32777. private _onPointerDown;
  32778. private _onPointerUp;
  32779. private _initClickEvent;
  32780. private _initActionManager;
  32781. private _delayedSimpleClick;
  32782. private _delayedSimpleClickTimeout;
  32783. private _previousDelayedSimpleClickTimeout;
  32784. private _meshPickProceed;
  32785. private _previousButtonPressed;
  32786. private _currentPickResult;
  32787. private _previousPickResult;
  32788. private _totalPointersPressed;
  32789. private _doubleClickOccured;
  32790. private _pointerOverMesh;
  32791. private _pickedDownMesh;
  32792. private _pickedUpMesh;
  32793. private _pointerX;
  32794. private _pointerY;
  32795. private _unTranslatedPointerX;
  32796. private _unTranslatedPointerY;
  32797. private _startingPointerPosition;
  32798. private _previousStartingPointerPosition;
  32799. private _startingPointerTime;
  32800. private _previousStartingPointerTime;
  32801. private _pointerCaptures;
  32802. private _onKeyDown;
  32803. private _onKeyUp;
  32804. private _onCanvasFocusObserver;
  32805. private _onCanvasBlurObserver;
  32806. private _scene;
  32807. /**
  32808. * Creates a new InputManager
  32809. * @param scene defines the hosting scene
  32810. */
  32811. constructor(scene: Scene);
  32812. /**
  32813. * Gets the mesh that is currently under the pointer
  32814. */
  32815. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32816. /**
  32817. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32818. */
  32819. readonly unTranslatedPointer: Vector2;
  32820. /**
  32821. * Gets or sets the current on-screen X position of the pointer
  32822. */
  32823. pointerX: number;
  32824. /**
  32825. * Gets or sets the current on-screen Y position of the pointer
  32826. */
  32827. pointerY: number;
  32828. private _updatePointerPosition;
  32829. private _processPointerMove;
  32830. private _setRayOnPointerInfo;
  32831. private _checkPrePointerObservable;
  32832. /**
  32833. * Use this method to simulate a pointer move on a mesh
  32834. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32835. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32836. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32837. */
  32838. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32839. /**
  32840. * Use this method to simulate a pointer down on a mesh
  32841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32844. */
  32845. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32846. private _processPointerDown;
  32847. /** @hidden */
  32848. _isPointerSwiping(): boolean;
  32849. /**
  32850. * Use this method to simulate a pointer up on a mesh
  32851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32854. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32855. */
  32856. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32857. private _processPointerUp;
  32858. /**
  32859. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32860. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32861. * @returns true if the pointer was captured
  32862. */
  32863. isPointerCaptured(pointerId?: number): boolean;
  32864. /**
  32865. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32866. * @param attachUp defines if you want to attach events to pointerup
  32867. * @param attachDown defines if you want to attach events to pointerdown
  32868. * @param attachMove defines if you want to attach events to pointermove
  32869. */
  32870. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32871. /**
  32872. * Detaches all event handlers
  32873. */
  32874. detachControl(): void;
  32875. /**
  32876. * Force the value of meshUnderPointer
  32877. * @param mesh defines the mesh to use
  32878. */
  32879. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32880. /**
  32881. * Gets the mesh under the pointer
  32882. * @returns a Mesh or null if no mesh is under the pointer
  32883. */
  32884. getPointerOverMesh(): Nullable<AbstractMesh>;
  32885. }
  32886. }
  32887. declare module "babylonjs/Animations/animationGroup" {
  32888. import { Animatable } from "babylonjs/Animations/animatable";
  32889. import { Animation } from "babylonjs/Animations/animation";
  32890. import { Scene, IDisposable } from "babylonjs/scene";
  32891. import { Observable } from "babylonjs/Misc/observable";
  32892. import { Nullable } from "babylonjs/types";
  32893. import "babylonjs/Animations/animatable";
  32894. /**
  32895. * This class defines the direct association between an animation and a target
  32896. */
  32897. export class TargetedAnimation {
  32898. /**
  32899. * Animation to perform
  32900. */
  32901. animation: Animation;
  32902. /**
  32903. * Target to animate
  32904. */
  32905. target: any;
  32906. /**
  32907. * Serialize the object
  32908. * @returns the JSON object representing the current entity
  32909. */
  32910. serialize(): any;
  32911. }
  32912. /**
  32913. * Use this class to create coordinated animations on multiple targets
  32914. */
  32915. export class AnimationGroup implements IDisposable {
  32916. /** The name of the animation group */
  32917. name: string;
  32918. private _scene;
  32919. private _targetedAnimations;
  32920. private _animatables;
  32921. private _from;
  32922. private _to;
  32923. private _isStarted;
  32924. private _isPaused;
  32925. private _speedRatio;
  32926. private _loopAnimation;
  32927. /**
  32928. * Gets or sets the unique id of the node
  32929. */
  32930. uniqueId: number;
  32931. /**
  32932. * This observable will notify when one animation have ended
  32933. */
  32934. onAnimationEndObservable: Observable<TargetedAnimation>;
  32935. /**
  32936. * Observer raised when one animation loops
  32937. */
  32938. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32939. /**
  32940. * This observable will notify when all animations have ended.
  32941. */
  32942. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32943. /**
  32944. * This observable will notify when all animations have paused.
  32945. */
  32946. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32947. /**
  32948. * This observable will notify when all animations are playing.
  32949. */
  32950. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32951. /**
  32952. * Gets the first frame
  32953. */
  32954. readonly from: number;
  32955. /**
  32956. * Gets the last frame
  32957. */
  32958. readonly to: number;
  32959. /**
  32960. * Define if the animations are started
  32961. */
  32962. readonly isStarted: boolean;
  32963. /**
  32964. * Gets a value indicating that the current group is playing
  32965. */
  32966. readonly isPlaying: boolean;
  32967. /**
  32968. * Gets or sets the speed ratio to use for all animations
  32969. */
  32970. /**
  32971. * Gets or sets the speed ratio to use for all animations
  32972. */
  32973. speedRatio: number;
  32974. /**
  32975. * Gets or sets if all animations should loop or not
  32976. */
  32977. loopAnimation: boolean;
  32978. /**
  32979. * Gets the targeted animations for this animation group
  32980. */
  32981. readonly targetedAnimations: Array<TargetedAnimation>;
  32982. /**
  32983. * returning the list of animatables controlled by this animation group.
  32984. */
  32985. readonly animatables: Array<Animatable>;
  32986. /**
  32987. * Instantiates a new Animation Group.
  32988. * This helps managing several animations at once.
  32989. * @see http://doc.babylonjs.com/how_to/group
  32990. * @param name Defines the name of the group
  32991. * @param scene Defines the scene the group belongs to
  32992. */
  32993. constructor(
  32994. /** The name of the animation group */
  32995. name: string, scene?: Nullable<Scene>);
  32996. /**
  32997. * Add an animation (with its target) in the group
  32998. * @param animation defines the animation we want to add
  32999. * @param target defines the target of the animation
  33000. * @returns the TargetedAnimation object
  33001. */
  33002. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33003. /**
  33004. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33005. * It can add constant keys at begin or end
  33006. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33007. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33008. * @returns the animation group
  33009. */
  33010. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33011. /**
  33012. * Start all animations on given targets
  33013. * @param loop defines if animations must loop
  33014. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33015. * @param from defines the from key (optional)
  33016. * @param to defines the to key (optional)
  33017. * @returns the current animation group
  33018. */
  33019. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33020. /**
  33021. * Pause all animations
  33022. * @returns the animation group
  33023. */
  33024. pause(): AnimationGroup;
  33025. /**
  33026. * Play all animations to initial state
  33027. * This function will start() the animations if they were not started or will restart() them if they were paused
  33028. * @param loop defines if animations must loop
  33029. * @returns the animation group
  33030. */
  33031. play(loop?: boolean): AnimationGroup;
  33032. /**
  33033. * Reset all animations to initial state
  33034. * @returns the animation group
  33035. */
  33036. reset(): AnimationGroup;
  33037. /**
  33038. * Restart animations from key 0
  33039. * @returns the animation group
  33040. */
  33041. restart(): AnimationGroup;
  33042. /**
  33043. * Stop all animations
  33044. * @returns the animation group
  33045. */
  33046. stop(): AnimationGroup;
  33047. /**
  33048. * Set animation weight for all animatables
  33049. * @param weight defines the weight to use
  33050. * @return the animationGroup
  33051. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33052. */
  33053. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33054. /**
  33055. * Synchronize and normalize all animatables with a source animatable
  33056. * @param root defines the root animatable to synchronize with
  33057. * @return the animationGroup
  33058. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33059. */
  33060. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33061. /**
  33062. * Goes to a specific frame in this animation group
  33063. * @param frame the frame number to go to
  33064. * @return the animationGroup
  33065. */
  33066. goToFrame(frame: number): AnimationGroup;
  33067. /**
  33068. * Dispose all associated resources
  33069. */
  33070. dispose(): void;
  33071. private _checkAnimationGroupEnded;
  33072. /**
  33073. * Clone the current animation group and returns a copy
  33074. * @param newName defines the name of the new group
  33075. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33076. * @returns the new aniamtion group
  33077. */
  33078. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33079. /**
  33080. * Serializes the animationGroup to an object
  33081. * @returns Serialized object
  33082. */
  33083. serialize(): any;
  33084. /**
  33085. * Returns a new AnimationGroup object parsed from the source provided.
  33086. * @param parsedAnimationGroup defines the source
  33087. * @param scene defines the scene that will receive the animationGroup
  33088. * @returns a new AnimationGroup
  33089. */
  33090. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33091. /**
  33092. * Returns the string "AnimationGroup"
  33093. * @returns "AnimationGroup"
  33094. */
  33095. getClassName(): string;
  33096. /**
  33097. * Creates a detailled string about the object
  33098. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33099. * @returns a string representing the object
  33100. */
  33101. toString(fullDetails?: boolean): string;
  33102. }
  33103. }
  33104. declare module "babylonjs/scene" {
  33105. import { Nullable } from "babylonjs/types";
  33106. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33107. import { Observable } from "babylonjs/Misc/observable";
  33108. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33109. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33110. import { Geometry } from "babylonjs/Meshes/geometry";
  33111. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33114. import { Mesh } from "babylonjs/Meshes/mesh";
  33115. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33116. import { Bone } from "babylonjs/Bones/bone";
  33117. import { Skeleton } from "babylonjs/Bones/skeleton";
  33118. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33119. import { Camera } from "babylonjs/Cameras/camera";
  33120. import { AbstractScene } from "babylonjs/abstractScene";
  33121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33123. import { Material } from "babylonjs/Materials/material";
  33124. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33125. import { Effect } from "babylonjs/Materials/effect";
  33126. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33127. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33128. import { Light } from "babylonjs/Lights/light";
  33129. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33130. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33131. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33132. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33133. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33134. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33135. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33136. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33137. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33138. import { Engine } from "babylonjs/Engines/engine";
  33139. import { Node } from "babylonjs/node";
  33140. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33141. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33142. import { WebRequest } from "babylonjs/Misc/webRequest";
  33143. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33144. import { Ray } from "babylonjs/Culling/ray";
  33145. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33146. import { Animation } from "babylonjs/Animations/animation";
  33147. import { Animatable } from "babylonjs/Animations/animatable";
  33148. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33149. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33150. import { Collider } from "babylonjs/Collisions/collider";
  33151. /**
  33152. * Define an interface for all classes that will hold resources
  33153. */
  33154. export interface IDisposable {
  33155. /**
  33156. * Releases all held resources
  33157. */
  33158. dispose(): void;
  33159. }
  33160. /** Interface defining initialization parameters for Scene class */
  33161. export interface SceneOptions {
  33162. /**
  33163. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33164. * It will improve performance when the number of geometries becomes important.
  33165. */
  33166. useGeometryUniqueIdsMap?: boolean;
  33167. /**
  33168. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33169. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33170. */
  33171. useMaterialMeshMap?: boolean;
  33172. /**
  33173. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33175. */
  33176. useClonedMeshhMap?: boolean;
  33177. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33178. virtual?: boolean;
  33179. }
  33180. /**
  33181. * Represents a scene to be rendered by the engine.
  33182. * @see http://doc.babylonjs.com/features/scene
  33183. */
  33184. export class Scene extends AbstractScene implements IAnimatable {
  33185. private static _uniqueIdCounter;
  33186. /** The fog is deactivated */
  33187. static readonly FOGMODE_NONE: number;
  33188. /** The fog density is following an exponential function */
  33189. static readonly FOGMODE_EXP: number;
  33190. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33191. static readonly FOGMODE_EXP2: number;
  33192. /** The fog density is following a linear function. */
  33193. static readonly FOGMODE_LINEAR: number;
  33194. /**
  33195. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33197. */
  33198. static MinDeltaTime: number;
  33199. /**
  33200. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33202. */
  33203. static MaxDeltaTime: number;
  33204. /**
  33205. * Factory used to create the default material.
  33206. * @param name The name of the material to create
  33207. * @param scene The scene to create the material for
  33208. * @returns The default material
  33209. */
  33210. static DefaultMaterialFactory(scene: Scene): Material;
  33211. /**
  33212. * Factory used to create the a collision coordinator.
  33213. * @returns The collision coordinator
  33214. */
  33215. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33216. /** @hidden */
  33217. _inputManager: InputManager;
  33218. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33219. cameraToUseForPointers: Nullable<Camera>;
  33220. /** @hidden */
  33221. readonly _isScene: boolean;
  33222. /**
  33223. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33224. */
  33225. autoClear: boolean;
  33226. /**
  33227. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33228. */
  33229. autoClearDepthAndStencil: boolean;
  33230. /**
  33231. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33232. */
  33233. clearColor: Color4;
  33234. /**
  33235. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33236. */
  33237. ambientColor: Color3;
  33238. /**
  33239. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33240. * It should only be one of the following (if not the default embedded one):
  33241. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33242. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33243. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33244. * The material properties need to be setup according to the type of texture in use.
  33245. */
  33246. environmentBRDFTexture: BaseTexture;
  33247. /** @hidden */
  33248. protected _environmentTexture: Nullable<BaseTexture>;
  33249. /**
  33250. * Texture used in all pbr material as the reflection texture.
  33251. * As in the majority of the scene they are the same (exception for multi room and so on),
  33252. * this is easier to reference from here than from all the materials.
  33253. */
  33254. /**
  33255. * Texture used in all pbr material as the reflection texture.
  33256. * As in the majority of the scene they are the same (exception for multi room and so on),
  33257. * this is easier to set here than in all the materials.
  33258. */
  33259. environmentTexture: Nullable<BaseTexture>;
  33260. /** @hidden */
  33261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33262. /**
  33263. * Default image processing configuration used either in the rendering
  33264. * Forward main pass or through the imageProcessingPostProcess if present.
  33265. * As in the majority of the scene they are the same (exception for multi camera),
  33266. * this is easier to reference from here than from all the materials and post process.
  33267. *
  33268. * No setter as we it is a shared configuration, you can set the values instead.
  33269. */
  33270. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33271. private _forceWireframe;
  33272. /**
  33273. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33274. */
  33275. forceWireframe: boolean;
  33276. private _forcePointsCloud;
  33277. /**
  33278. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33279. */
  33280. forcePointsCloud: boolean;
  33281. /**
  33282. * Gets or sets the active clipplane 1
  33283. */
  33284. clipPlane: Nullable<Plane>;
  33285. /**
  33286. * Gets or sets the active clipplane 2
  33287. */
  33288. clipPlane2: Nullable<Plane>;
  33289. /**
  33290. * Gets or sets the active clipplane 3
  33291. */
  33292. clipPlane3: Nullable<Plane>;
  33293. /**
  33294. * Gets or sets the active clipplane 4
  33295. */
  33296. clipPlane4: Nullable<Plane>;
  33297. /**
  33298. * Gets or sets a boolean indicating if animations are enabled
  33299. */
  33300. animationsEnabled: boolean;
  33301. private _animationPropertiesOverride;
  33302. /**
  33303. * Gets or sets the animation properties override
  33304. */
  33305. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33306. /**
  33307. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33308. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33309. */
  33310. useConstantAnimationDeltaTime: boolean;
  33311. /**
  33312. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33313. * Please note that it requires to run a ray cast through the scene on every frame
  33314. */
  33315. constantlyUpdateMeshUnderPointer: boolean;
  33316. /**
  33317. * Defines the HTML cursor to use when hovering over interactive elements
  33318. */
  33319. hoverCursor: string;
  33320. /**
  33321. * Defines the HTML default cursor to use (empty by default)
  33322. */
  33323. defaultCursor: string;
  33324. /**
  33325. * This is used to call preventDefault() on pointer down
  33326. * in order to block unwanted artifacts like system double clicks
  33327. */
  33328. preventDefaultOnPointerDown: boolean;
  33329. /**
  33330. * This is used to call preventDefault() on pointer up
  33331. * in order to block unwanted artifacts like system double clicks
  33332. */
  33333. preventDefaultOnPointerUp: boolean;
  33334. /**
  33335. * Gets or sets user defined metadata
  33336. */
  33337. metadata: any;
  33338. /**
  33339. * For internal use only. Please do not use.
  33340. */
  33341. reservedDataStore: any;
  33342. /**
  33343. * Gets the name of the plugin used to load this scene (null by default)
  33344. */
  33345. loadingPluginName: string;
  33346. /**
  33347. * Use this array to add regular expressions used to disable offline support for specific urls
  33348. */
  33349. disableOfflineSupportExceptionRules: RegExp[];
  33350. /**
  33351. * An event triggered when the scene is disposed.
  33352. */
  33353. onDisposeObservable: Observable<Scene>;
  33354. private _onDisposeObserver;
  33355. /** Sets a function to be executed when this scene is disposed. */
  33356. onDispose: () => void;
  33357. /**
  33358. * An event triggered before rendering the scene (right after animations and physics)
  33359. */
  33360. onBeforeRenderObservable: Observable<Scene>;
  33361. private _onBeforeRenderObserver;
  33362. /** Sets a function to be executed before rendering this scene */
  33363. beforeRender: Nullable<() => void>;
  33364. /**
  33365. * An event triggered after rendering the scene
  33366. */
  33367. onAfterRenderObservable: Observable<Scene>;
  33368. /**
  33369. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33370. */
  33371. onAfterRenderCameraObservable: Observable<Camera>;
  33372. private _onAfterRenderObserver;
  33373. /** Sets a function to be executed after rendering this scene */
  33374. afterRender: Nullable<() => void>;
  33375. /**
  33376. * An event triggered before animating the scene
  33377. */
  33378. onBeforeAnimationsObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered after animations processing
  33381. */
  33382. onAfterAnimationsObservable: Observable<Scene>;
  33383. /**
  33384. * An event triggered before draw calls are ready to be sent
  33385. */
  33386. onBeforeDrawPhaseObservable: Observable<Scene>;
  33387. /**
  33388. * An event triggered after draw calls have been sent
  33389. */
  33390. onAfterDrawPhaseObservable: Observable<Scene>;
  33391. /**
  33392. * An event triggered when the scene is ready
  33393. */
  33394. onReadyObservable: Observable<Scene>;
  33395. /**
  33396. * An event triggered before rendering a camera
  33397. */
  33398. onBeforeCameraRenderObservable: Observable<Camera>;
  33399. private _onBeforeCameraRenderObserver;
  33400. /** Sets a function to be executed before rendering a camera*/
  33401. beforeCameraRender: () => void;
  33402. /**
  33403. * An event triggered after rendering a camera
  33404. */
  33405. onAfterCameraRenderObservable: Observable<Camera>;
  33406. private _onAfterCameraRenderObserver;
  33407. /** Sets a function to be executed after rendering a camera*/
  33408. afterCameraRender: () => void;
  33409. /**
  33410. * An event triggered when active meshes evaluation is about to start
  33411. */
  33412. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33413. /**
  33414. * An event triggered when active meshes evaluation is done
  33415. */
  33416. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33417. /**
  33418. * An event triggered when particles rendering is about to start
  33419. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33420. */
  33421. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33422. /**
  33423. * An event triggered when particles rendering is done
  33424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33425. */
  33426. onAfterParticlesRenderingObservable: Observable<Scene>;
  33427. /**
  33428. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33429. */
  33430. onDataLoadedObservable: Observable<Scene>;
  33431. /**
  33432. * An event triggered when a camera is created
  33433. */
  33434. onNewCameraAddedObservable: Observable<Camera>;
  33435. /**
  33436. * An event triggered when a camera is removed
  33437. */
  33438. onCameraRemovedObservable: Observable<Camera>;
  33439. /**
  33440. * An event triggered when a light is created
  33441. */
  33442. onNewLightAddedObservable: Observable<Light>;
  33443. /**
  33444. * An event triggered when a light is removed
  33445. */
  33446. onLightRemovedObservable: Observable<Light>;
  33447. /**
  33448. * An event triggered when a geometry is created
  33449. */
  33450. onNewGeometryAddedObservable: Observable<Geometry>;
  33451. /**
  33452. * An event triggered when a geometry is removed
  33453. */
  33454. onGeometryRemovedObservable: Observable<Geometry>;
  33455. /**
  33456. * An event triggered when a transform node is created
  33457. */
  33458. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33459. /**
  33460. * An event triggered when a transform node is removed
  33461. */
  33462. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33463. /**
  33464. * An event triggered when a mesh is created
  33465. */
  33466. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33467. /**
  33468. * An event triggered when a mesh is removed
  33469. */
  33470. onMeshRemovedObservable: Observable<AbstractMesh>;
  33471. /**
  33472. * An event triggered when a skeleton is created
  33473. */
  33474. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33475. /**
  33476. * An event triggered when a skeleton is removed
  33477. */
  33478. onSkeletonRemovedObservable: Observable<Skeleton>;
  33479. /**
  33480. * An event triggered when a material is created
  33481. */
  33482. onNewMaterialAddedObservable: Observable<Material>;
  33483. /**
  33484. * An event triggered when a material is removed
  33485. */
  33486. onMaterialRemovedObservable: Observable<Material>;
  33487. /**
  33488. * An event triggered when a texture is created
  33489. */
  33490. onNewTextureAddedObservable: Observable<BaseTexture>;
  33491. /**
  33492. * An event triggered when a texture is removed
  33493. */
  33494. onTextureRemovedObservable: Observable<BaseTexture>;
  33495. /**
  33496. * An event triggered when render targets are about to be rendered
  33497. * Can happen multiple times per frame.
  33498. */
  33499. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33500. /**
  33501. * An event triggered when render targets were rendered.
  33502. * Can happen multiple times per frame.
  33503. */
  33504. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33505. /**
  33506. * An event triggered before calculating deterministic simulation step
  33507. */
  33508. onBeforeStepObservable: Observable<Scene>;
  33509. /**
  33510. * An event triggered after calculating deterministic simulation step
  33511. */
  33512. onAfterStepObservable: Observable<Scene>;
  33513. /**
  33514. * An event triggered when the activeCamera property is updated
  33515. */
  33516. onActiveCameraChanged: Observable<Scene>;
  33517. /**
  33518. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33519. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33520. * 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)
  33521. */
  33522. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33523. /**
  33524. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33525. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33526. * 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)
  33527. */
  33528. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33529. /**
  33530. * This Observable will when a mesh has been imported into the scene.
  33531. */
  33532. onMeshImportedObservable: Observable<AbstractMesh>;
  33533. /**
  33534. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33535. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33536. */
  33537. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33538. /** @hidden */
  33539. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33540. /**
  33541. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33542. */
  33543. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33544. /**
  33545. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33546. */
  33547. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33548. /**
  33549. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33550. */
  33551. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33552. /** Callback called when a pointer move is detected */
  33553. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33554. /** Callback called when a pointer down is detected */
  33555. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33556. /** Callback called when a pointer up is detected */
  33557. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33558. /** Callback called when a pointer pick is detected */
  33559. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33560. /**
  33561. * 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).
  33562. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33563. */
  33564. onPrePointerObservable: Observable<PointerInfoPre>;
  33565. /**
  33566. * Observable event triggered each time an input event is received from the rendering canvas
  33567. */
  33568. onPointerObservable: Observable<PointerInfo>;
  33569. /**
  33570. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33571. */
  33572. readonly unTranslatedPointer: Vector2;
  33573. /**
  33574. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33575. */
  33576. static DragMovementThreshold: number;
  33577. /**
  33578. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33579. */
  33580. static LongPressDelay: number;
  33581. /**
  33582. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33583. */
  33584. static DoubleClickDelay: number;
  33585. /** If you need to check double click without raising a single click at first click, enable this flag */
  33586. static ExclusiveDoubleClickMode: boolean;
  33587. /** @hidden */
  33588. _mirroredCameraPosition: Nullable<Vector3>;
  33589. /**
  33590. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33591. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33592. */
  33593. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33594. /**
  33595. * Observable event triggered each time an keyboard event is received from the hosting window
  33596. */
  33597. onKeyboardObservable: Observable<KeyboardInfo>;
  33598. private _useRightHandedSystem;
  33599. /**
  33600. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33601. */
  33602. useRightHandedSystem: boolean;
  33603. private _timeAccumulator;
  33604. private _currentStepId;
  33605. private _currentInternalStep;
  33606. /**
  33607. * Sets the step Id used by deterministic lock step
  33608. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33609. * @param newStepId defines the step Id
  33610. */
  33611. setStepId(newStepId: number): void;
  33612. /**
  33613. * Gets the step Id used by deterministic lock step
  33614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33615. * @returns the step Id
  33616. */
  33617. getStepId(): number;
  33618. /**
  33619. * Gets the internal step used by deterministic lock step
  33620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33621. * @returns the internal step
  33622. */
  33623. getInternalStep(): number;
  33624. private _fogEnabled;
  33625. /**
  33626. * Gets or sets a boolean indicating if fog is enabled on this scene
  33627. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33628. * (Default is true)
  33629. */
  33630. fogEnabled: boolean;
  33631. private _fogMode;
  33632. /**
  33633. * Gets or sets the fog mode to use
  33634. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33635. * | mode | value |
  33636. * | --- | --- |
  33637. * | FOGMODE_NONE | 0 |
  33638. * | FOGMODE_EXP | 1 |
  33639. * | FOGMODE_EXP2 | 2 |
  33640. * | FOGMODE_LINEAR | 3 |
  33641. */
  33642. fogMode: number;
  33643. /**
  33644. * Gets or sets the fog color to use
  33645. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33646. * (Default is Color3(0.2, 0.2, 0.3))
  33647. */
  33648. fogColor: Color3;
  33649. /**
  33650. * Gets or sets the fog density to use
  33651. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33652. * (Default is 0.1)
  33653. */
  33654. fogDensity: number;
  33655. /**
  33656. * Gets or sets the fog start distance to use
  33657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33658. * (Default is 0)
  33659. */
  33660. fogStart: number;
  33661. /**
  33662. * Gets or sets the fog end distance to use
  33663. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33664. * (Default is 1000)
  33665. */
  33666. fogEnd: number;
  33667. private _shadowsEnabled;
  33668. /**
  33669. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33670. */
  33671. shadowsEnabled: boolean;
  33672. private _lightsEnabled;
  33673. /**
  33674. * Gets or sets a boolean indicating if lights are enabled on this scene
  33675. */
  33676. lightsEnabled: boolean;
  33677. /** All of the active cameras added to this scene. */
  33678. activeCameras: Camera[];
  33679. /** @hidden */
  33680. _activeCamera: Nullable<Camera>;
  33681. /** Gets or sets the current active camera */
  33682. activeCamera: Nullable<Camera>;
  33683. private _defaultMaterial;
  33684. /** The default material used on meshes when no material is affected */
  33685. /** The default material used on meshes when no material is affected */
  33686. defaultMaterial: Material;
  33687. private _texturesEnabled;
  33688. /**
  33689. * Gets or sets a boolean indicating if textures are enabled on this scene
  33690. */
  33691. texturesEnabled: boolean;
  33692. /**
  33693. * Gets or sets a boolean indicating if particles are enabled on this scene
  33694. */
  33695. particlesEnabled: boolean;
  33696. /**
  33697. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33698. */
  33699. spritesEnabled: boolean;
  33700. private _skeletonsEnabled;
  33701. /**
  33702. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33703. */
  33704. skeletonsEnabled: boolean;
  33705. /**
  33706. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33707. */
  33708. lensFlaresEnabled: boolean;
  33709. /**
  33710. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33712. */
  33713. collisionsEnabled: boolean;
  33714. private _collisionCoordinator;
  33715. /** @hidden */
  33716. readonly collisionCoordinator: ICollisionCoordinator;
  33717. /**
  33718. * Defines the gravity applied to this scene (used only for collisions)
  33719. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33720. */
  33721. gravity: Vector3;
  33722. /**
  33723. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33724. */
  33725. postProcessesEnabled: boolean;
  33726. /**
  33727. * The list of postprocesses added to the scene
  33728. */
  33729. postProcesses: PostProcess[];
  33730. /**
  33731. * Gets the current postprocess manager
  33732. */
  33733. postProcessManager: PostProcessManager;
  33734. /**
  33735. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33736. */
  33737. renderTargetsEnabled: boolean;
  33738. /**
  33739. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33740. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33741. */
  33742. dumpNextRenderTargets: boolean;
  33743. /**
  33744. * The list of user defined render targets added to the scene
  33745. */
  33746. customRenderTargets: RenderTargetTexture[];
  33747. /**
  33748. * Defines if texture loading must be delayed
  33749. * If true, textures will only be loaded when they need to be rendered
  33750. */
  33751. useDelayedTextureLoading: boolean;
  33752. /**
  33753. * Gets the list of meshes imported to the scene through SceneLoader
  33754. */
  33755. importedMeshesFiles: String[];
  33756. /**
  33757. * Gets or sets a boolean indicating if probes are enabled on this scene
  33758. */
  33759. probesEnabled: boolean;
  33760. /**
  33761. * Gets or sets the current offline provider to use to store scene data
  33762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33763. */
  33764. offlineProvider: IOfflineProvider;
  33765. /**
  33766. * Gets or sets the action manager associated with the scene
  33767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33768. */
  33769. actionManager: AbstractActionManager;
  33770. private _meshesForIntersections;
  33771. /**
  33772. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33773. */
  33774. proceduralTexturesEnabled: boolean;
  33775. private _engine;
  33776. private _totalVertices;
  33777. /** @hidden */
  33778. _activeIndices: PerfCounter;
  33779. /** @hidden */
  33780. _activeParticles: PerfCounter;
  33781. /** @hidden */
  33782. _activeBones: PerfCounter;
  33783. private _animationRatio;
  33784. /** @hidden */
  33785. _animationTimeLast: number;
  33786. /** @hidden */
  33787. _animationTime: number;
  33788. /**
  33789. * Gets or sets a general scale for animation speed
  33790. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33791. */
  33792. animationTimeScale: number;
  33793. /** @hidden */
  33794. _cachedMaterial: Nullable<Material>;
  33795. /** @hidden */
  33796. _cachedEffect: Nullable<Effect>;
  33797. /** @hidden */
  33798. _cachedVisibility: Nullable<number>;
  33799. private _renderId;
  33800. private _frameId;
  33801. private _executeWhenReadyTimeoutId;
  33802. private _intermediateRendering;
  33803. private _viewUpdateFlag;
  33804. private _projectionUpdateFlag;
  33805. /** @hidden */
  33806. _toBeDisposed: Nullable<IDisposable>[];
  33807. private _activeRequests;
  33808. /** @hidden */
  33809. _pendingData: any[];
  33810. private _isDisposed;
  33811. /**
  33812. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33813. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33814. */
  33815. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33816. private _activeMeshes;
  33817. private _processedMaterials;
  33818. private _renderTargets;
  33819. /** @hidden */
  33820. _activeParticleSystems: SmartArray<IParticleSystem>;
  33821. private _activeSkeletons;
  33822. private _softwareSkinnedMeshes;
  33823. private _renderingManager;
  33824. /** @hidden */
  33825. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33826. private _transformMatrix;
  33827. private _sceneUbo;
  33828. /** @hidden */
  33829. _viewMatrix: Matrix;
  33830. private _projectionMatrix;
  33831. /** @hidden */
  33832. _forcedViewPosition: Nullable<Vector3>;
  33833. /** @hidden */
  33834. _frustumPlanes: Plane[];
  33835. /**
  33836. * Gets the list of frustum planes (built from the active camera)
  33837. */
  33838. readonly frustumPlanes: Plane[];
  33839. /**
  33840. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33841. * This is useful if there are more lights that the maximum simulteanous authorized
  33842. */
  33843. requireLightSorting: boolean;
  33844. /** @hidden */
  33845. readonly useMaterialMeshMap: boolean;
  33846. /** @hidden */
  33847. readonly useClonedMeshhMap: boolean;
  33848. private _externalData;
  33849. private _uid;
  33850. /**
  33851. * @hidden
  33852. * Backing store of defined scene components.
  33853. */
  33854. _components: ISceneComponent[];
  33855. /**
  33856. * @hidden
  33857. * Backing store of defined scene components.
  33858. */
  33859. _serializableComponents: ISceneSerializableComponent[];
  33860. /**
  33861. * List of components to register on the next registration step.
  33862. */
  33863. private _transientComponents;
  33864. /**
  33865. * Registers the transient components if needed.
  33866. */
  33867. private _registerTransientComponents;
  33868. /**
  33869. * @hidden
  33870. * Add a component to the scene.
  33871. * Note that the ccomponent could be registered on th next frame if this is called after
  33872. * the register component stage.
  33873. * @param component Defines the component to add to the scene
  33874. */
  33875. _addComponent(component: ISceneComponent): void;
  33876. /**
  33877. * @hidden
  33878. * Gets a component from the scene.
  33879. * @param name defines the name of the component to retrieve
  33880. * @returns the component or null if not present
  33881. */
  33882. _getComponent(name: string): Nullable<ISceneComponent>;
  33883. /**
  33884. * @hidden
  33885. * Defines the actions happening before camera updates.
  33886. */
  33887. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33888. /**
  33889. * @hidden
  33890. * Defines the actions happening before clear the canvas.
  33891. */
  33892. _beforeClearStage: Stage<SimpleStageAction>;
  33893. /**
  33894. * @hidden
  33895. * Defines the actions when collecting render targets for the frame.
  33896. */
  33897. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33898. /**
  33899. * @hidden
  33900. * Defines the actions happening for one camera in the frame.
  33901. */
  33902. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33903. /**
  33904. * @hidden
  33905. * Defines the actions happening during the per mesh ready checks.
  33906. */
  33907. _isReadyForMeshStage: Stage<MeshStageAction>;
  33908. /**
  33909. * @hidden
  33910. * Defines the actions happening before evaluate active mesh checks.
  33911. */
  33912. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33913. /**
  33914. * @hidden
  33915. * Defines the actions happening during the evaluate sub mesh checks.
  33916. */
  33917. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33918. /**
  33919. * @hidden
  33920. * Defines the actions happening during the active mesh stage.
  33921. */
  33922. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33923. /**
  33924. * @hidden
  33925. * Defines the actions happening during the per camera render target step.
  33926. */
  33927. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33928. /**
  33929. * @hidden
  33930. * Defines the actions happening just before the active camera is drawing.
  33931. */
  33932. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33933. /**
  33934. * @hidden
  33935. * Defines the actions happening just before a render target is drawing.
  33936. */
  33937. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33938. /**
  33939. * @hidden
  33940. * Defines the actions happening just before a rendering group is drawing.
  33941. */
  33942. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33943. /**
  33944. * @hidden
  33945. * Defines the actions happening just before a mesh is drawing.
  33946. */
  33947. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33948. /**
  33949. * @hidden
  33950. * Defines the actions happening just after a mesh has been drawn.
  33951. */
  33952. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33953. /**
  33954. * @hidden
  33955. * Defines the actions happening just after a rendering group has been drawn.
  33956. */
  33957. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33958. /**
  33959. * @hidden
  33960. * Defines the actions happening just after the active camera has been drawn.
  33961. */
  33962. _afterCameraDrawStage: Stage<CameraStageAction>;
  33963. /**
  33964. * @hidden
  33965. * Defines the actions happening just after a render target has been drawn.
  33966. */
  33967. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33968. /**
  33969. * @hidden
  33970. * Defines the actions happening just after rendering all cameras and computing intersections.
  33971. */
  33972. _afterRenderStage: Stage<SimpleStageAction>;
  33973. /**
  33974. * @hidden
  33975. * Defines the actions happening when a pointer move event happens.
  33976. */
  33977. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33978. /**
  33979. * @hidden
  33980. * Defines the actions happening when a pointer down event happens.
  33981. */
  33982. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33983. /**
  33984. * @hidden
  33985. * Defines the actions happening when a pointer up event happens.
  33986. */
  33987. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33988. /**
  33989. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33990. */
  33991. private geometriesByUniqueId;
  33992. /**
  33993. * Creates a new Scene
  33994. * @param engine defines the engine to use to render this scene
  33995. * @param options defines the scene options
  33996. */
  33997. constructor(engine: Engine, options?: SceneOptions);
  33998. /**
  33999. * Gets a string idenfifying the name of the class
  34000. * @returns "Scene" string
  34001. */
  34002. getClassName(): string;
  34003. private _defaultMeshCandidates;
  34004. /**
  34005. * @hidden
  34006. */
  34007. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34008. private _defaultSubMeshCandidates;
  34009. /**
  34010. * @hidden
  34011. */
  34012. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34013. /**
  34014. * Sets the default candidate providers for the scene.
  34015. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34016. * and getCollidingSubMeshCandidates to their default function
  34017. */
  34018. setDefaultCandidateProviders(): void;
  34019. /**
  34020. * Gets the mesh that is currently under the pointer
  34021. */
  34022. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34023. /**
  34024. * Gets or sets the current on-screen X position of the pointer
  34025. */
  34026. pointerX: number;
  34027. /**
  34028. * Gets or sets the current on-screen Y position of the pointer
  34029. */
  34030. pointerY: number;
  34031. /**
  34032. * Gets the cached material (ie. the latest rendered one)
  34033. * @returns the cached material
  34034. */
  34035. getCachedMaterial(): Nullable<Material>;
  34036. /**
  34037. * Gets the cached effect (ie. the latest rendered one)
  34038. * @returns the cached effect
  34039. */
  34040. getCachedEffect(): Nullable<Effect>;
  34041. /**
  34042. * Gets the cached visibility state (ie. the latest rendered one)
  34043. * @returns the cached visibility state
  34044. */
  34045. getCachedVisibility(): Nullable<number>;
  34046. /**
  34047. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34048. * @param material defines the current material
  34049. * @param effect defines the current effect
  34050. * @param visibility defines the current visibility state
  34051. * @returns true if one parameter is not cached
  34052. */
  34053. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34054. /**
  34055. * Gets the engine associated with the scene
  34056. * @returns an Engine
  34057. */
  34058. getEngine(): Engine;
  34059. /**
  34060. * Gets the total number of vertices rendered per frame
  34061. * @returns the total number of vertices rendered per frame
  34062. */
  34063. getTotalVertices(): number;
  34064. /**
  34065. * Gets the performance counter for total vertices
  34066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34067. */
  34068. readonly totalVerticesPerfCounter: PerfCounter;
  34069. /**
  34070. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34071. * @returns the total number of active indices rendered per frame
  34072. */
  34073. getActiveIndices(): number;
  34074. /**
  34075. * Gets the performance counter for active indices
  34076. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34077. */
  34078. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34079. /**
  34080. * Gets the total number of active particles rendered per frame
  34081. * @returns the total number of active particles rendered per frame
  34082. */
  34083. getActiveParticles(): number;
  34084. /**
  34085. * Gets the performance counter for active particles
  34086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34087. */
  34088. readonly activeParticlesPerfCounter: PerfCounter;
  34089. /**
  34090. * Gets the total number of active bones rendered per frame
  34091. * @returns the total number of active bones rendered per frame
  34092. */
  34093. getActiveBones(): number;
  34094. /**
  34095. * Gets the performance counter for active bones
  34096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34097. */
  34098. readonly activeBonesPerfCounter: PerfCounter;
  34099. /**
  34100. * Gets the array of active meshes
  34101. * @returns an array of AbstractMesh
  34102. */
  34103. getActiveMeshes(): SmartArray<AbstractMesh>;
  34104. /**
  34105. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34106. * @returns a number
  34107. */
  34108. getAnimationRatio(): number;
  34109. /**
  34110. * Gets an unique Id for the current render phase
  34111. * @returns a number
  34112. */
  34113. getRenderId(): number;
  34114. /**
  34115. * Gets an unique Id for the current frame
  34116. * @returns a number
  34117. */
  34118. getFrameId(): number;
  34119. /** Call this function if you want to manually increment the render Id*/
  34120. incrementRenderId(): void;
  34121. private _createUbo;
  34122. /**
  34123. * Use this method to simulate a pointer move on a mesh
  34124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34127. * @returns the current scene
  34128. */
  34129. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34130. /**
  34131. * Use this method to simulate a pointer down on a mesh
  34132. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34133. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34134. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34135. * @returns the current scene
  34136. */
  34137. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34138. /**
  34139. * Use this method to simulate a pointer up on a mesh
  34140. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34141. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34142. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34143. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34144. * @returns the current scene
  34145. */
  34146. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34147. /**
  34148. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34149. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34150. * @returns true if the pointer was captured
  34151. */
  34152. isPointerCaptured(pointerId?: number): boolean;
  34153. /**
  34154. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34155. * @param attachUp defines if you want to attach events to pointerup
  34156. * @param attachDown defines if you want to attach events to pointerdown
  34157. * @param attachMove defines if you want to attach events to pointermove
  34158. */
  34159. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34160. /** Detaches all event handlers*/
  34161. detachControl(): void;
  34162. /**
  34163. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34164. * Delay loaded resources are not taking in account
  34165. * @return true if all required resources are ready
  34166. */
  34167. isReady(): boolean;
  34168. /** Resets all cached information relative to material (including effect and visibility) */
  34169. resetCachedMaterial(): void;
  34170. /**
  34171. * Registers a function to be called before every frame render
  34172. * @param func defines the function to register
  34173. */
  34174. registerBeforeRender(func: () => void): void;
  34175. /**
  34176. * Unregisters a function called before every frame render
  34177. * @param func defines the function to unregister
  34178. */
  34179. unregisterBeforeRender(func: () => void): void;
  34180. /**
  34181. * Registers a function to be called after every frame render
  34182. * @param func defines the function to register
  34183. */
  34184. registerAfterRender(func: () => void): void;
  34185. /**
  34186. * Unregisters a function called after every frame render
  34187. * @param func defines the function to unregister
  34188. */
  34189. unregisterAfterRender(func: () => void): void;
  34190. private _executeOnceBeforeRender;
  34191. /**
  34192. * The provided function will run before render once and will be disposed afterwards.
  34193. * A timeout delay can be provided so that the function will be executed in N ms.
  34194. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34195. * @param func The function to be executed.
  34196. * @param timeout optional delay in ms
  34197. */
  34198. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34199. /** @hidden */
  34200. _addPendingData(data: any): void;
  34201. /** @hidden */
  34202. _removePendingData(data: any): void;
  34203. /**
  34204. * Returns the number of items waiting to be loaded
  34205. * @returns the number of items waiting to be loaded
  34206. */
  34207. getWaitingItemsCount(): number;
  34208. /**
  34209. * Returns a boolean indicating if the scene is still loading data
  34210. */
  34211. readonly isLoading: boolean;
  34212. /**
  34213. * Registers a function to be executed when the scene is ready
  34214. * @param {Function} func - the function to be executed
  34215. */
  34216. executeWhenReady(func: () => void): void;
  34217. /**
  34218. * Returns a promise that resolves when the scene is ready
  34219. * @returns A promise that resolves when the scene is ready
  34220. */
  34221. whenReadyAsync(): Promise<void>;
  34222. /** @hidden */
  34223. _checkIsReady(): void;
  34224. /**
  34225. * Gets all animatable attached to the scene
  34226. */
  34227. readonly animatables: Animatable[];
  34228. /**
  34229. * Resets the last animation time frame.
  34230. * Useful to override when animations start running when loading a scene for the first time.
  34231. */
  34232. resetLastAnimationTimeFrame(): void;
  34233. /**
  34234. * Gets the current view matrix
  34235. * @returns a Matrix
  34236. */
  34237. getViewMatrix(): Matrix;
  34238. /**
  34239. * Gets the current projection matrix
  34240. * @returns a Matrix
  34241. */
  34242. getProjectionMatrix(): Matrix;
  34243. /**
  34244. * Gets the current transform matrix
  34245. * @returns a Matrix made of View * Projection
  34246. */
  34247. getTransformMatrix(): Matrix;
  34248. /**
  34249. * Sets the current transform matrix
  34250. * @param viewL defines the View matrix to use
  34251. * @param projectionL defines the Projection matrix to use
  34252. * @param viewR defines the right View matrix to use (if provided)
  34253. * @param projectionR defines the right Projection matrix to use (if provided)
  34254. */
  34255. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34256. /**
  34257. * Gets the uniform buffer used to store scene data
  34258. * @returns a UniformBuffer
  34259. */
  34260. getSceneUniformBuffer(): UniformBuffer;
  34261. /**
  34262. * Gets an unique (relatively to the current scene) Id
  34263. * @returns an unique number for the scene
  34264. */
  34265. getUniqueId(): number;
  34266. /**
  34267. * Add a mesh to the list of scene's meshes
  34268. * @param newMesh defines the mesh to add
  34269. * @param recursive if all child meshes should also be added to the scene
  34270. */
  34271. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34272. /**
  34273. * Remove a mesh for the list of scene's meshes
  34274. * @param toRemove defines the mesh to remove
  34275. * @param recursive if all child meshes should also be removed from the scene
  34276. * @returns the index where the mesh was in the mesh list
  34277. */
  34278. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34279. /**
  34280. * Add a transform node to the list of scene's transform nodes
  34281. * @param newTransformNode defines the transform node to add
  34282. */
  34283. addTransformNode(newTransformNode: TransformNode): void;
  34284. /**
  34285. * Remove a transform node for the list of scene's transform nodes
  34286. * @param toRemove defines the transform node to remove
  34287. * @returns the index where the transform node was in the transform node list
  34288. */
  34289. removeTransformNode(toRemove: TransformNode): number;
  34290. /**
  34291. * Remove a skeleton for the list of scene's skeletons
  34292. * @param toRemove defines the skeleton to remove
  34293. * @returns the index where the skeleton was in the skeleton list
  34294. */
  34295. removeSkeleton(toRemove: Skeleton): number;
  34296. /**
  34297. * Remove a morph target for the list of scene's morph targets
  34298. * @param toRemove defines the morph target to remove
  34299. * @returns the index where the morph target was in the morph target list
  34300. */
  34301. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34302. /**
  34303. * Remove a light for the list of scene's lights
  34304. * @param toRemove defines the light to remove
  34305. * @returns the index where the light was in the light list
  34306. */
  34307. removeLight(toRemove: Light): number;
  34308. /**
  34309. * Remove a camera for the list of scene's cameras
  34310. * @param toRemove defines the camera to remove
  34311. * @returns the index where the camera was in the camera list
  34312. */
  34313. removeCamera(toRemove: Camera): number;
  34314. /**
  34315. * Remove a particle system for the list of scene's particle systems
  34316. * @param toRemove defines the particle system to remove
  34317. * @returns the index where the particle system was in the particle system list
  34318. */
  34319. removeParticleSystem(toRemove: IParticleSystem): number;
  34320. /**
  34321. * Remove a animation for the list of scene's animations
  34322. * @param toRemove defines the animation to remove
  34323. * @returns the index where the animation was in the animation list
  34324. */
  34325. removeAnimation(toRemove: Animation): number;
  34326. /**
  34327. * Will stop the animation of the given target
  34328. * @param target - the target
  34329. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34330. * @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)
  34331. */
  34332. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34333. /**
  34334. * Removes the given animation group from this scene.
  34335. * @param toRemove The animation group to remove
  34336. * @returns The index of the removed animation group
  34337. */
  34338. removeAnimationGroup(toRemove: AnimationGroup): number;
  34339. /**
  34340. * Removes the given multi-material from this scene.
  34341. * @param toRemove The multi-material to remove
  34342. * @returns The index of the removed multi-material
  34343. */
  34344. removeMultiMaterial(toRemove: MultiMaterial): number;
  34345. /**
  34346. * Removes the given material from this scene.
  34347. * @param toRemove The material to remove
  34348. * @returns The index of the removed material
  34349. */
  34350. removeMaterial(toRemove: Material): number;
  34351. /**
  34352. * Removes the given action manager from this scene.
  34353. * @param toRemove The action manager to remove
  34354. * @returns The index of the removed action manager
  34355. */
  34356. removeActionManager(toRemove: AbstractActionManager): number;
  34357. /**
  34358. * Removes the given texture from this scene.
  34359. * @param toRemove The texture to remove
  34360. * @returns The index of the removed texture
  34361. */
  34362. removeTexture(toRemove: BaseTexture): number;
  34363. /**
  34364. * Adds the given light to this scene
  34365. * @param newLight The light to add
  34366. */
  34367. addLight(newLight: Light): void;
  34368. /**
  34369. * Sorts the list list based on light priorities
  34370. */
  34371. sortLightsByPriority(): void;
  34372. /**
  34373. * Adds the given camera to this scene
  34374. * @param newCamera The camera to add
  34375. */
  34376. addCamera(newCamera: Camera): void;
  34377. /**
  34378. * Adds the given skeleton to this scene
  34379. * @param newSkeleton The skeleton to add
  34380. */
  34381. addSkeleton(newSkeleton: Skeleton): void;
  34382. /**
  34383. * Adds the given particle system to this scene
  34384. * @param newParticleSystem The particle system to add
  34385. */
  34386. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34387. /**
  34388. * Adds the given animation to this scene
  34389. * @param newAnimation The animation to add
  34390. */
  34391. addAnimation(newAnimation: Animation): void;
  34392. /**
  34393. * Adds the given animation group to this scene.
  34394. * @param newAnimationGroup The animation group to add
  34395. */
  34396. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34397. /**
  34398. * Adds the given multi-material to this scene
  34399. * @param newMultiMaterial The multi-material to add
  34400. */
  34401. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34402. /**
  34403. * Adds the given material to this scene
  34404. * @param newMaterial The material to add
  34405. */
  34406. addMaterial(newMaterial: Material): void;
  34407. /**
  34408. * Adds the given morph target to this scene
  34409. * @param newMorphTargetManager The morph target to add
  34410. */
  34411. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34412. /**
  34413. * Adds the given geometry to this scene
  34414. * @param newGeometry The geometry to add
  34415. */
  34416. addGeometry(newGeometry: Geometry): void;
  34417. /**
  34418. * Adds the given action manager to this scene
  34419. * @param newActionManager The action manager to add
  34420. */
  34421. addActionManager(newActionManager: AbstractActionManager): void;
  34422. /**
  34423. * Adds the given texture to this scene.
  34424. * @param newTexture The texture to add
  34425. */
  34426. addTexture(newTexture: BaseTexture): void;
  34427. /**
  34428. * Switch active camera
  34429. * @param newCamera defines the new active camera
  34430. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34431. */
  34432. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34433. /**
  34434. * sets the active camera of the scene using its ID
  34435. * @param id defines the camera's ID
  34436. * @return the new active camera or null if none found.
  34437. */
  34438. setActiveCameraByID(id: string): Nullable<Camera>;
  34439. /**
  34440. * sets the active camera of the scene using its name
  34441. * @param name defines the camera's name
  34442. * @returns the new active camera or null if none found.
  34443. */
  34444. setActiveCameraByName(name: string): Nullable<Camera>;
  34445. /**
  34446. * get an animation group using its name
  34447. * @param name defines the material's name
  34448. * @return the animation group or null if none found.
  34449. */
  34450. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34451. /**
  34452. * Get a material using its unique id
  34453. * @param uniqueId defines the material's unique id
  34454. * @return the material or null if none found.
  34455. */
  34456. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34457. /**
  34458. * get a material using its id
  34459. * @param id defines the material's ID
  34460. * @return the material or null if none found.
  34461. */
  34462. getMaterialByID(id: string): Nullable<Material>;
  34463. /**
  34464. * Gets a the last added material using a given id
  34465. * @param id defines the material's ID
  34466. * @return the last material with the given id or null if none found.
  34467. */
  34468. getLastMaterialByID(id: string): Nullable<Material>;
  34469. /**
  34470. * Gets a material using its name
  34471. * @param name defines the material's name
  34472. * @return the material or null if none found.
  34473. */
  34474. getMaterialByName(name: string): Nullable<Material>;
  34475. /**
  34476. * Gets a camera using its id
  34477. * @param id defines the id to look for
  34478. * @returns the camera or null if not found
  34479. */
  34480. getCameraByID(id: string): Nullable<Camera>;
  34481. /**
  34482. * Gets a camera using its unique id
  34483. * @param uniqueId defines the unique id to look for
  34484. * @returns the camera or null if not found
  34485. */
  34486. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34487. /**
  34488. * Gets a camera using its name
  34489. * @param name defines the camera's name
  34490. * @return the camera or null if none found.
  34491. */
  34492. getCameraByName(name: string): Nullable<Camera>;
  34493. /**
  34494. * Gets a bone using its id
  34495. * @param id defines the bone's id
  34496. * @return the bone or null if not found
  34497. */
  34498. getBoneByID(id: string): Nullable<Bone>;
  34499. /**
  34500. * Gets a bone using its id
  34501. * @param name defines the bone's name
  34502. * @return the bone or null if not found
  34503. */
  34504. getBoneByName(name: string): Nullable<Bone>;
  34505. /**
  34506. * Gets a light node using its name
  34507. * @param name defines the the light's name
  34508. * @return the light or null if none found.
  34509. */
  34510. getLightByName(name: string): Nullable<Light>;
  34511. /**
  34512. * Gets a light node using its id
  34513. * @param id defines the light's id
  34514. * @return the light or null if none found.
  34515. */
  34516. getLightByID(id: string): Nullable<Light>;
  34517. /**
  34518. * Gets a light node using its scene-generated unique ID
  34519. * @param uniqueId defines the light's unique id
  34520. * @return the light or null if none found.
  34521. */
  34522. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34523. /**
  34524. * Gets a particle system by id
  34525. * @param id defines the particle system id
  34526. * @return the corresponding system or null if none found
  34527. */
  34528. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34529. /**
  34530. * Gets a geometry using its ID
  34531. * @param id defines the geometry's id
  34532. * @return the geometry or null if none found.
  34533. */
  34534. getGeometryByID(id: string): Nullable<Geometry>;
  34535. private _getGeometryByUniqueID;
  34536. /**
  34537. * Add a new geometry to this scene
  34538. * @param geometry defines the geometry to be added to the scene.
  34539. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34540. * @return a boolean defining if the geometry was added or not
  34541. */
  34542. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34543. /**
  34544. * Removes an existing geometry
  34545. * @param geometry defines the geometry to be removed from the scene
  34546. * @return a boolean defining if the geometry was removed or not
  34547. */
  34548. removeGeometry(geometry: Geometry): boolean;
  34549. /**
  34550. * Gets the list of geometries attached to the scene
  34551. * @returns an array of Geometry
  34552. */
  34553. getGeometries(): Geometry[];
  34554. /**
  34555. * Gets the first added mesh found of a given ID
  34556. * @param id defines the id to search for
  34557. * @return the mesh found or null if not found at all
  34558. */
  34559. getMeshByID(id: string): Nullable<AbstractMesh>;
  34560. /**
  34561. * Gets a list of meshes using their id
  34562. * @param id defines the id to search for
  34563. * @returns a list of meshes
  34564. */
  34565. getMeshesByID(id: string): Array<AbstractMesh>;
  34566. /**
  34567. * Gets the first added transform node found of a given ID
  34568. * @param id defines the id to search for
  34569. * @return the found transform node or null if not found at all.
  34570. */
  34571. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34572. /**
  34573. * Gets a transform node with its auto-generated unique id
  34574. * @param uniqueId efines the unique id to search for
  34575. * @return the found transform node or null if not found at all.
  34576. */
  34577. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34578. /**
  34579. * Gets a list of transform nodes using their id
  34580. * @param id defines the id to search for
  34581. * @returns a list of transform nodes
  34582. */
  34583. getTransformNodesByID(id: string): Array<TransformNode>;
  34584. /**
  34585. * Gets a mesh with its auto-generated unique id
  34586. * @param uniqueId defines the unique id to search for
  34587. * @return the found mesh or null if not found at all.
  34588. */
  34589. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34590. /**
  34591. * Gets a the last added mesh using a given id
  34592. * @param id defines the id to search for
  34593. * @return the found mesh or null if not found at all.
  34594. */
  34595. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34596. /**
  34597. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34598. * @param id defines the id to search for
  34599. * @return the found node or null if not found at all
  34600. */
  34601. getLastEntryByID(id: string): Nullable<Node>;
  34602. /**
  34603. * Gets a node (Mesh, Camera, Light) using a given id
  34604. * @param id defines the id to search for
  34605. * @return the found node or null if not found at all
  34606. */
  34607. getNodeByID(id: string): Nullable<Node>;
  34608. /**
  34609. * Gets a node (Mesh, Camera, Light) using a given name
  34610. * @param name defines the name to search for
  34611. * @return the found node or null if not found at all.
  34612. */
  34613. getNodeByName(name: string): Nullable<Node>;
  34614. /**
  34615. * Gets a mesh using a given name
  34616. * @param name defines the name to search for
  34617. * @return the found mesh or null if not found at all.
  34618. */
  34619. getMeshByName(name: string): Nullable<AbstractMesh>;
  34620. /**
  34621. * Gets a transform node using a given name
  34622. * @param name defines the name to search for
  34623. * @return the found transform node or null if not found at all.
  34624. */
  34625. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34626. /**
  34627. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34628. * @param id defines the id to search for
  34629. * @return the found skeleton or null if not found at all.
  34630. */
  34631. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34632. /**
  34633. * Gets a skeleton using a given auto generated unique id
  34634. * @param uniqueId defines the unique id to search for
  34635. * @return the found skeleton or null if not found at all.
  34636. */
  34637. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34638. /**
  34639. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34640. * @param id defines the id to search for
  34641. * @return the found skeleton or null if not found at all.
  34642. */
  34643. getSkeletonById(id: string): Nullable<Skeleton>;
  34644. /**
  34645. * Gets a skeleton using a given name
  34646. * @param name defines the name to search for
  34647. * @return the found skeleton or null if not found at all.
  34648. */
  34649. getSkeletonByName(name: string): Nullable<Skeleton>;
  34650. /**
  34651. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34652. * @param id defines the id to search for
  34653. * @return the found morph target manager or null if not found at all.
  34654. */
  34655. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34656. /**
  34657. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34658. * @param id defines the id to search for
  34659. * @return the found morph target or null if not found at all.
  34660. */
  34661. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34662. /**
  34663. * Gets a boolean indicating if the given mesh is active
  34664. * @param mesh defines the mesh to look for
  34665. * @returns true if the mesh is in the active list
  34666. */
  34667. isActiveMesh(mesh: AbstractMesh): boolean;
  34668. /**
  34669. * Return a unique id as a string which can serve as an identifier for the scene
  34670. */
  34671. readonly uid: string;
  34672. /**
  34673. * Add an externaly attached data from its key.
  34674. * This method call will fail and return false, if such key already exists.
  34675. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34676. * @param key the unique key that identifies the data
  34677. * @param data the data object to associate to the key for this Engine instance
  34678. * @return true if no such key were already present and the data was added successfully, false otherwise
  34679. */
  34680. addExternalData<T>(key: string, data: T): boolean;
  34681. /**
  34682. * Get an externaly attached data from its key
  34683. * @param key the unique key that identifies the data
  34684. * @return the associated data, if present (can be null), or undefined if not present
  34685. */
  34686. getExternalData<T>(key: string): Nullable<T>;
  34687. /**
  34688. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34689. * @param key the unique key that identifies the data
  34690. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34691. * @return the associated data, can be null if the factory returned null.
  34692. */
  34693. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34694. /**
  34695. * Remove an externaly attached data from the Engine instance
  34696. * @param key the unique key that identifies the data
  34697. * @return true if the data was successfully removed, false if it doesn't exist
  34698. */
  34699. removeExternalData(key: string): boolean;
  34700. private _evaluateSubMesh;
  34701. /**
  34702. * Clear the processed materials smart array preventing retention point in material dispose.
  34703. */
  34704. freeProcessedMaterials(): void;
  34705. private _preventFreeActiveMeshesAndRenderingGroups;
  34706. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34707. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34708. * when disposing several meshes in a row or a hierarchy of meshes.
  34709. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34710. */
  34711. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34712. /**
  34713. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34714. */
  34715. freeActiveMeshes(): void;
  34716. /**
  34717. * Clear the info related to rendering groups preventing retention points during dispose.
  34718. */
  34719. freeRenderingGroups(): void;
  34720. /** @hidden */
  34721. _isInIntermediateRendering(): boolean;
  34722. /**
  34723. * Lambda returning the list of potentially active meshes.
  34724. */
  34725. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34726. /**
  34727. * Lambda returning the list of potentially active sub meshes.
  34728. */
  34729. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34730. /**
  34731. * Lambda returning the list of potentially intersecting sub meshes.
  34732. */
  34733. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34734. /**
  34735. * Lambda returning the list of potentially colliding sub meshes.
  34736. */
  34737. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34738. private _activeMeshesFrozen;
  34739. /**
  34740. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34741. * @returns the current scene
  34742. */
  34743. freezeActiveMeshes(): Scene;
  34744. /**
  34745. * Use this function to restart evaluating active meshes on every frame
  34746. * @returns the current scene
  34747. */
  34748. unfreezeActiveMeshes(): Scene;
  34749. private _evaluateActiveMeshes;
  34750. private _activeMesh;
  34751. /**
  34752. * Update the transform matrix to update from the current active camera
  34753. * @param force defines a boolean used to force the update even if cache is up to date
  34754. */
  34755. updateTransformMatrix(force?: boolean): void;
  34756. private _bindFrameBuffer;
  34757. /** @hidden */
  34758. _allowPostProcessClearColor: boolean;
  34759. /** @hidden */
  34760. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34761. private _processSubCameras;
  34762. private _checkIntersections;
  34763. /** @hidden */
  34764. _advancePhysicsEngineStep(step: number): void;
  34765. /**
  34766. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34767. */
  34768. getDeterministicFrameTime: () => number;
  34769. /** @hidden */
  34770. _animate(): void;
  34771. /** Execute all animations (for a frame) */
  34772. animate(): void;
  34773. /**
  34774. * Render the scene
  34775. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34776. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34777. */
  34778. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34779. /**
  34780. * Freeze all materials
  34781. * A frozen material will not be updatable but should be faster to render
  34782. */
  34783. freezeMaterials(): void;
  34784. /**
  34785. * Unfreeze all materials
  34786. * A frozen material will not be updatable but should be faster to render
  34787. */
  34788. unfreezeMaterials(): void;
  34789. /**
  34790. * Releases all held ressources
  34791. */
  34792. dispose(): void;
  34793. /**
  34794. * Gets if the scene is already disposed
  34795. */
  34796. readonly isDisposed: boolean;
  34797. /**
  34798. * Call this function to reduce memory footprint of the scene.
  34799. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34800. */
  34801. clearCachedVertexData(): void;
  34802. /**
  34803. * This function will remove the local cached buffer data from texture.
  34804. * It will save memory but will prevent the texture from being rebuilt
  34805. */
  34806. cleanCachedTextureBuffer(): void;
  34807. /**
  34808. * Get the world extend vectors with an optional filter
  34809. *
  34810. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34811. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34812. */
  34813. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34814. min: Vector3;
  34815. max: Vector3;
  34816. };
  34817. /**
  34818. * Creates a ray that can be used to pick in the scene
  34819. * @param x defines the x coordinate of the origin (on-screen)
  34820. * @param y defines the y coordinate of the origin (on-screen)
  34821. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34822. * @param camera defines the camera to use for the picking
  34823. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34824. * @returns a Ray
  34825. */
  34826. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34827. /**
  34828. * Creates a ray that can be used to pick in the scene
  34829. * @param x defines the x coordinate of the origin (on-screen)
  34830. * @param y defines the y coordinate of the origin (on-screen)
  34831. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34832. * @param result defines the ray where to store the picking ray
  34833. * @param camera defines the camera to use for the picking
  34834. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34835. * @returns the current scene
  34836. */
  34837. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34838. /**
  34839. * Creates a ray that can be used to pick in the scene
  34840. * @param x defines the x coordinate of the origin (on-screen)
  34841. * @param y defines the y coordinate of the origin (on-screen)
  34842. * @param camera defines the camera to use for the picking
  34843. * @returns a Ray
  34844. */
  34845. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34846. /**
  34847. * Creates a ray that can be used to pick in the scene
  34848. * @param x defines the x coordinate of the origin (on-screen)
  34849. * @param y defines the y coordinate of the origin (on-screen)
  34850. * @param result defines the ray where to store the picking ray
  34851. * @param camera defines the camera to use for the picking
  34852. * @returns the current scene
  34853. */
  34854. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34855. /** Launch a ray to try to pick a mesh in the scene
  34856. * @param x position on screen
  34857. * @param y position on screen
  34858. * @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
  34859. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34860. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34862. * @returns a PickingInfo
  34863. */
  34864. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34865. /** Use the given ray to pick a mesh in the scene
  34866. * @param ray The ray to use to pick meshes
  34867. * @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
  34868. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34870. * @returns a PickingInfo
  34871. */
  34872. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34873. /**
  34874. * Launch a ray to try to pick a mesh in the scene
  34875. * @param x X position on screen
  34876. * @param y Y position on screen
  34877. * @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
  34878. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34880. * @returns an array of PickingInfo
  34881. */
  34882. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34883. /**
  34884. * Launch a ray to try to pick a mesh in the scene
  34885. * @param ray Ray to use
  34886. * @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
  34887. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34888. * @returns an array of PickingInfo
  34889. */
  34890. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34891. /**
  34892. * Force the value of meshUnderPointer
  34893. * @param mesh defines the mesh to use
  34894. */
  34895. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34896. /**
  34897. * Gets the mesh under the pointer
  34898. * @returns a Mesh or null if no mesh is under the pointer
  34899. */
  34900. getPointerOverMesh(): Nullable<AbstractMesh>;
  34901. /** @hidden */
  34902. _rebuildGeometries(): void;
  34903. /** @hidden */
  34904. _rebuildTextures(): void;
  34905. private _getByTags;
  34906. /**
  34907. * Get a list of meshes by tags
  34908. * @param tagsQuery defines the tags query to use
  34909. * @param forEach defines a predicate used to filter results
  34910. * @returns an array of Mesh
  34911. */
  34912. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34913. /**
  34914. * Get a list of cameras by tags
  34915. * @param tagsQuery defines the tags query to use
  34916. * @param forEach defines a predicate used to filter results
  34917. * @returns an array of Camera
  34918. */
  34919. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34920. /**
  34921. * Get a list of lights by tags
  34922. * @param tagsQuery defines the tags query to use
  34923. * @param forEach defines a predicate used to filter results
  34924. * @returns an array of Light
  34925. */
  34926. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34927. /**
  34928. * Get a list of materials by tags
  34929. * @param tagsQuery defines the tags query to use
  34930. * @param forEach defines a predicate used to filter results
  34931. * @returns an array of Material
  34932. */
  34933. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34934. /**
  34935. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34936. * This allowed control for front to back rendering or reversly depending of the special needs.
  34937. *
  34938. * @param renderingGroupId The rendering group id corresponding to its index
  34939. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34940. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34941. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34942. */
  34943. 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;
  34944. /**
  34945. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34946. *
  34947. * @param renderingGroupId The rendering group id corresponding to its index
  34948. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34949. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34950. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34951. */
  34952. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34953. /**
  34954. * Gets the current auto clear configuration for one rendering group of the rendering
  34955. * manager.
  34956. * @param index the rendering group index to get the information for
  34957. * @returns The auto clear setup for the requested rendering group
  34958. */
  34959. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34960. private _blockMaterialDirtyMechanism;
  34961. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34962. blockMaterialDirtyMechanism: boolean;
  34963. /**
  34964. * Will flag all materials as dirty to trigger new shader compilation
  34965. * @param flag defines the flag used to specify which material part must be marked as dirty
  34966. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34967. */
  34968. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34969. /** @hidden */
  34970. _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;
  34971. /** @hidden */
  34972. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34973. }
  34974. }
  34975. declare module "babylonjs/assetContainer" {
  34976. import { AbstractScene } from "babylonjs/abstractScene";
  34977. import { Scene } from "babylonjs/scene";
  34978. import { Mesh } from "babylonjs/Meshes/mesh";
  34979. /**
  34980. * Set of assets to keep when moving a scene into an asset container.
  34981. */
  34982. export class KeepAssets extends AbstractScene {
  34983. }
  34984. /**
  34985. * Container with a set of assets that can be added or removed from a scene.
  34986. */
  34987. export class AssetContainer extends AbstractScene {
  34988. /**
  34989. * The scene the AssetContainer belongs to.
  34990. */
  34991. scene: Scene;
  34992. /**
  34993. * Instantiates an AssetContainer.
  34994. * @param scene The scene the AssetContainer belongs to.
  34995. */
  34996. constructor(scene: Scene);
  34997. /**
  34998. * Adds all the assets from the container to the scene.
  34999. */
  35000. addAllToScene(): void;
  35001. /**
  35002. * Removes all the assets in the container from the scene
  35003. */
  35004. removeAllFromScene(): void;
  35005. /**
  35006. * Disposes all the assets in the container
  35007. */
  35008. dispose(): void;
  35009. private _moveAssets;
  35010. /**
  35011. * Removes all the assets contained in the scene and adds them to the container.
  35012. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35013. */
  35014. moveAllFromScene(keepAssets?: KeepAssets): void;
  35015. /**
  35016. * 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.
  35017. * @returns the root mesh
  35018. */
  35019. createRootMesh(): Mesh;
  35020. }
  35021. }
  35022. declare module "babylonjs/abstractScene" {
  35023. import { Scene } from "babylonjs/scene";
  35024. import { Nullable } from "babylonjs/types";
  35025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35027. import { Geometry } from "babylonjs/Meshes/geometry";
  35028. import { Skeleton } from "babylonjs/Bones/skeleton";
  35029. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35030. import { AssetContainer } from "babylonjs/assetContainer";
  35031. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35032. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35034. import { Material } from "babylonjs/Materials/material";
  35035. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35036. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35037. import { Camera } from "babylonjs/Cameras/camera";
  35038. import { Light } from "babylonjs/Lights/light";
  35039. import { Node } from "babylonjs/node";
  35040. import { Animation } from "babylonjs/Animations/animation";
  35041. /**
  35042. * Defines how the parser contract is defined.
  35043. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35044. */
  35045. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35046. /**
  35047. * Defines how the individual parser contract is defined.
  35048. * These parser can parse an individual asset
  35049. */
  35050. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35051. /**
  35052. * Base class of the scene acting as a container for the different elements composing a scene.
  35053. * This class is dynamically extended by the different components of the scene increasing
  35054. * flexibility and reducing coupling
  35055. */
  35056. export abstract class AbstractScene {
  35057. /**
  35058. * Stores the list of available parsers in the application.
  35059. */
  35060. private static _BabylonFileParsers;
  35061. /**
  35062. * Stores the list of available individual parsers in the application.
  35063. */
  35064. private static _IndividualBabylonFileParsers;
  35065. /**
  35066. * Adds a parser in the list of available ones
  35067. * @param name Defines the name of the parser
  35068. * @param parser Defines the parser to add
  35069. */
  35070. static AddParser(name: string, parser: BabylonFileParser): void;
  35071. /**
  35072. * Gets a general parser from the list of avaialble ones
  35073. * @param name Defines the name of the parser
  35074. * @returns the requested parser or null
  35075. */
  35076. static GetParser(name: string): Nullable<BabylonFileParser>;
  35077. /**
  35078. * Adds n individual parser in the list of available ones
  35079. * @param name Defines the name of the parser
  35080. * @param parser Defines the parser to add
  35081. */
  35082. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35083. /**
  35084. * Gets an individual parser from the list of avaialble ones
  35085. * @param name Defines the name of the parser
  35086. * @returns the requested parser or null
  35087. */
  35088. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35089. /**
  35090. * Parser json data and populate both a scene and its associated container object
  35091. * @param jsonData Defines the data to parse
  35092. * @param scene Defines the scene to parse the data for
  35093. * @param container Defines the container attached to the parsing sequence
  35094. * @param rootUrl Defines the root url of the data
  35095. */
  35096. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35097. /**
  35098. * Gets the list of root nodes (ie. nodes with no parent)
  35099. */
  35100. rootNodes: Node[];
  35101. /** All of the cameras added to this scene
  35102. * @see http://doc.babylonjs.com/babylon101/cameras
  35103. */
  35104. cameras: Camera[];
  35105. /**
  35106. * All of the lights added to this scene
  35107. * @see http://doc.babylonjs.com/babylon101/lights
  35108. */
  35109. lights: Light[];
  35110. /**
  35111. * All of the (abstract) meshes added to this scene
  35112. */
  35113. meshes: AbstractMesh[];
  35114. /**
  35115. * The list of skeletons added to the scene
  35116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35117. */
  35118. skeletons: Skeleton[];
  35119. /**
  35120. * All of the particle systems added to this scene
  35121. * @see http://doc.babylonjs.com/babylon101/particles
  35122. */
  35123. particleSystems: IParticleSystem[];
  35124. /**
  35125. * Gets a list of Animations associated with the scene
  35126. */
  35127. animations: Animation[];
  35128. /**
  35129. * All of the animation groups added to this scene
  35130. * @see http://doc.babylonjs.com/how_to/group
  35131. */
  35132. animationGroups: AnimationGroup[];
  35133. /**
  35134. * All of the multi-materials added to this scene
  35135. * @see http://doc.babylonjs.com/how_to/multi_materials
  35136. */
  35137. multiMaterials: MultiMaterial[];
  35138. /**
  35139. * All of the materials added to this scene
  35140. * In the context of a Scene, it is not supposed to be modified manually.
  35141. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35142. * Note also that the order of the Material wihin the array is not significant and might change.
  35143. * @see http://doc.babylonjs.com/babylon101/materials
  35144. */
  35145. materials: Material[];
  35146. /**
  35147. * The list of morph target managers added to the scene
  35148. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35149. */
  35150. morphTargetManagers: MorphTargetManager[];
  35151. /**
  35152. * The list of geometries used in the scene.
  35153. */
  35154. geometries: Geometry[];
  35155. /**
  35156. * All of the tranform nodes added to this scene
  35157. * In the context of a Scene, it is not supposed to be modified manually.
  35158. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35159. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35160. * @see http://doc.babylonjs.com/how_to/transformnode
  35161. */
  35162. transformNodes: TransformNode[];
  35163. /**
  35164. * ActionManagers available on the scene.
  35165. */
  35166. actionManagers: AbstractActionManager[];
  35167. /**
  35168. * Textures to keep.
  35169. */
  35170. textures: BaseTexture[];
  35171. /**
  35172. * Environment texture for the scene
  35173. */
  35174. environmentTexture: Nullable<BaseTexture>;
  35175. }
  35176. }
  35177. declare module "babylonjs/Audio/sound" {
  35178. import { Observable } from "babylonjs/Misc/observable";
  35179. import { Vector3 } from "babylonjs/Maths/math";
  35180. import { Nullable } from "babylonjs/types";
  35181. import { Scene } from "babylonjs/scene";
  35182. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35183. /**
  35184. * Interface used to define options for Sound class
  35185. */
  35186. export interface ISoundOptions {
  35187. /**
  35188. * Does the sound autoplay once loaded.
  35189. */
  35190. autoplay?: boolean;
  35191. /**
  35192. * Does the sound loop after it finishes playing once.
  35193. */
  35194. loop?: boolean;
  35195. /**
  35196. * Sound's volume
  35197. */
  35198. volume?: number;
  35199. /**
  35200. * Is it a spatial sound?
  35201. */
  35202. spatialSound?: boolean;
  35203. /**
  35204. * Maximum distance to hear that sound
  35205. */
  35206. maxDistance?: number;
  35207. /**
  35208. * Uses user defined attenuation function
  35209. */
  35210. useCustomAttenuation?: boolean;
  35211. /**
  35212. * Define the roll off factor of spatial sounds.
  35213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35214. */
  35215. rolloffFactor?: number;
  35216. /**
  35217. * Define the reference distance the sound should be heard perfectly.
  35218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35219. */
  35220. refDistance?: number;
  35221. /**
  35222. * Define the distance attenuation model the sound will follow.
  35223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35224. */
  35225. distanceModel?: string;
  35226. /**
  35227. * Defines the playback speed (1 by default)
  35228. */
  35229. playbackRate?: number;
  35230. /**
  35231. * Defines if the sound is from a streaming source
  35232. */
  35233. streaming?: boolean;
  35234. /**
  35235. * Defines an optional length (in seconds) inside the sound file
  35236. */
  35237. length?: number;
  35238. /**
  35239. * Defines an optional offset (in seconds) inside the sound file
  35240. */
  35241. offset?: number;
  35242. /**
  35243. * If true, URLs will not be required to state the audio file codec to use.
  35244. */
  35245. skipCodecCheck?: boolean;
  35246. }
  35247. /**
  35248. * Defines a sound that can be played in the application.
  35249. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35251. */
  35252. export class Sound {
  35253. /**
  35254. * The name of the sound in the scene.
  35255. */
  35256. name: string;
  35257. /**
  35258. * Does the sound autoplay once loaded.
  35259. */
  35260. autoplay: boolean;
  35261. /**
  35262. * Does the sound loop after it finishes playing once.
  35263. */
  35264. loop: boolean;
  35265. /**
  35266. * Does the sound use a custom attenuation curve to simulate the falloff
  35267. * happening when the source gets further away from the camera.
  35268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35269. */
  35270. useCustomAttenuation: boolean;
  35271. /**
  35272. * The sound track id this sound belongs to.
  35273. */
  35274. soundTrackId: number;
  35275. /**
  35276. * Is this sound currently played.
  35277. */
  35278. isPlaying: boolean;
  35279. /**
  35280. * Is this sound currently paused.
  35281. */
  35282. isPaused: boolean;
  35283. /**
  35284. * Does this sound enables spatial sound.
  35285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35286. */
  35287. spatialSound: boolean;
  35288. /**
  35289. * Define the reference distance the sound should be heard perfectly.
  35290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35291. */
  35292. refDistance: number;
  35293. /**
  35294. * Define the roll off factor of spatial sounds.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. rolloffFactor: number;
  35298. /**
  35299. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35301. */
  35302. maxDistance: number;
  35303. /**
  35304. * Define the distance attenuation model the sound will follow.
  35305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35306. */
  35307. distanceModel: string;
  35308. /**
  35309. * @hidden
  35310. * Back Compat
  35311. **/
  35312. onended: () => any;
  35313. /**
  35314. * Observable event when the current playing sound finishes.
  35315. */
  35316. onEndedObservable: Observable<Sound>;
  35317. private _panningModel;
  35318. private _playbackRate;
  35319. private _streaming;
  35320. private _startTime;
  35321. private _startOffset;
  35322. private _position;
  35323. /** @hidden */
  35324. _positionInEmitterSpace: boolean;
  35325. private _localDirection;
  35326. private _volume;
  35327. private _isReadyToPlay;
  35328. private _isDirectional;
  35329. private _readyToPlayCallback;
  35330. private _audioBuffer;
  35331. private _soundSource;
  35332. private _streamingSource;
  35333. private _soundPanner;
  35334. private _soundGain;
  35335. private _inputAudioNode;
  35336. private _outputAudioNode;
  35337. private _coneInnerAngle;
  35338. private _coneOuterAngle;
  35339. private _coneOuterGain;
  35340. private _scene;
  35341. private _connectedTransformNode;
  35342. private _customAttenuationFunction;
  35343. private _registerFunc;
  35344. private _isOutputConnected;
  35345. private _htmlAudioElement;
  35346. private _urlType;
  35347. private _length?;
  35348. private _offset?;
  35349. /** @hidden */
  35350. static _SceneComponentInitialization: (scene: Scene) => void;
  35351. /**
  35352. * Create a sound and attach it to a scene
  35353. * @param name Name of your sound
  35354. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35355. * @param scene defines the scene the sound belongs to
  35356. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35357. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35358. */
  35359. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35360. /**
  35361. * Release the sound and its associated resources
  35362. */
  35363. dispose(): void;
  35364. /**
  35365. * Gets if the sounds is ready to be played or not.
  35366. * @returns true if ready, otherwise false
  35367. */
  35368. isReady(): boolean;
  35369. private _soundLoaded;
  35370. /**
  35371. * Sets the data of the sound from an audiobuffer
  35372. * @param audioBuffer The audioBuffer containing the data
  35373. */
  35374. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35375. /**
  35376. * Updates the current sounds options such as maxdistance, loop...
  35377. * @param options A JSON object containing values named as the object properties
  35378. */
  35379. updateOptions(options: ISoundOptions): void;
  35380. private _createSpatialParameters;
  35381. private _updateSpatialParameters;
  35382. /**
  35383. * Switch the panning model to HRTF:
  35384. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35386. */
  35387. switchPanningModelToHRTF(): void;
  35388. /**
  35389. * Switch the panning model to Equal Power:
  35390. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35392. */
  35393. switchPanningModelToEqualPower(): void;
  35394. private _switchPanningModel;
  35395. /**
  35396. * Connect this sound to a sound track audio node like gain...
  35397. * @param soundTrackAudioNode the sound track audio node to connect to
  35398. */
  35399. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35400. /**
  35401. * Transform this sound into a directional source
  35402. * @param coneInnerAngle Size of the inner cone in degree
  35403. * @param coneOuterAngle Size of the outer cone in degree
  35404. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35405. */
  35406. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35407. /**
  35408. * Gets or sets the inner angle for the directional cone.
  35409. */
  35410. /**
  35411. * Gets or sets the inner angle for the directional cone.
  35412. */
  35413. directionalConeInnerAngle: number;
  35414. /**
  35415. * Gets or sets the outer angle for the directional cone.
  35416. */
  35417. /**
  35418. * Gets or sets the outer angle for the directional cone.
  35419. */
  35420. directionalConeOuterAngle: number;
  35421. /**
  35422. * Sets the position of the emitter if spatial sound is enabled
  35423. * @param newPosition Defines the new posisiton
  35424. */
  35425. setPosition(newPosition: Vector3): void;
  35426. /**
  35427. * Sets the local direction of the emitter if spatial sound is enabled
  35428. * @param newLocalDirection Defines the new local direction
  35429. */
  35430. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35431. private _updateDirection;
  35432. /** @hidden */
  35433. updateDistanceFromListener(): void;
  35434. /**
  35435. * Sets a new custom attenuation function for the sound.
  35436. * @param callback Defines the function used for the attenuation
  35437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35438. */
  35439. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35440. /**
  35441. * Play the sound
  35442. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35443. * @param offset (optional) Start the sound at a specific time in seconds
  35444. * @param length (optional) Sound duration (in seconds)
  35445. */
  35446. play(time?: number, offset?: number, length?: number): void;
  35447. private _onended;
  35448. /**
  35449. * Stop the sound
  35450. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35451. */
  35452. stop(time?: number): void;
  35453. /**
  35454. * Put the sound in pause
  35455. */
  35456. pause(): void;
  35457. /**
  35458. * Sets a dedicated volume for this sounds
  35459. * @param newVolume Define the new volume of the sound
  35460. * @param time Define time for gradual change to new volume
  35461. */
  35462. setVolume(newVolume: number, time?: number): void;
  35463. /**
  35464. * Set the sound play back rate
  35465. * @param newPlaybackRate Define the playback rate the sound should be played at
  35466. */
  35467. setPlaybackRate(newPlaybackRate: number): void;
  35468. /**
  35469. * Gets the volume of the sound.
  35470. * @returns the volume of the sound
  35471. */
  35472. getVolume(): number;
  35473. /**
  35474. * Attach the sound to a dedicated mesh
  35475. * @param transformNode The transform node to connect the sound with
  35476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35477. */
  35478. attachToMesh(transformNode: TransformNode): void;
  35479. /**
  35480. * Detach the sound from the previously attached mesh
  35481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35482. */
  35483. detachFromMesh(): void;
  35484. private _onRegisterAfterWorldMatrixUpdate;
  35485. /**
  35486. * Clone the current sound in the scene.
  35487. * @returns the new sound clone
  35488. */
  35489. clone(): Nullable<Sound>;
  35490. /**
  35491. * Gets the current underlying audio buffer containing the data
  35492. * @returns the audio buffer
  35493. */
  35494. getAudioBuffer(): Nullable<AudioBuffer>;
  35495. /**
  35496. * Serializes the Sound in a JSON representation
  35497. * @returns the JSON representation of the sound
  35498. */
  35499. serialize(): any;
  35500. /**
  35501. * Parse a JSON representation of a sound to innstantiate in a given scene
  35502. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35503. * @param scene Define the scene the new parsed sound should be created in
  35504. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35505. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35506. * @returns the newly parsed sound
  35507. */
  35508. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35509. }
  35510. }
  35511. declare module "babylonjs/Actions/directAudioActions" {
  35512. import { Action } from "babylonjs/Actions/action";
  35513. import { Condition } from "babylonjs/Actions/condition";
  35514. import { Sound } from "babylonjs/Audio/sound";
  35515. /**
  35516. * This defines an action helpful to play a defined sound on a triggered action.
  35517. */
  35518. export class PlaySoundAction extends Action {
  35519. private _sound;
  35520. /**
  35521. * Instantiate the action
  35522. * @param triggerOptions defines the trigger options
  35523. * @param sound defines the sound to play
  35524. * @param condition defines the trigger related conditions
  35525. */
  35526. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35527. /** @hidden */
  35528. _prepare(): void;
  35529. /**
  35530. * Execute the action and play the sound.
  35531. */
  35532. execute(): void;
  35533. /**
  35534. * Serializes the actions and its related information.
  35535. * @param parent defines the object to serialize in
  35536. * @returns the serialized object
  35537. */
  35538. serialize(parent: any): any;
  35539. }
  35540. /**
  35541. * This defines an action helpful to stop a defined sound on a triggered action.
  35542. */
  35543. export class StopSoundAction extends Action {
  35544. private _sound;
  35545. /**
  35546. * Instantiate the action
  35547. * @param triggerOptions defines the trigger options
  35548. * @param sound defines the sound to stop
  35549. * @param condition defines the trigger related conditions
  35550. */
  35551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35552. /** @hidden */
  35553. _prepare(): void;
  35554. /**
  35555. * Execute the action and stop the sound.
  35556. */
  35557. execute(): void;
  35558. /**
  35559. * Serializes the actions and its related information.
  35560. * @param parent defines the object to serialize in
  35561. * @returns the serialized object
  35562. */
  35563. serialize(parent: any): any;
  35564. }
  35565. }
  35566. declare module "babylonjs/Actions/interpolateValueAction" {
  35567. import { Action } from "babylonjs/Actions/action";
  35568. import { Condition } from "babylonjs/Actions/condition";
  35569. import { Observable } from "babylonjs/Misc/observable";
  35570. /**
  35571. * This defines an action responsible to change the value of a property
  35572. * by interpolating between its current value and the newly set one once triggered.
  35573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35574. */
  35575. export class InterpolateValueAction extends Action {
  35576. /**
  35577. * Defines the path of the property where the value should be interpolated
  35578. */
  35579. propertyPath: string;
  35580. /**
  35581. * Defines the target value at the end of the interpolation.
  35582. */
  35583. value: any;
  35584. /**
  35585. * Defines the time it will take for the property to interpolate to the value.
  35586. */
  35587. duration: number;
  35588. /**
  35589. * Defines if the other scene animations should be stopped when the action has been triggered
  35590. */
  35591. stopOtherAnimations?: boolean;
  35592. /**
  35593. * Defines a callback raised once the interpolation animation has been done.
  35594. */
  35595. onInterpolationDone?: () => void;
  35596. /**
  35597. * Observable triggered once the interpolation animation has been done.
  35598. */
  35599. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35600. private _target;
  35601. private _effectiveTarget;
  35602. private _property;
  35603. /**
  35604. * Instantiate the action
  35605. * @param triggerOptions defines the trigger options
  35606. * @param target defines the object containing the value to interpolate
  35607. * @param propertyPath defines the path to the property in the target object
  35608. * @param value defines the target value at the end of the interpolation
  35609. * @param duration deines the time it will take for the property to interpolate to the value.
  35610. * @param condition defines the trigger related conditions
  35611. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35612. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35613. */
  35614. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35615. /** @hidden */
  35616. _prepare(): void;
  35617. /**
  35618. * Execute the action starts the value interpolation.
  35619. */
  35620. execute(): void;
  35621. /**
  35622. * Serializes the actions and its related information.
  35623. * @param parent defines the object to serialize in
  35624. * @returns the serialized object
  35625. */
  35626. serialize(parent: any): any;
  35627. }
  35628. }
  35629. declare module "babylonjs/Actions/index" {
  35630. export * from "babylonjs/Actions/action";
  35631. export * from "babylonjs/Actions/actionEvent";
  35632. export * from "babylonjs/Actions/actionManager";
  35633. export * from "babylonjs/Actions/condition";
  35634. export * from "babylonjs/Actions/directActions";
  35635. export * from "babylonjs/Actions/directAudioActions";
  35636. export * from "babylonjs/Actions/interpolateValueAction";
  35637. }
  35638. declare module "babylonjs/Animations/index" {
  35639. export * from "babylonjs/Animations/animatable";
  35640. export * from "babylonjs/Animations/animation";
  35641. export * from "babylonjs/Animations/animationGroup";
  35642. export * from "babylonjs/Animations/animationPropertiesOverride";
  35643. export * from "babylonjs/Animations/easing";
  35644. export * from "babylonjs/Animations/runtimeAnimation";
  35645. export * from "babylonjs/Animations/animationEvent";
  35646. export * from "babylonjs/Animations/animationGroup";
  35647. export * from "babylonjs/Animations/animationKey";
  35648. export * from "babylonjs/Animations/animationRange";
  35649. }
  35650. declare module "babylonjs/Audio/soundTrack" {
  35651. import { Sound } from "babylonjs/Audio/sound";
  35652. import { Analyser } from "babylonjs/Audio/analyser";
  35653. import { Scene } from "babylonjs/scene";
  35654. /**
  35655. * Options allowed during the creation of a sound track.
  35656. */
  35657. export interface ISoundTrackOptions {
  35658. /**
  35659. * The volume the sound track should take during creation
  35660. */
  35661. volume?: number;
  35662. /**
  35663. * Define if the sound track is the main sound track of the scene
  35664. */
  35665. mainTrack?: boolean;
  35666. }
  35667. /**
  35668. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35669. * It will be also used in a future release to apply effects on a specific track.
  35670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35671. */
  35672. export class SoundTrack {
  35673. /**
  35674. * The unique identifier of the sound track in the scene.
  35675. */
  35676. id: number;
  35677. /**
  35678. * The list of sounds included in the sound track.
  35679. */
  35680. soundCollection: Array<Sound>;
  35681. private _outputAudioNode;
  35682. private _scene;
  35683. private _isMainTrack;
  35684. private _connectedAnalyser;
  35685. private _options;
  35686. private _isInitialized;
  35687. /**
  35688. * Creates a new sound track.
  35689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35690. * @param scene Define the scene the sound track belongs to
  35691. * @param options
  35692. */
  35693. constructor(scene: Scene, options?: ISoundTrackOptions);
  35694. private _initializeSoundTrackAudioGraph;
  35695. /**
  35696. * Release the sound track and its associated resources
  35697. */
  35698. dispose(): void;
  35699. /**
  35700. * Adds a sound to this sound track
  35701. * @param sound define the cound to add
  35702. * @ignoreNaming
  35703. */
  35704. AddSound(sound: Sound): void;
  35705. /**
  35706. * Removes a sound to this sound track
  35707. * @param sound define the cound to remove
  35708. * @ignoreNaming
  35709. */
  35710. RemoveSound(sound: Sound): void;
  35711. /**
  35712. * Set a global volume for the full sound track.
  35713. * @param newVolume Define the new volume of the sound track
  35714. */
  35715. setVolume(newVolume: number): void;
  35716. /**
  35717. * Switch the panning model to HRTF:
  35718. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35720. */
  35721. switchPanningModelToHRTF(): void;
  35722. /**
  35723. * Switch the panning model to Equal Power:
  35724. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35726. */
  35727. switchPanningModelToEqualPower(): void;
  35728. /**
  35729. * Connect the sound track to an audio analyser allowing some amazing
  35730. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35732. * @param analyser The analyser to connect to the engine
  35733. */
  35734. connectToAnalyser(analyser: Analyser): void;
  35735. }
  35736. }
  35737. declare module "babylonjs/Audio/audioSceneComponent" {
  35738. import { Sound } from "babylonjs/Audio/sound";
  35739. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35740. import { Nullable } from "babylonjs/types";
  35741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35742. import { Scene } from "babylonjs/scene";
  35743. import { AbstractScene } from "babylonjs/abstractScene";
  35744. module "babylonjs/abstractScene" {
  35745. interface AbstractScene {
  35746. /**
  35747. * The list of sounds used in the scene.
  35748. */
  35749. sounds: Nullable<Array<Sound>>;
  35750. }
  35751. }
  35752. module "babylonjs/scene" {
  35753. interface Scene {
  35754. /**
  35755. * @hidden
  35756. * Backing field
  35757. */
  35758. _mainSoundTrack: SoundTrack;
  35759. /**
  35760. * The main sound track played by the scene.
  35761. * It cotains your primary collection of sounds.
  35762. */
  35763. mainSoundTrack: SoundTrack;
  35764. /**
  35765. * The list of sound tracks added to the scene
  35766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35767. */
  35768. soundTracks: Nullable<Array<SoundTrack>>;
  35769. /**
  35770. * Gets a sound using a given name
  35771. * @param name defines the name to search for
  35772. * @return the found sound or null if not found at all.
  35773. */
  35774. getSoundByName(name: string): Nullable<Sound>;
  35775. /**
  35776. * Gets or sets if audio support is enabled
  35777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35778. */
  35779. audioEnabled: boolean;
  35780. /**
  35781. * Gets or sets if audio will be output to headphones
  35782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35783. */
  35784. headphone: boolean;
  35785. }
  35786. }
  35787. /**
  35788. * Defines the sound scene component responsible to manage any sounds
  35789. * in a given scene.
  35790. */
  35791. export class AudioSceneComponent implements ISceneSerializableComponent {
  35792. /**
  35793. * The component name helpfull to identify the component in the list of scene components.
  35794. */
  35795. readonly name: string;
  35796. /**
  35797. * The scene the component belongs to.
  35798. */
  35799. scene: Scene;
  35800. private _audioEnabled;
  35801. /**
  35802. * Gets whether audio is enabled or not.
  35803. * Please use related enable/disable method to switch state.
  35804. */
  35805. readonly audioEnabled: boolean;
  35806. private _headphone;
  35807. /**
  35808. * Gets whether audio is outputing to headphone or not.
  35809. * Please use the according Switch methods to change output.
  35810. */
  35811. readonly headphone: boolean;
  35812. /**
  35813. * Creates a new instance of the component for the given scene
  35814. * @param scene Defines the scene to register the component in
  35815. */
  35816. constructor(scene: Scene);
  35817. /**
  35818. * Registers the component in a given scene
  35819. */
  35820. register(): void;
  35821. /**
  35822. * Rebuilds the elements related to this component in case of
  35823. * context lost for instance.
  35824. */
  35825. rebuild(): void;
  35826. /**
  35827. * Serializes the component data to the specified json object
  35828. * @param serializationObject The object to serialize to
  35829. */
  35830. serialize(serializationObject: any): void;
  35831. /**
  35832. * Adds all the elements from the container to the scene
  35833. * @param container the container holding the elements
  35834. */
  35835. addFromContainer(container: AbstractScene): void;
  35836. /**
  35837. * Removes all the elements in the container from the scene
  35838. * @param container contains the elements to remove
  35839. * @param dispose if the removed element should be disposed (default: false)
  35840. */
  35841. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35842. /**
  35843. * Disposes the component and the associated ressources.
  35844. */
  35845. dispose(): void;
  35846. /**
  35847. * Disables audio in the associated scene.
  35848. */
  35849. disableAudio(): void;
  35850. /**
  35851. * Enables audio in the associated scene.
  35852. */
  35853. enableAudio(): void;
  35854. /**
  35855. * Switch audio to headphone output.
  35856. */
  35857. switchAudioModeForHeadphones(): void;
  35858. /**
  35859. * Switch audio to normal speakers.
  35860. */
  35861. switchAudioModeForNormalSpeakers(): void;
  35862. private _afterRender;
  35863. }
  35864. }
  35865. declare module "babylonjs/Audio/weightedsound" {
  35866. import { Sound } from "babylonjs/Audio/sound";
  35867. /**
  35868. * Wraps one or more Sound objects and selects one with random weight for playback.
  35869. */
  35870. export class WeightedSound {
  35871. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35872. loop: boolean;
  35873. private _coneInnerAngle;
  35874. private _coneOuterAngle;
  35875. private _volume;
  35876. /** A Sound is currently playing. */
  35877. isPlaying: boolean;
  35878. /** A Sound is currently paused. */
  35879. isPaused: boolean;
  35880. private _sounds;
  35881. private _weights;
  35882. private _currentIndex?;
  35883. /**
  35884. * Creates a new WeightedSound from the list of sounds given.
  35885. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35886. * @param sounds Array of Sounds that will be selected from.
  35887. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35888. */
  35889. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35890. /**
  35891. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35892. */
  35893. /**
  35894. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35895. */
  35896. directionalConeInnerAngle: number;
  35897. /**
  35898. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35899. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35900. */
  35901. /**
  35902. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35903. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35904. */
  35905. directionalConeOuterAngle: number;
  35906. /**
  35907. * Playback volume.
  35908. */
  35909. /**
  35910. * Playback volume.
  35911. */
  35912. volume: number;
  35913. private _onended;
  35914. /**
  35915. * Suspend playback
  35916. */
  35917. pause(): void;
  35918. /**
  35919. * Stop playback
  35920. */
  35921. stop(): void;
  35922. /**
  35923. * Start playback.
  35924. * @param startOffset Position the clip head at a specific time in seconds.
  35925. */
  35926. play(startOffset?: number): void;
  35927. }
  35928. }
  35929. declare module "babylonjs/Audio/index" {
  35930. export * from "babylonjs/Audio/analyser";
  35931. export * from "babylonjs/Audio/audioEngine";
  35932. export * from "babylonjs/Audio/audioSceneComponent";
  35933. export * from "babylonjs/Audio/sound";
  35934. export * from "babylonjs/Audio/soundTrack";
  35935. export * from "babylonjs/Audio/weightedsound";
  35936. }
  35937. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35938. import { Behavior } from "babylonjs/Behaviors/behavior";
  35939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35940. import { BackEase } from "babylonjs/Animations/easing";
  35941. /**
  35942. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35943. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35944. */
  35945. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35946. /**
  35947. * Gets the name of the behavior.
  35948. */
  35949. readonly name: string;
  35950. /**
  35951. * The easing function used by animations
  35952. */
  35953. static EasingFunction: BackEase;
  35954. /**
  35955. * The easing mode used by animations
  35956. */
  35957. static EasingMode: number;
  35958. /**
  35959. * The duration of the animation, in milliseconds
  35960. */
  35961. transitionDuration: number;
  35962. /**
  35963. * Length of the distance animated by the transition when lower radius is reached
  35964. */
  35965. lowerRadiusTransitionRange: number;
  35966. /**
  35967. * Length of the distance animated by the transition when upper radius is reached
  35968. */
  35969. upperRadiusTransitionRange: number;
  35970. private _autoTransitionRange;
  35971. /**
  35972. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35973. */
  35974. /**
  35975. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35976. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35977. */
  35978. autoTransitionRange: boolean;
  35979. private _attachedCamera;
  35980. private _onAfterCheckInputsObserver;
  35981. private _onMeshTargetChangedObserver;
  35982. /**
  35983. * Initializes the behavior.
  35984. */
  35985. init(): void;
  35986. /**
  35987. * Attaches the behavior to its arc rotate camera.
  35988. * @param camera Defines the camera to attach the behavior to
  35989. */
  35990. attach(camera: ArcRotateCamera): void;
  35991. /**
  35992. * Detaches the behavior from its current arc rotate camera.
  35993. */
  35994. detach(): void;
  35995. private _radiusIsAnimating;
  35996. private _radiusBounceTransition;
  35997. private _animatables;
  35998. private _cachedWheelPrecision;
  35999. /**
  36000. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36001. * @param radiusLimit The limit to check against.
  36002. * @return Bool to indicate if at limit.
  36003. */
  36004. private _isRadiusAtLimit;
  36005. /**
  36006. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36007. * @param radiusDelta The delta by which to animate to. Can be negative.
  36008. */
  36009. private _applyBoundRadiusAnimation;
  36010. /**
  36011. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36012. */
  36013. protected _clearAnimationLocks(): void;
  36014. /**
  36015. * Stops and removes all animations that have been applied to the camera
  36016. */
  36017. stopAllAnimations(): void;
  36018. }
  36019. }
  36020. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36021. import { Behavior } from "babylonjs/Behaviors/behavior";
  36022. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36023. import { ExponentialEase } from "babylonjs/Animations/easing";
  36024. import { Nullable } from "babylonjs/types";
  36025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36026. import { Vector3 } from "babylonjs/Maths/math";
  36027. /**
  36028. * 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.
  36029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36030. */
  36031. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36032. /**
  36033. * Gets the name of the behavior.
  36034. */
  36035. readonly name: string;
  36036. private _mode;
  36037. private _radiusScale;
  36038. private _positionScale;
  36039. private _defaultElevation;
  36040. private _elevationReturnTime;
  36041. private _elevationReturnWaitTime;
  36042. private _zoomStopsAnimation;
  36043. private _framingTime;
  36044. /**
  36045. * The easing function used by animations
  36046. */
  36047. static EasingFunction: ExponentialEase;
  36048. /**
  36049. * The easing mode used by animations
  36050. */
  36051. static EasingMode: number;
  36052. /**
  36053. * Sets the current mode used by the behavior
  36054. */
  36055. /**
  36056. * Gets current mode used by the behavior.
  36057. */
  36058. mode: number;
  36059. /**
  36060. * Sets the scale applied to the radius (1 by default)
  36061. */
  36062. /**
  36063. * Gets the scale applied to the radius
  36064. */
  36065. radiusScale: number;
  36066. /**
  36067. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36068. */
  36069. /**
  36070. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36071. */
  36072. positionScale: number;
  36073. /**
  36074. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36075. * behaviour is triggered, in radians.
  36076. */
  36077. /**
  36078. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36079. * behaviour is triggered, in radians.
  36080. */
  36081. defaultElevation: number;
  36082. /**
  36083. * Sets the time (in milliseconds) taken to return to the default beta position.
  36084. * Negative value indicates camera should not return to default.
  36085. */
  36086. /**
  36087. * Gets the time (in milliseconds) taken to return to the default beta position.
  36088. * Negative value indicates camera should not return to default.
  36089. */
  36090. elevationReturnTime: number;
  36091. /**
  36092. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36093. */
  36094. /**
  36095. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36096. */
  36097. elevationReturnWaitTime: number;
  36098. /**
  36099. * Sets the flag that indicates if user zooming should stop animation.
  36100. */
  36101. /**
  36102. * Gets the flag that indicates if user zooming should stop animation.
  36103. */
  36104. zoomStopsAnimation: boolean;
  36105. /**
  36106. * Sets the transition time when framing the mesh, in milliseconds
  36107. */
  36108. /**
  36109. * Gets the transition time when framing the mesh, in milliseconds
  36110. */
  36111. framingTime: number;
  36112. /**
  36113. * Define if the behavior should automatically change the configured
  36114. * camera limits and sensibilities.
  36115. */
  36116. autoCorrectCameraLimitsAndSensibility: boolean;
  36117. private _onPrePointerObservableObserver;
  36118. private _onAfterCheckInputsObserver;
  36119. private _onMeshTargetChangedObserver;
  36120. private _attachedCamera;
  36121. private _isPointerDown;
  36122. private _lastInteractionTime;
  36123. /**
  36124. * Initializes the behavior.
  36125. */
  36126. init(): void;
  36127. /**
  36128. * Attaches the behavior to its arc rotate camera.
  36129. * @param camera Defines the camera to attach the behavior to
  36130. */
  36131. attach(camera: ArcRotateCamera): void;
  36132. /**
  36133. * Detaches the behavior from its current arc rotate camera.
  36134. */
  36135. detach(): void;
  36136. private _animatables;
  36137. private _betaIsAnimating;
  36138. private _betaTransition;
  36139. private _radiusTransition;
  36140. private _vectorTransition;
  36141. /**
  36142. * Targets the given mesh and updates zoom level accordingly.
  36143. * @param mesh The mesh to target.
  36144. * @param radius Optional. If a cached radius position already exists, overrides default.
  36145. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36146. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36147. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36148. */
  36149. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36150. /**
  36151. * Targets the given mesh with its children and updates zoom level accordingly.
  36152. * @param mesh The mesh to target.
  36153. * @param radius Optional. If a cached radius position already exists, overrides default.
  36154. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36155. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36156. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36157. */
  36158. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36159. /**
  36160. * Targets the given meshes with their children and updates zoom level accordingly.
  36161. * @param meshes The mesh to target.
  36162. * @param radius Optional. If a cached radius position already exists, overrides default.
  36163. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36164. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36165. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36166. */
  36167. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36168. /**
  36169. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36170. * @param minimumWorld Determines the smaller position of the bounding box extend
  36171. * @param maximumWorld Determines the bigger position of the bounding box extend
  36172. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36173. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36174. */
  36175. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36176. /**
  36177. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36178. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36179. * frustum width.
  36180. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36181. * to fully enclose the mesh in the viewing frustum.
  36182. */
  36183. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36184. /**
  36185. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36186. * is automatically returned to its default position (expected to be above ground plane).
  36187. */
  36188. private _maintainCameraAboveGround;
  36189. /**
  36190. * Returns the frustum slope based on the canvas ratio and camera FOV
  36191. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36192. */
  36193. private _getFrustumSlope;
  36194. /**
  36195. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36196. */
  36197. private _clearAnimationLocks;
  36198. /**
  36199. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36200. */
  36201. private _applyUserInteraction;
  36202. /**
  36203. * Stops and removes all animations that have been applied to the camera
  36204. */
  36205. stopAllAnimations(): void;
  36206. /**
  36207. * Gets a value indicating if the user is moving the camera
  36208. */
  36209. readonly isUserIsMoving: boolean;
  36210. /**
  36211. * The camera can move all the way towards the mesh.
  36212. */
  36213. static IgnoreBoundsSizeMode: number;
  36214. /**
  36215. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36216. */
  36217. static FitFrustumSidesMode: number;
  36218. }
  36219. }
  36220. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36221. import { Nullable } from "babylonjs/types";
  36222. import { Camera } from "babylonjs/Cameras/camera";
  36223. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36224. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36225. /**
  36226. * Base class for Camera Pointer Inputs.
  36227. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36228. * for example usage.
  36229. */
  36230. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36231. /**
  36232. * Defines the camera the input is attached to.
  36233. */
  36234. abstract camera: Camera;
  36235. /**
  36236. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36237. */
  36238. protected _altKey: boolean;
  36239. protected _ctrlKey: boolean;
  36240. protected _metaKey: boolean;
  36241. protected _shiftKey: boolean;
  36242. /**
  36243. * Which mouse buttons were pressed at time of last mouse event.
  36244. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36245. */
  36246. protected _buttonsPressed: number;
  36247. /**
  36248. * Defines the buttons associated with the input to handle camera move.
  36249. */
  36250. buttons: number[];
  36251. /**
  36252. * Attach the input controls to a specific dom element to get the input from.
  36253. * @param element Defines the element the controls should be listened from
  36254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36255. */
  36256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36257. /**
  36258. * Detach the current controls from the specified dom element.
  36259. * @param element Defines the element to stop listening the inputs from
  36260. */
  36261. detachControl(element: Nullable<HTMLElement>): void;
  36262. /**
  36263. * Gets the class name of the current input.
  36264. * @returns the class name
  36265. */
  36266. getClassName(): string;
  36267. /**
  36268. * Get the friendly name associated with the input class.
  36269. * @returns the input friendly name
  36270. */
  36271. getSimpleName(): string;
  36272. /**
  36273. * Called on pointer POINTERDOUBLETAP event.
  36274. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36275. */
  36276. protected onDoubleTap(type: string): void;
  36277. /**
  36278. * Called on pointer POINTERMOVE event if only a single touch is active.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36282. /**
  36283. * Called on pointer POINTERMOVE event if multiple touches are active.
  36284. * Override this method to provide functionality.
  36285. */
  36286. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36287. /**
  36288. * Called on JS contextmenu event.
  36289. * Override this method to provide functionality.
  36290. */
  36291. protected onContextMenu(evt: PointerEvent): void;
  36292. /**
  36293. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36294. * press.
  36295. * Override this method to provide functionality.
  36296. */
  36297. protected onButtonDown(evt: PointerEvent): void;
  36298. /**
  36299. * Called each time a new POINTERUP event occurs. Ie, for each button
  36300. * release.
  36301. * Override this method to provide functionality.
  36302. */
  36303. protected onButtonUp(evt: PointerEvent): void;
  36304. /**
  36305. * Called when window becomes inactive.
  36306. * Override this method to provide functionality.
  36307. */
  36308. protected onLostFocus(): void;
  36309. private _pointerInput;
  36310. private _observer;
  36311. private _onLostFocus;
  36312. private pointA;
  36313. private pointB;
  36314. }
  36315. }
  36316. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36317. import { Nullable } from "babylonjs/types";
  36318. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36319. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36320. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36321. /**
  36322. * Manage the pointers inputs to control an arc rotate camera.
  36323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36324. */
  36325. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36326. /**
  36327. * Defines the camera the input is attached to.
  36328. */
  36329. camera: ArcRotateCamera;
  36330. /**
  36331. * Gets the class name of the current input.
  36332. * @returns the class name
  36333. */
  36334. getClassName(): string;
  36335. /**
  36336. * Defines the buttons associated with the input to handle camera move.
  36337. */
  36338. buttons: number[];
  36339. /**
  36340. * Defines the pointer angular sensibility along the X axis or how fast is
  36341. * the camera rotating.
  36342. */
  36343. angularSensibilityX: number;
  36344. /**
  36345. * Defines the pointer angular sensibility along the Y axis or how fast is
  36346. * the camera rotating.
  36347. */
  36348. angularSensibilityY: number;
  36349. /**
  36350. * Defines the pointer pinch precision or how fast is the camera zooming.
  36351. */
  36352. pinchPrecision: number;
  36353. /**
  36354. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36355. * from 0.
  36356. * It defines the percentage of current camera.radius to use as delta when
  36357. * pinch zoom is used.
  36358. */
  36359. pinchDeltaPercentage: number;
  36360. /**
  36361. * Defines the pointer panning sensibility or how fast is the camera moving.
  36362. */
  36363. panningSensibility: number;
  36364. /**
  36365. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36366. */
  36367. multiTouchPanning: boolean;
  36368. /**
  36369. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36370. * zoom (pinch) through multitouch.
  36371. */
  36372. multiTouchPanAndZoom: boolean;
  36373. /**
  36374. * Revers pinch action direction.
  36375. */
  36376. pinchInwards: boolean;
  36377. private _isPanClick;
  36378. private _twoFingerActivityCount;
  36379. private _isPinching;
  36380. /**
  36381. * Called on pointer POINTERMOVE event if only a single touch is active.
  36382. */
  36383. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36384. /**
  36385. * Called on pointer POINTERDOUBLETAP event.
  36386. */
  36387. protected onDoubleTap(type: string): void;
  36388. /**
  36389. * Called on pointer POINTERMOVE event if multiple touches are active.
  36390. */
  36391. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36392. /**
  36393. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36394. * press.
  36395. */
  36396. protected onButtonDown(evt: PointerEvent): void;
  36397. /**
  36398. * Called each time a new POINTERUP event occurs. Ie, for each button
  36399. * release.
  36400. */
  36401. protected onButtonUp(evt: PointerEvent): void;
  36402. /**
  36403. * Called when window becomes inactive.
  36404. */
  36405. protected onLostFocus(): void;
  36406. }
  36407. }
  36408. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36409. import { Nullable } from "babylonjs/types";
  36410. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36412. /**
  36413. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36415. */
  36416. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36417. /**
  36418. * Defines the camera the input is attached to.
  36419. */
  36420. camera: ArcRotateCamera;
  36421. /**
  36422. * Defines the list of key codes associated with the up action (increase alpha)
  36423. */
  36424. keysUp: number[];
  36425. /**
  36426. * Defines the list of key codes associated with the down action (decrease alpha)
  36427. */
  36428. keysDown: number[];
  36429. /**
  36430. * Defines the list of key codes associated with the left action (increase beta)
  36431. */
  36432. keysLeft: number[];
  36433. /**
  36434. * Defines the list of key codes associated with the right action (decrease beta)
  36435. */
  36436. keysRight: number[];
  36437. /**
  36438. * Defines the list of key codes associated with the reset action.
  36439. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36440. */
  36441. keysReset: number[];
  36442. /**
  36443. * Defines the panning sensibility of the inputs.
  36444. * (How fast is the camera paning)
  36445. */
  36446. panningSensibility: number;
  36447. /**
  36448. * Defines the zooming sensibility of the inputs.
  36449. * (How fast is the camera zooming)
  36450. */
  36451. zoomingSensibility: number;
  36452. /**
  36453. * Defines wether maintaining the alt key down switch the movement mode from
  36454. * orientation to zoom.
  36455. */
  36456. useAltToZoom: boolean;
  36457. /**
  36458. * Rotation speed of the camera
  36459. */
  36460. angularSpeed: number;
  36461. private _keys;
  36462. private _ctrlPressed;
  36463. private _altPressed;
  36464. private _onCanvasBlurObserver;
  36465. private _onKeyboardObserver;
  36466. private _engine;
  36467. private _scene;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Update the current camera state depending on the inputs that have been used this frame.
  36481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36482. */
  36483. checkInputs(): void;
  36484. /**
  36485. * Gets the class name of the current intput.
  36486. * @returns the class name
  36487. */
  36488. getClassName(): string;
  36489. /**
  36490. * Get the friendly name associated with the input class.
  36491. * @returns the input friendly name
  36492. */
  36493. getSimpleName(): string;
  36494. }
  36495. }
  36496. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36497. import { Nullable } from "babylonjs/types";
  36498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36500. /**
  36501. * Manage the mouse wheel inputs to control an arc rotate camera.
  36502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36503. */
  36504. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36505. /**
  36506. * Defines the camera the input is attached to.
  36507. */
  36508. camera: ArcRotateCamera;
  36509. /**
  36510. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36511. */
  36512. wheelPrecision: number;
  36513. /**
  36514. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36515. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36516. */
  36517. wheelDeltaPercentage: number;
  36518. private _wheel;
  36519. private _observer;
  36520. private computeDeltaFromMouseWheelLegacyEvent;
  36521. /**
  36522. * Attach the input controls to a specific dom element to get the input from.
  36523. * @param element Defines the element the controls should be listened from
  36524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36525. */
  36526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36527. /**
  36528. * Detach the current controls from the specified dom element.
  36529. * @param element Defines the element to stop listening the inputs from
  36530. */
  36531. detachControl(element: Nullable<HTMLElement>): void;
  36532. /**
  36533. * Gets the class name of the current intput.
  36534. * @returns the class name
  36535. */
  36536. getClassName(): string;
  36537. /**
  36538. * Get the friendly name associated with the input class.
  36539. * @returns the input friendly name
  36540. */
  36541. getSimpleName(): string;
  36542. }
  36543. }
  36544. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36547. /**
  36548. * Default Inputs manager for the ArcRotateCamera.
  36549. * It groups all the default supported inputs for ease of use.
  36550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36551. */
  36552. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36553. /**
  36554. * Instantiates a new ArcRotateCameraInputsManager.
  36555. * @param camera Defines the camera the inputs belong to
  36556. */
  36557. constructor(camera: ArcRotateCamera);
  36558. /**
  36559. * Add mouse wheel input support to the input manager.
  36560. * @returns the current input manager
  36561. */
  36562. addMouseWheel(): ArcRotateCameraInputsManager;
  36563. /**
  36564. * Add pointers input support to the input manager.
  36565. * @returns the current input manager
  36566. */
  36567. addPointers(): ArcRotateCameraInputsManager;
  36568. /**
  36569. * Add keyboard input support to the input manager.
  36570. * @returns the current input manager
  36571. */
  36572. addKeyboard(): ArcRotateCameraInputsManager;
  36573. }
  36574. }
  36575. declare module "babylonjs/Cameras/arcRotateCamera" {
  36576. import { Observable } from "babylonjs/Misc/observable";
  36577. import { Nullable } from "babylonjs/types";
  36578. import { Scene } from "babylonjs/scene";
  36579. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36581. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36582. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36583. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36584. import { Camera } from "babylonjs/Cameras/camera";
  36585. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36586. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36587. import { Collider } from "babylonjs/Collisions/collider";
  36588. /**
  36589. * This represents an orbital type of camera.
  36590. *
  36591. * 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.
  36592. * 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.
  36593. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36594. */
  36595. export class ArcRotateCamera extends TargetCamera {
  36596. /**
  36597. * Defines the rotation angle of the camera along the longitudinal axis.
  36598. */
  36599. alpha: number;
  36600. /**
  36601. * Defines the rotation angle of the camera along the latitudinal axis.
  36602. */
  36603. beta: number;
  36604. /**
  36605. * Defines the radius of the camera from it s target point.
  36606. */
  36607. radius: number;
  36608. protected _target: Vector3;
  36609. protected _targetHost: Nullable<AbstractMesh>;
  36610. /**
  36611. * Defines the target point of the camera.
  36612. * The camera looks towards it form the radius distance.
  36613. */
  36614. target: Vector3;
  36615. /**
  36616. * Define the current local position of the camera in the scene
  36617. */
  36618. position: Vector3;
  36619. protected _upVector: Vector3;
  36620. protected _upToYMatrix: Matrix;
  36621. protected _YToUpMatrix: Matrix;
  36622. /**
  36623. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36624. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36625. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36626. */
  36627. upVector: Vector3;
  36628. /**
  36629. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36630. */
  36631. setMatUp(): void;
  36632. /**
  36633. * Current inertia value on the longitudinal axis.
  36634. * The bigger this number the longer it will take for the camera to stop.
  36635. */
  36636. inertialAlphaOffset: number;
  36637. /**
  36638. * Current inertia value on the latitudinal axis.
  36639. * The bigger this number the longer it will take for the camera to stop.
  36640. */
  36641. inertialBetaOffset: number;
  36642. /**
  36643. * Current inertia value on the radius axis.
  36644. * The bigger this number the longer it will take for the camera to stop.
  36645. */
  36646. inertialRadiusOffset: number;
  36647. /**
  36648. * Minimum allowed angle on the longitudinal axis.
  36649. * This can help limiting how the Camera is able to move in the scene.
  36650. */
  36651. lowerAlphaLimit: Nullable<number>;
  36652. /**
  36653. * Maximum allowed angle on the longitudinal axis.
  36654. * This can help limiting how the Camera is able to move in the scene.
  36655. */
  36656. upperAlphaLimit: Nullable<number>;
  36657. /**
  36658. * Minimum allowed angle on the latitudinal axis.
  36659. * This can help limiting how the Camera is able to move in the scene.
  36660. */
  36661. lowerBetaLimit: number;
  36662. /**
  36663. * Maximum allowed angle on the latitudinal axis.
  36664. * This can help limiting how the Camera is able to move in the scene.
  36665. */
  36666. upperBetaLimit: number;
  36667. /**
  36668. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36669. * This can help limiting how the Camera is able to move in the scene.
  36670. */
  36671. lowerRadiusLimit: Nullable<number>;
  36672. /**
  36673. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36674. * This can help limiting how the Camera is able to move in the scene.
  36675. */
  36676. upperRadiusLimit: Nullable<number>;
  36677. /**
  36678. * Defines the current inertia value used during panning of the camera along the X axis.
  36679. */
  36680. inertialPanningX: number;
  36681. /**
  36682. * Defines the current inertia value used during panning of the camera along the Y axis.
  36683. */
  36684. inertialPanningY: number;
  36685. /**
  36686. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36687. * Basically if your fingers moves away from more than this distance you will be considered
  36688. * in pinch mode.
  36689. */
  36690. pinchToPanMaxDistance: number;
  36691. /**
  36692. * Defines the maximum distance the camera can pan.
  36693. * This could help keeping the cammera always in your scene.
  36694. */
  36695. panningDistanceLimit: Nullable<number>;
  36696. /**
  36697. * Defines the target of the camera before paning.
  36698. */
  36699. panningOriginTarget: Vector3;
  36700. /**
  36701. * Defines the value of the inertia used during panning.
  36702. * 0 would mean stop inertia and one would mean no decelleration at all.
  36703. */
  36704. panningInertia: number;
  36705. /**
  36706. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36707. */
  36708. angularSensibilityX: number;
  36709. /**
  36710. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36711. */
  36712. angularSensibilityY: number;
  36713. /**
  36714. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36715. */
  36716. pinchPrecision: number;
  36717. /**
  36718. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36719. * It will be used instead of pinchDeltaPrecision if different from 0.
  36720. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36721. */
  36722. pinchDeltaPercentage: number;
  36723. /**
  36724. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36725. */
  36726. panningSensibility: number;
  36727. /**
  36728. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36729. */
  36730. keysUp: number[];
  36731. /**
  36732. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36733. */
  36734. keysDown: number[];
  36735. /**
  36736. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36737. */
  36738. keysLeft: number[];
  36739. /**
  36740. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36741. */
  36742. keysRight: number[];
  36743. /**
  36744. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36745. */
  36746. wheelPrecision: number;
  36747. /**
  36748. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36749. * It will be used instead of pinchDeltaPrecision if different from 0.
  36750. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36751. */
  36752. wheelDeltaPercentage: number;
  36753. /**
  36754. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36755. */
  36756. zoomOnFactor: number;
  36757. /**
  36758. * Defines a screen offset for the camera position.
  36759. */
  36760. targetScreenOffset: Vector2;
  36761. /**
  36762. * Allows the camera to be completely reversed.
  36763. * If false the camera can not arrive upside down.
  36764. */
  36765. allowUpsideDown: boolean;
  36766. /**
  36767. * Define if double tap/click is used to restore the previously saved state of the camera.
  36768. */
  36769. useInputToRestoreState: boolean;
  36770. /** @hidden */
  36771. _viewMatrix: Matrix;
  36772. /** @hidden */
  36773. _useCtrlForPanning: boolean;
  36774. /** @hidden */
  36775. _panningMouseButton: number;
  36776. /**
  36777. * Defines the input associated to the camera.
  36778. */
  36779. inputs: ArcRotateCameraInputsManager;
  36780. /** @hidden */
  36781. _reset: () => void;
  36782. /**
  36783. * Defines the allowed panning axis.
  36784. */
  36785. panningAxis: Vector3;
  36786. protected _localDirection: Vector3;
  36787. protected _transformedDirection: Vector3;
  36788. private _bouncingBehavior;
  36789. /**
  36790. * Gets the bouncing behavior of the camera if it has been enabled.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36792. */
  36793. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36794. /**
  36795. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36797. */
  36798. useBouncingBehavior: boolean;
  36799. private _framingBehavior;
  36800. /**
  36801. * Gets the framing behavior of the camera if it has been enabled.
  36802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36803. */
  36804. readonly framingBehavior: Nullable<FramingBehavior>;
  36805. /**
  36806. * Defines if the framing behavior of the camera is enabled on the camera.
  36807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36808. */
  36809. useFramingBehavior: boolean;
  36810. private _autoRotationBehavior;
  36811. /**
  36812. * Gets the auto rotation behavior of the camera if it has been enabled.
  36813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36814. */
  36815. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36816. /**
  36817. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36819. */
  36820. useAutoRotationBehavior: boolean;
  36821. /**
  36822. * Observable triggered when the mesh target has been changed on the camera.
  36823. */
  36824. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36825. /**
  36826. * Event raised when the camera is colliding with a mesh.
  36827. */
  36828. onCollide: (collidedMesh: AbstractMesh) => void;
  36829. /**
  36830. * Defines whether the camera should check collision with the objects oh the scene.
  36831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36832. */
  36833. checkCollisions: boolean;
  36834. /**
  36835. * Defines the collision radius of the camera.
  36836. * This simulates a sphere around the camera.
  36837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36838. */
  36839. collisionRadius: Vector3;
  36840. protected _collider: Collider;
  36841. protected _previousPosition: Vector3;
  36842. protected _collisionVelocity: Vector3;
  36843. protected _newPosition: Vector3;
  36844. protected _previousAlpha: number;
  36845. protected _previousBeta: number;
  36846. protected _previousRadius: number;
  36847. protected _collisionTriggered: boolean;
  36848. protected _targetBoundingCenter: Nullable<Vector3>;
  36849. private _computationVector;
  36850. /**
  36851. * Instantiates a new ArcRotateCamera in a given scene
  36852. * @param name Defines the name of the camera
  36853. * @param alpha Defines the camera rotation along the logitudinal axis
  36854. * @param beta Defines the camera rotation along the latitudinal axis
  36855. * @param radius Defines the camera distance from its target
  36856. * @param target Defines the camera target
  36857. * @param scene Defines the scene the camera belongs to
  36858. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36859. */
  36860. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36861. /** @hidden */
  36862. _initCache(): void;
  36863. /** @hidden */
  36864. _updateCache(ignoreParentClass?: boolean): void;
  36865. protected _getTargetPosition(): Vector3;
  36866. private _storedAlpha;
  36867. private _storedBeta;
  36868. private _storedRadius;
  36869. private _storedTarget;
  36870. /**
  36871. * Stores the current state of the camera (alpha, beta, radius and target)
  36872. * @returns the camera itself
  36873. */
  36874. storeState(): Camera;
  36875. /**
  36876. * @hidden
  36877. * Restored camera state. You must call storeState() first
  36878. */
  36879. _restoreStateValues(): boolean;
  36880. /** @hidden */
  36881. _isSynchronizedViewMatrix(): boolean;
  36882. /**
  36883. * Attached controls to the current camera.
  36884. * @param element Defines the element the controls should be listened from
  36885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36886. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36887. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36888. */
  36889. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36890. /**
  36891. * Detach the current controls from the camera.
  36892. * The camera will stop reacting to inputs.
  36893. * @param element Defines the element to stop listening the inputs from
  36894. */
  36895. detachControl(element: HTMLElement): void;
  36896. /** @hidden */
  36897. _checkInputs(): void;
  36898. protected _checkLimits(): void;
  36899. /**
  36900. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36901. */
  36902. rebuildAnglesAndRadius(): void;
  36903. /**
  36904. * Use a position to define the current camera related information like aplha, beta and radius
  36905. * @param position Defines the position to set the camera at
  36906. */
  36907. setPosition(position: Vector3): void;
  36908. /**
  36909. * Defines the target the camera should look at.
  36910. * This will automatically adapt alpha beta and radius to fit within the new target.
  36911. * @param target Defines the new target as a Vector or a mesh
  36912. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36913. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36914. */
  36915. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36916. /** @hidden */
  36917. _getViewMatrix(): Matrix;
  36918. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36919. /**
  36920. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36921. * @param meshes Defines the mesh to zoom on
  36922. * @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)
  36923. */
  36924. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36925. /**
  36926. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36927. * The target will be changed but the radius
  36928. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36929. * @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)
  36930. */
  36931. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36932. min: Vector3;
  36933. max: Vector3;
  36934. distance: number;
  36935. }, doNotUpdateMaxZ?: boolean): void;
  36936. /**
  36937. * @override
  36938. * Override Camera.createRigCamera
  36939. */
  36940. createRigCamera(name: string, cameraIndex: number): Camera;
  36941. /**
  36942. * @hidden
  36943. * @override
  36944. * Override Camera._updateRigCameras
  36945. */
  36946. _updateRigCameras(): void;
  36947. /**
  36948. * Destroy the camera and release the current resources hold by it.
  36949. */
  36950. dispose(): void;
  36951. /**
  36952. * Gets the current object class name.
  36953. * @return the class name
  36954. */
  36955. getClassName(): string;
  36956. }
  36957. }
  36958. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36959. import { Behavior } from "babylonjs/Behaviors/behavior";
  36960. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36961. /**
  36962. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36963. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36964. */
  36965. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36966. /**
  36967. * Gets the name of the behavior.
  36968. */
  36969. readonly name: string;
  36970. private _zoomStopsAnimation;
  36971. private _idleRotationSpeed;
  36972. private _idleRotationWaitTime;
  36973. private _idleRotationSpinupTime;
  36974. /**
  36975. * Sets the flag that indicates if user zooming should stop animation.
  36976. */
  36977. /**
  36978. * Gets the flag that indicates if user zooming should stop animation.
  36979. */
  36980. zoomStopsAnimation: boolean;
  36981. /**
  36982. * Sets the default speed at which the camera rotates around the model.
  36983. */
  36984. /**
  36985. * Gets the default speed at which the camera rotates around the model.
  36986. */
  36987. idleRotationSpeed: number;
  36988. /**
  36989. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36990. */
  36991. /**
  36992. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36993. */
  36994. idleRotationWaitTime: number;
  36995. /**
  36996. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36997. */
  36998. /**
  36999. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37000. */
  37001. idleRotationSpinupTime: number;
  37002. /**
  37003. * Gets a value indicating if the camera is currently rotating because of this behavior
  37004. */
  37005. readonly rotationInProgress: boolean;
  37006. private _onPrePointerObservableObserver;
  37007. private _onAfterCheckInputsObserver;
  37008. private _attachedCamera;
  37009. private _isPointerDown;
  37010. private _lastFrameTime;
  37011. private _lastInteractionTime;
  37012. private _cameraRotationSpeed;
  37013. /**
  37014. * Initializes the behavior.
  37015. */
  37016. init(): void;
  37017. /**
  37018. * Attaches the behavior to its arc rotate camera.
  37019. * @param camera Defines the camera to attach the behavior to
  37020. */
  37021. attach(camera: ArcRotateCamera): void;
  37022. /**
  37023. * Detaches the behavior from its current arc rotate camera.
  37024. */
  37025. detach(): void;
  37026. /**
  37027. * Returns true if user is scrolling.
  37028. * @return true if user is scrolling.
  37029. */
  37030. private _userIsZooming;
  37031. private _lastFrameRadius;
  37032. private _shouldAnimationStopForInteraction;
  37033. /**
  37034. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37035. */
  37036. private _applyUserInteraction;
  37037. private _userIsMoving;
  37038. }
  37039. }
  37040. declare module "babylonjs/Behaviors/Cameras/index" {
  37041. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37042. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37043. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37044. }
  37045. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37046. import { Mesh } from "babylonjs/Meshes/mesh";
  37047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37048. import { Behavior } from "babylonjs/Behaviors/behavior";
  37049. /**
  37050. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37051. */
  37052. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37053. private ui;
  37054. /**
  37055. * The name of the behavior
  37056. */
  37057. name: string;
  37058. /**
  37059. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37060. */
  37061. distanceAwayFromFace: number;
  37062. /**
  37063. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37064. */
  37065. distanceAwayFromBottomOfFace: number;
  37066. private _faceVectors;
  37067. private _target;
  37068. private _scene;
  37069. private _onRenderObserver;
  37070. private _tmpMatrix;
  37071. private _tmpVector;
  37072. /**
  37073. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37074. * @param ui The transform node that should be attched to the mesh
  37075. */
  37076. constructor(ui: TransformNode);
  37077. /**
  37078. * Initializes the behavior
  37079. */
  37080. init(): void;
  37081. private _closestFace;
  37082. private _zeroVector;
  37083. private _lookAtTmpMatrix;
  37084. private _lookAtToRef;
  37085. /**
  37086. * Attaches the AttachToBoxBehavior to the passed in mesh
  37087. * @param target The mesh that the specified node will be attached to
  37088. */
  37089. attach(target: Mesh): void;
  37090. /**
  37091. * Detaches the behavior from the mesh
  37092. */
  37093. detach(): void;
  37094. }
  37095. }
  37096. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37097. import { Behavior } from "babylonjs/Behaviors/behavior";
  37098. import { Mesh } from "babylonjs/Meshes/mesh";
  37099. /**
  37100. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37101. */
  37102. export class FadeInOutBehavior implements Behavior<Mesh> {
  37103. /**
  37104. * Time in milliseconds to delay before fading in (Default: 0)
  37105. */
  37106. delay: number;
  37107. /**
  37108. * Time in milliseconds for the mesh to fade in (Default: 300)
  37109. */
  37110. fadeInTime: number;
  37111. private _millisecondsPerFrame;
  37112. private _hovered;
  37113. private _hoverValue;
  37114. private _ownerNode;
  37115. /**
  37116. * Instatiates the FadeInOutBehavior
  37117. */
  37118. constructor();
  37119. /**
  37120. * The name of the behavior
  37121. */
  37122. readonly name: string;
  37123. /**
  37124. * Initializes the behavior
  37125. */
  37126. init(): void;
  37127. /**
  37128. * Attaches the fade behavior on the passed in mesh
  37129. * @param ownerNode The mesh that will be faded in/out once attached
  37130. */
  37131. attach(ownerNode: Mesh): void;
  37132. /**
  37133. * Detaches the behavior from the mesh
  37134. */
  37135. detach(): void;
  37136. /**
  37137. * Triggers the mesh to begin fading in or out
  37138. * @param value if the object should fade in or out (true to fade in)
  37139. */
  37140. fadeIn(value: boolean): void;
  37141. private _update;
  37142. private _setAllVisibility;
  37143. }
  37144. }
  37145. declare module "babylonjs/Misc/pivotTools" {
  37146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37147. /**
  37148. * Class containing a set of static utilities functions for managing Pivots
  37149. * @hidden
  37150. */
  37151. export class PivotTools {
  37152. private static _PivotCached;
  37153. private static _OldPivotPoint;
  37154. private static _PivotTranslation;
  37155. private static _PivotTmpVector;
  37156. /** @hidden */
  37157. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37158. /** @hidden */
  37159. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37160. }
  37161. }
  37162. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37163. import { Scene } from "babylonjs/scene";
  37164. import { Vector4, Plane } from "babylonjs/Maths/math";
  37165. import { Mesh } from "babylonjs/Meshes/mesh";
  37166. import { Nullable } from "babylonjs/types";
  37167. /**
  37168. * Class containing static functions to help procedurally build meshes
  37169. */
  37170. export class PlaneBuilder {
  37171. /**
  37172. * Creates a plane mesh
  37173. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37174. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37175. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37177. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37179. * @param name defines the name of the mesh
  37180. * @param options defines the options used to create the mesh
  37181. * @param scene defines the hosting scene
  37182. * @returns the plane mesh
  37183. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37184. */
  37185. static CreatePlane(name: string, options: {
  37186. size?: number;
  37187. width?: number;
  37188. height?: number;
  37189. sideOrientation?: number;
  37190. frontUVs?: Vector4;
  37191. backUVs?: Vector4;
  37192. updatable?: boolean;
  37193. sourcePlane?: Plane;
  37194. }, scene?: Nullable<Scene>): Mesh;
  37195. }
  37196. }
  37197. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37198. import { Behavior } from "babylonjs/Behaviors/behavior";
  37199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37200. import { Observable } from "babylonjs/Misc/observable";
  37201. import { Vector3 } from "babylonjs/Maths/math";
  37202. import { Ray } from "babylonjs/Culling/ray";
  37203. import "babylonjs/Meshes/Builders/planeBuilder";
  37204. /**
  37205. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37206. */
  37207. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37208. private static _AnyMouseID;
  37209. /**
  37210. * Abstract mesh the behavior is set on
  37211. */
  37212. attachedNode: AbstractMesh;
  37213. private _dragPlane;
  37214. private _scene;
  37215. private _pointerObserver;
  37216. private _beforeRenderObserver;
  37217. private static _planeScene;
  37218. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37219. /**
  37220. * 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)
  37221. */
  37222. maxDragAngle: number;
  37223. /**
  37224. * @hidden
  37225. */
  37226. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37227. /**
  37228. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37229. */
  37230. currentDraggingPointerID: number;
  37231. /**
  37232. * The last position where the pointer hit the drag plane in world space
  37233. */
  37234. lastDragPosition: Vector3;
  37235. /**
  37236. * If the behavior is currently in a dragging state
  37237. */
  37238. dragging: boolean;
  37239. /**
  37240. * 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)
  37241. */
  37242. dragDeltaRatio: number;
  37243. /**
  37244. * If the drag plane orientation should be updated during the dragging (Default: true)
  37245. */
  37246. updateDragPlane: boolean;
  37247. private _debugMode;
  37248. private _moving;
  37249. /**
  37250. * Fires each time the attached mesh is dragged with the pointer
  37251. * * delta between last drag position and current drag position in world space
  37252. * * dragDistance along the drag axis
  37253. * * dragPlaneNormal normal of the current drag plane used during the drag
  37254. * * dragPlanePoint in world space where the drag intersects the drag plane
  37255. */
  37256. onDragObservable: Observable<{
  37257. delta: Vector3;
  37258. dragPlanePoint: Vector3;
  37259. dragPlaneNormal: Vector3;
  37260. dragDistance: number;
  37261. pointerId: number;
  37262. }>;
  37263. /**
  37264. * Fires each time a drag begins (eg. mouse down on mesh)
  37265. */
  37266. onDragStartObservable: Observable<{
  37267. dragPlanePoint: Vector3;
  37268. pointerId: number;
  37269. }>;
  37270. /**
  37271. * Fires each time a drag ends (eg. mouse release after drag)
  37272. */
  37273. onDragEndObservable: Observable<{
  37274. dragPlanePoint: Vector3;
  37275. pointerId: number;
  37276. }>;
  37277. /**
  37278. * If the attached mesh should be moved when dragged
  37279. */
  37280. moveAttached: boolean;
  37281. /**
  37282. * If the drag behavior will react to drag events (Default: true)
  37283. */
  37284. enabled: boolean;
  37285. /**
  37286. * If pointer events should start and release the drag (Default: true)
  37287. */
  37288. startAndReleaseDragOnPointerEvents: boolean;
  37289. /**
  37290. * If camera controls should be detached during the drag
  37291. */
  37292. detachCameraControls: boolean;
  37293. /**
  37294. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37295. */
  37296. useObjectOrienationForDragging: boolean;
  37297. private _options;
  37298. /**
  37299. * Creates a pointer drag behavior that can be attached to a mesh
  37300. * @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)
  37301. */
  37302. constructor(options?: {
  37303. dragAxis?: Vector3;
  37304. dragPlaneNormal?: Vector3;
  37305. });
  37306. /**
  37307. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37308. */
  37309. validateDrag: (targetPosition: Vector3) => boolean;
  37310. /**
  37311. * The name of the behavior
  37312. */
  37313. readonly name: string;
  37314. /**
  37315. * Initializes the behavior
  37316. */
  37317. init(): void;
  37318. private _tmpVector;
  37319. private _alternatePickedPoint;
  37320. private _worldDragAxis;
  37321. private _targetPosition;
  37322. private _attachedElement;
  37323. /**
  37324. * Attaches the drag behavior the passed in mesh
  37325. * @param ownerNode The mesh that will be dragged around once attached
  37326. */
  37327. attach(ownerNode: AbstractMesh): void;
  37328. /**
  37329. * Force relase the drag action by code.
  37330. */
  37331. releaseDrag(): void;
  37332. private _startDragRay;
  37333. private _lastPointerRay;
  37334. /**
  37335. * Simulates the start of a pointer drag event on the behavior
  37336. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37337. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37338. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37339. */
  37340. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37341. private _startDrag;
  37342. private _dragDelta;
  37343. private _moveDrag;
  37344. private _pickWithRayOnDragPlane;
  37345. private _pointA;
  37346. private _pointB;
  37347. private _pointC;
  37348. private _lineA;
  37349. private _lineB;
  37350. private _localAxis;
  37351. private _lookAt;
  37352. private _updateDragPlanePosition;
  37353. /**
  37354. * Detaches the behavior from the mesh
  37355. */
  37356. detach(): void;
  37357. }
  37358. }
  37359. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37360. import { Mesh } from "babylonjs/Meshes/mesh";
  37361. import { Behavior } from "babylonjs/Behaviors/behavior";
  37362. /**
  37363. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37364. */
  37365. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37366. private _dragBehaviorA;
  37367. private _dragBehaviorB;
  37368. private _startDistance;
  37369. private _initialScale;
  37370. private _targetScale;
  37371. private _ownerNode;
  37372. private _sceneRenderObserver;
  37373. /**
  37374. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37375. */
  37376. constructor();
  37377. /**
  37378. * The name of the behavior
  37379. */
  37380. readonly name: string;
  37381. /**
  37382. * Initializes the behavior
  37383. */
  37384. init(): void;
  37385. private _getCurrentDistance;
  37386. /**
  37387. * Attaches the scale behavior the passed in mesh
  37388. * @param ownerNode The mesh that will be scaled around once attached
  37389. */
  37390. attach(ownerNode: Mesh): void;
  37391. /**
  37392. * Detaches the behavior from the mesh
  37393. */
  37394. detach(): void;
  37395. }
  37396. }
  37397. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37398. import { Behavior } from "babylonjs/Behaviors/behavior";
  37399. import { Mesh } from "babylonjs/Meshes/mesh";
  37400. import { Observable } from "babylonjs/Misc/observable";
  37401. /**
  37402. * 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
  37403. */
  37404. export class SixDofDragBehavior implements Behavior<Mesh> {
  37405. private static _virtualScene;
  37406. private _ownerNode;
  37407. private _sceneRenderObserver;
  37408. private _scene;
  37409. private _targetPosition;
  37410. private _virtualOriginMesh;
  37411. private _virtualDragMesh;
  37412. private _pointerObserver;
  37413. private _moving;
  37414. private _startingOrientation;
  37415. /**
  37416. * 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)
  37417. */
  37418. private zDragFactor;
  37419. /**
  37420. * If the object should rotate to face the drag origin
  37421. */
  37422. rotateDraggedObject: boolean;
  37423. /**
  37424. * If the behavior is currently in a dragging state
  37425. */
  37426. dragging: boolean;
  37427. /**
  37428. * 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)
  37429. */
  37430. dragDeltaRatio: number;
  37431. /**
  37432. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37433. */
  37434. currentDraggingPointerID: number;
  37435. /**
  37436. * If camera controls should be detached during the drag
  37437. */
  37438. detachCameraControls: boolean;
  37439. /**
  37440. * Fires each time a drag starts
  37441. */
  37442. onDragStartObservable: Observable<{}>;
  37443. /**
  37444. * Fires each time a drag ends (eg. mouse release after drag)
  37445. */
  37446. onDragEndObservable: Observable<{}>;
  37447. /**
  37448. * 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
  37449. */
  37450. constructor();
  37451. /**
  37452. * The name of the behavior
  37453. */
  37454. readonly name: string;
  37455. /**
  37456. * Initializes the behavior
  37457. */
  37458. init(): void;
  37459. /**
  37460. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37461. */
  37462. private readonly _pointerCamera;
  37463. /**
  37464. * Attaches the scale behavior the passed in mesh
  37465. * @param ownerNode The mesh that will be scaled around once attached
  37466. */
  37467. attach(ownerNode: Mesh): void;
  37468. /**
  37469. * Detaches the behavior from the mesh
  37470. */
  37471. detach(): void;
  37472. }
  37473. }
  37474. declare module "babylonjs/Behaviors/Meshes/index" {
  37475. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37476. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37477. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37478. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37479. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37480. }
  37481. declare module "babylonjs/Behaviors/index" {
  37482. export * from "babylonjs/Behaviors/behavior";
  37483. export * from "babylonjs/Behaviors/Cameras/index";
  37484. export * from "babylonjs/Behaviors/Meshes/index";
  37485. }
  37486. declare module "babylonjs/Bones/boneIKController" {
  37487. import { Bone } from "babylonjs/Bones/bone";
  37488. import { Vector3 } from "babylonjs/Maths/math";
  37489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37490. import { Nullable } from "babylonjs/types";
  37491. /**
  37492. * Class used to apply inverse kinematics to bones
  37493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37494. */
  37495. export class BoneIKController {
  37496. private static _tmpVecs;
  37497. private static _tmpQuat;
  37498. private static _tmpMats;
  37499. /**
  37500. * Gets or sets the target mesh
  37501. */
  37502. targetMesh: AbstractMesh;
  37503. /** Gets or sets the mesh used as pole */
  37504. poleTargetMesh: AbstractMesh;
  37505. /**
  37506. * Gets or sets the bone used as pole
  37507. */
  37508. poleTargetBone: Nullable<Bone>;
  37509. /**
  37510. * Gets or sets the target position
  37511. */
  37512. targetPosition: Vector3;
  37513. /**
  37514. * Gets or sets the pole target position
  37515. */
  37516. poleTargetPosition: Vector3;
  37517. /**
  37518. * Gets or sets the pole target local offset
  37519. */
  37520. poleTargetLocalOffset: Vector3;
  37521. /**
  37522. * Gets or sets the pole angle
  37523. */
  37524. poleAngle: number;
  37525. /**
  37526. * Gets or sets the mesh associated with the controller
  37527. */
  37528. mesh: AbstractMesh;
  37529. /**
  37530. * 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)
  37531. */
  37532. slerpAmount: number;
  37533. private _bone1Quat;
  37534. private _bone1Mat;
  37535. private _bone2Ang;
  37536. private _bone1;
  37537. private _bone2;
  37538. private _bone1Length;
  37539. private _bone2Length;
  37540. private _maxAngle;
  37541. private _maxReach;
  37542. private _rightHandedSystem;
  37543. private _bendAxis;
  37544. private _slerping;
  37545. private _adjustRoll;
  37546. /**
  37547. * Gets or sets maximum allowed angle
  37548. */
  37549. maxAngle: number;
  37550. /**
  37551. * Creates a new BoneIKController
  37552. * @param mesh defines the mesh to control
  37553. * @param bone defines the bone to control
  37554. * @param options defines options to set up the controller
  37555. */
  37556. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37557. targetMesh?: AbstractMesh;
  37558. poleTargetMesh?: AbstractMesh;
  37559. poleTargetBone?: Bone;
  37560. poleTargetLocalOffset?: Vector3;
  37561. poleAngle?: number;
  37562. bendAxis?: Vector3;
  37563. maxAngle?: number;
  37564. slerpAmount?: number;
  37565. });
  37566. private _setMaxAngle;
  37567. /**
  37568. * Force the controller to update the bones
  37569. */
  37570. update(): void;
  37571. }
  37572. }
  37573. declare module "babylonjs/Bones/boneLookController" {
  37574. import { Vector3, Space } from "babylonjs/Maths/math";
  37575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37576. import { Bone } from "babylonjs/Bones/bone";
  37577. /**
  37578. * Class used to make a bone look toward a point in space
  37579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37580. */
  37581. export class BoneLookController {
  37582. private static _tmpVecs;
  37583. private static _tmpQuat;
  37584. private static _tmpMats;
  37585. /**
  37586. * The target Vector3 that the bone will look at
  37587. */
  37588. target: Vector3;
  37589. /**
  37590. * The mesh that the bone is attached to
  37591. */
  37592. mesh: AbstractMesh;
  37593. /**
  37594. * The bone that will be looking to the target
  37595. */
  37596. bone: Bone;
  37597. /**
  37598. * The up axis of the coordinate system that is used when the bone is rotated
  37599. */
  37600. upAxis: Vector3;
  37601. /**
  37602. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37603. */
  37604. upAxisSpace: Space;
  37605. /**
  37606. * Used to make an adjustment to the yaw of the bone
  37607. */
  37608. adjustYaw: number;
  37609. /**
  37610. * Used to make an adjustment to the pitch of the bone
  37611. */
  37612. adjustPitch: number;
  37613. /**
  37614. * Used to make an adjustment to the roll of the bone
  37615. */
  37616. adjustRoll: number;
  37617. /**
  37618. * 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)
  37619. */
  37620. slerpAmount: number;
  37621. private _minYaw;
  37622. private _maxYaw;
  37623. private _minPitch;
  37624. private _maxPitch;
  37625. private _minYawSin;
  37626. private _minYawCos;
  37627. private _maxYawSin;
  37628. private _maxYawCos;
  37629. private _midYawConstraint;
  37630. private _minPitchTan;
  37631. private _maxPitchTan;
  37632. private _boneQuat;
  37633. private _slerping;
  37634. private _transformYawPitch;
  37635. private _transformYawPitchInv;
  37636. private _firstFrameSkipped;
  37637. private _yawRange;
  37638. private _fowardAxis;
  37639. /**
  37640. * Gets or sets the minimum yaw angle that the bone can look to
  37641. */
  37642. minYaw: number;
  37643. /**
  37644. * Gets or sets the maximum yaw angle that the bone can look to
  37645. */
  37646. maxYaw: number;
  37647. /**
  37648. * Gets or sets the minimum pitch angle that the bone can look to
  37649. */
  37650. minPitch: number;
  37651. /**
  37652. * Gets or sets the maximum pitch angle that the bone can look to
  37653. */
  37654. maxPitch: number;
  37655. /**
  37656. * Create a BoneLookController
  37657. * @param mesh the mesh that the bone belongs to
  37658. * @param bone the bone that will be looking to the target
  37659. * @param target the target Vector3 to look at
  37660. * @param options optional settings:
  37661. * * maxYaw: the maximum angle the bone will yaw to
  37662. * * minYaw: the minimum angle the bone will yaw to
  37663. * * maxPitch: the maximum angle the bone will pitch to
  37664. * * minPitch: the minimum angle the bone will yaw to
  37665. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37666. * * upAxis: the up axis of the coordinate system
  37667. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37668. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37669. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37670. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37671. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37672. * * adjustRoll: used to make an adjustment to the roll of the bone
  37673. **/
  37674. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37675. maxYaw?: number;
  37676. minYaw?: number;
  37677. maxPitch?: number;
  37678. minPitch?: number;
  37679. slerpAmount?: number;
  37680. upAxis?: Vector3;
  37681. upAxisSpace?: Space;
  37682. yawAxis?: Vector3;
  37683. pitchAxis?: Vector3;
  37684. adjustYaw?: number;
  37685. adjustPitch?: number;
  37686. adjustRoll?: number;
  37687. });
  37688. /**
  37689. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37690. */
  37691. update(): void;
  37692. private _getAngleDiff;
  37693. private _getAngleBetween;
  37694. private _isAngleBetween;
  37695. }
  37696. }
  37697. declare module "babylonjs/Bones/index" {
  37698. export * from "babylonjs/Bones/bone";
  37699. export * from "babylonjs/Bones/boneIKController";
  37700. export * from "babylonjs/Bones/boneLookController";
  37701. export * from "babylonjs/Bones/skeleton";
  37702. }
  37703. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37704. import { Nullable } from "babylonjs/types";
  37705. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37706. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37707. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37708. /**
  37709. * Manage the gamepad inputs to control an arc rotate camera.
  37710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37711. */
  37712. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37713. /**
  37714. * Defines the camera the input is attached to.
  37715. */
  37716. camera: ArcRotateCamera;
  37717. /**
  37718. * Defines the gamepad the input is gathering event from.
  37719. */
  37720. gamepad: Nullable<Gamepad>;
  37721. /**
  37722. * Defines the gamepad rotation sensiblity.
  37723. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37724. */
  37725. gamepadRotationSensibility: number;
  37726. /**
  37727. * Defines the gamepad move sensiblity.
  37728. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37729. */
  37730. gamepadMoveSensibility: number;
  37731. private _onGamepadConnectedObserver;
  37732. private _onGamepadDisconnectedObserver;
  37733. /**
  37734. * Attach the input controls to a specific dom element to get the input from.
  37735. * @param element Defines the element the controls should be listened from
  37736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37737. */
  37738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37739. /**
  37740. * Detach the current controls from the specified dom element.
  37741. * @param element Defines the element to stop listening the inputs from
  37742. */
  37743. detachControl(element: Nullable<HTMLElement>): void;
  37744. /**
  37745. * Update the current camera state depending on the inputs that have been used this frame.
  37746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37747. */
  37748. checkInputs(): void;
  37749. /**
  37750. * Gets the class name of the current intput.
  37751. * @returns the class name
  37752. */
  37753. getClassName(): string;
  37754. /**
  37755. * Get the friendly name associated with the input class.
  37756. * @returns the input friendly name
  37757. */
  37758. getSimpleName(): string;
  37759. }
  37760. }
  37761. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37762. import { Nullable } from "babylonjs/types";
  37763. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37765. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37766. interface ArcRotateCameraInputsManager {
  37767. /**
  37768. * Add orientation input support to the input manager.
  37769. * @returns the current input manager
  37770. */
  37771. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37772. }
  37773. }
  37774. /**
  37775. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37777. */
  37778. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37779. /**
  37780. * Defines the camera the input is attached to.
  37781. */
  37782. camera: ArcRotateCamera;
  37783. /**
  37784. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37785. */
  37786. alphaCorrection: number;
  37787. /**
  37788. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37789. */
  37790. gammaCorrection: number;
  37791. private _alpha;
  37792. private _gamma;
  37793. private _dirty;
  37794. private _deviceOrientationHandler;
  37795. /**
  37796. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37797. */
  37798. constructor();
  37799. /**
  37800. * Attach the input controls to a specific dom element to get the input from.
  37801. * @param element Defines the element the controls should be listened from
  37802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37803. */
  37804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37805. /** @hidden */
  37806. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37807. /**
  37808. * Update the current camera state depending on the inputs that have been used this frame.
  37809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37810. */
  37811. checkInputs(): void;
  37812. /**
  37813. * Detach the current controls from the specified dom element.
  37814. * @param element Defines the element to stop listening the inputs from
  37815. */
  37816. detachControl(element: Nullable<HTMLElement>): void;
  37817. /**
  37818. * Gets the class name of the current intput.
  37819. * @returns the class name
  37820. */
  37821. getClassName(): string;
  37822. /**
  37823. * Get the friendly name associated with the input class.
  37824. * @returns the input friendly name
  37825. */
  37826. getSimpleName(): string;
  37827. }
  37828. }
  37829. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37830. import { Nullable } from "babylonjs/types";
  37831. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37832. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37833. /**
  37834. * Listen to mouse events to control the camera.
  37835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37836. */
  37837. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37838. /**
  37839. * Defines the camera the input is attached to.
  37840. */
  37841. camera: FlyCamera;
  37842. /**
  37843. * Defines if touch is enabled. (Default is true.)
  37844. */
  37845. touchEnabled: boolean;
  37846. /**
  37847. * Defines the buttons associated with the input to handle camera rotation.
  37848. */
  37849. buttons: number[];
  37850. /**
  37851. * Assign buttons for Yaw control.
  37852. */
  37853. buttonsYaw: number[];
  37854. /**
  37855. * Assign buttons for Pitch control.
  37856. */
  37857. buttonsPitch: number[];
  37858. /**
  37859. * Assign buttons for Roll control.
  37860. */
  37861. buttonsRoll: number[];
  37862. /**
  37863. * Detect if any button is being pressed while mouse is moved.
  37864. * -1 = Mouse locked.
  37865. * 0 = Left button.
  37866. * 1 = Middle Button.
  37867. * 2 = Right Button.
  37868. */
  37869. activeButton: number;
  37870. /**
  37871. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37872. * Higher values reduce its sensitivity.
  37873. */
  37874. angularSensibility: number;
  37875. private _mousemoveCallback;
  37876. private _observer;
  37877. private _rollObserver;
  37878. private previousPosition;
  37879. private noPreventDefault;
  37880. private element;
  37881. /**
  37882. * Listen to mouse events to control the camera.
  37883. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37885. */
  37886. constructor(touchEnabled?: boolean);
  37887. /**
  37888. * Attach the mouse control to the HTML DOM element.
  37889. * @param element Defines the element that listens to the input events.
  37890. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37891. */
  37892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37893. /**
  37894. * Detach the current controls from the specified dom element.
  37895. * @param element Defines the element to stop listening the inputs from
  37896. */
  37897. detachControl(element: Nullable<HTMLElement>): void;
  37898. /**
  37899. * Gets the class name of the current input.
  37900. * @returns the class name.
  37901. */
  37902. getClassName(): string;
  37903. /**
  37904. * Get the friendly name associated with the input class.
  37905. * @returns the input's friendly name.
  37906. */
  37907. getSimpleName(): string;
  37908. private _pointerInput;
  37909. private _onMouseMove;
  37910. /**
  37911. * Rotate camera by mouse offset.
  37912. */
  37913. private rotateCamera;
  37914. }
  37915. }
  37916. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37917. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37918. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37919. /**
  37920. * Default Inputs manager for the FlyCamera.
  37921. * It groups all the default supported inputs for ease of use.
  37922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37923. */
  37924. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37925. /**
  37926. * Instantiates a new FlyCameraInputsManager.
  37927. * @param camera Defines the camera the inputs belong to.
  37928. */
  37929. constructor(camera: FlyCamera);
  37930. /**
  37931. * Add keyboard input support to the input manager.
  37932. * @returns the new FlyCameraKeyboardMoveInput().
  37933. */
  37934. addKeyboard(): FlyCameraInputsManager;
  37935. /**
  37936. * Add mouse input support to the input manager.
  37937. * @param touchEnabled Enable touch screen support.
  37938. * @returns the new FlyCameraMouseInput().
  37939. */
  37940. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37941. }
  37942. }
  37943. declare module "babylonjs/Cameras/flyCamera" {
  37944. import { Scene } from "babylonjs/scene";
  37945. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37947. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37948. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37949. /**
  37950. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37951. * such as in a 3D Space Shooter or a Flight Simulator.
  37952. */
  37953. export class FlyCamera extends TargetCamera {
  37954. /**
  37955. * Define the collision ellipsoid of the camera.
  37956. * This is helpful for simulating a camera body, like a player's body.
  37957. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37958. */
  37959. ellipsoid: Vector3;
  37960. /**
  37961. * Define an offset for the position of the ellipsoid around the camera.
  37962. * This can be helpful if the camera is attached away from the player's body center,
  37963. * such as at its head.
  37964. */
  37965. ellipsoidOffset: Vector3;
  37966. /**
  37967. * Enable or disable collisions of the camera with the rest of the scene objects.
  37968. */
  37969. checkCollisions: boolean;
  37970. /**
  37971. * Enable or disable gravity on the camera.
  37972. */
  37973. applyGravity: boolean;
  37974. /**
  37975. * Define the current direction the camera is moving to.
  37976. */
  37977. cameraDirection: Vector3;
  37978. /**
  37979. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37980. * This overrides and empties cameraRotation.
  37981. */
  37982. rotationQuaternion: Quaternion;
  37983. /**
  37984. * Track Roll to maintain the wanted Rolling when looking around.
  37985. */
  37986. _trackRoll: number;
  37987. /**
  37988. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37989. */
  37990. rollCorrect: number;
  37991. /**
  37992. * Mimic a banked turn, Rolling the camera when Yawing.
  37993. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37994. */
  37995. bankedTurn: boolean;
  37996. /**
  37997. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37998. */
  37999. bankedTurnLimit: number;
  38000. /**
  38001. * Value of 0 disables the banked Roll.
  38002. * Value of 1 is equal to the Yaw angle in radians.
  38003. */
  38004. bankedTurnMultiplier: number;
  38005. /**
  38006. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38007. */
  38008. inputs: FlyCameraInputsManager;
  38009. /**
  38010. * Gets the input sensibility for mouse input.
  38011. * Higher values reduce sensitivity.
  38012. */
  38013. /**
  38014. * Sets the input sensibility for a mouse input.
  38015. * Higher values reduce sensitivity.
  38016. */
  38017. angularSensibility: number;
  38018. /**
  38019. * Get the keys for camera movement forward.
  38020. */
  38021. /**
  38022. * Set the keys for camera movement forward.
  38023. */
  38024. keysForward: number[];
  38025. /**
  38026. * Get the keys for camera movement backward.
  38027. */
  38028. keysBackward: number[];
  38029. /**
  38030. * Get the keys for camera movement up.
  38031. */
  38032. /**
  38033. * Set the keys for camera movement up.
  38034. */
  38035. keysUp: number[];
  38036. /**
  38037. * Get the keys for camera movement down.
  38038. */
  38039. /**
  38040. * Set the keys for camera movement down.
  38041. */
  38042. keysDown: number[];
  38043. /**
  38044. * Get the keys for camera movement left.
  38045. */
  38046. /**
  38047. * Set the keys for camera movement left.
  38048. */
  38049. keysLeft: number[];
  38050. /**
  38051. * Set the keys for camera movement right.
  38052. */
  38053. /**
  38054. * Set the keys for camera movement right.
  38055. */
  38056. keysRight: number[];
  38057. /**
  38058. * Event raised when the camera collides with a mesh in the scene.
  38059. */
  38060. onCollide: (collidedMesh: AbstractMesh) => void;
  38061. private _collider;
  38062. private _needMoveForGravity;
  38063. private _oldPosition;
  38064. private _diffPosition;
  38065. private _newPosition;
  38066. /** @hidden */
  38067. _localDirection: Vector3;
  38068. /** @hidden */
  38069. _transformedDirection: Vector3;
  38070. /**
  38071. * Instantiates a FlyCamera.
  38072. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38073. * such as in a 3D Space Shooter or a Flight Simulator.
  38074. * @param name Define the name of the camera in the scene.
  38075. * @param position Define the starting position of the camera in the scene.
  38076. * @param scene Define the scene the camera belongs to.
  38077. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38078. */
  38079. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38080. /**
  38081. * Attach a control to the HTML DOM element.
  38082. * @param element Defines the element that listens to the input events.
  38083. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38084. */
  38085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38086. /**
  38087. * Detach a control from the HTML DOM element.
  38088. * The camera will stop reacting to that input.
  38089. * @param element Defines the element that listens to the input events.
  38090. */
  38091. detachControl(element: HTMLElement): void;
  38092. private _collisionMask;
  38093. /**
  38094. * Get the mask that the camera ignores in collision events.
  38095. */
  38096. /**
  38097. * Set the mask that the camera ignores in collision events.
  38098. */
  38099. collisionMask: number;
  38100. /** @hidden */
  38101. _collideWithWorld(displacement: Vector3): void;
  38102. /** @hidden */
  38103. private _onCollisionPositionChange;
  38104. /** @hidden */
  38105. _checkInputs(): void;
  38106. /** @hidden */
  38107. _decideIfNeedsToMove(): boolean;
  38108. /** @hidden */
  38109. _updatePosition(): void;
  38110. /**
  38111. * Restore the Roll to its target value at the rate specified.
  38112. * @param rate - Higher means slower restoring.
  38113. * @hidden
  38114. */
  38115. restoreRoll(rate: number): void;
  38116. /**
  38117. * Destroy the camera and release the current resources held by it.
  38118. */
  38119. dispose(): void;
  38120. /**
  38121. * Get the current object class name.
  38122. * @returns the class name.
  38123. */
  38124. getClassName(): string;
  38125. }
  38126. }
  38127. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38128. import { Nullable } from "babylonjs/types";
  38129. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38130. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38131. /**
  38132. * Listen to keyboard events to control the camera.
  38133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38134. */
  38135. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38136. /**
  38137. * Defines the camera the input is attached to.
  38138. */
  38139. camera: FlyCamera;
  38140. /**
  38141. * The list of keyboard keys used to control the forward move of the camera.
  38142. */
  38143. keysForward: number[];
  38144. /**
  38145. * The list of keyboard keys used to control the backward move of the camera.
  38146. */
  38147. keysBackward: number[];
  38148. /**
  38149. * The list of keyboard keys used to control the forward move of the camera.
  38150. */
  38151. keysUp: number[];
  38152. /**
  38153. * The list of keyboard keys used to control the backward move of the camera.
  38154. */
  38155. keysDown: number[];
  38156. /**
  38157. * The list of keyboard keys used to control the right strafe move of the camera.
  38158. */
  38159. keysRight: number[];
  38160. /**
  38161. * The list of keyboard keys used to control the left strafe move of the camera.
  38162. */
  38163. keysLeft: number[];
  38164. private _keys;
  38165. private _onCanvasBlurObserver;
  38166. private _onKeyboardObserver;
  38167. private _engine;
  38168. private _scene;
  38169. /**
  38170. * Attach the input controls to a specific dom element to get the input from.
  38171. * @param element Defines the element the controls should be listened from
  38172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38173. */
  38174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38175. /**
  38176. * Detach the current controls from the specified dom element.
  38177. * @param element Defines the element to stop listening the inputs from
  38178. */
  38179. detachControl(element: Nullable<HTMLElement>): void;
  38180. /**
  38181. * Gets the class name of the current intput.
  38182. * @returns the class name
  38183. */
  38184. getClassName(): string;
  38185. /** @hidden */
  38186. _onLostFocus(e: FocusEvent): void;
  38187. /**
  38188. * Get the friendly name associated with the input class.
  38189. * @returns the input friendly name
  38190. */
  38191. getSimpleName(): string;
  38192. /**
  38193. * Update the current camera state depending on the inputs that have been used this frame.
  38194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38195. */
  38196. checkInputs(): void;
  38197. }
  38198. }
  38199. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38200. import { Nullable } from "babylonjs/types";
  38201. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38202. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38203. /**
  38204. * Manage the mouse wheel inputs to control a follow camera.
  38205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38206. */
  38207. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38208. /**
  38209. * Defines the camera the input is attached to.
  38210. */
  38211. camera: FollowCamera;
  38212. /**
  38213. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38214. */
  38215. axisControlRadius: boolean;
  38216. /**
  38217. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38218. */
  38219. axisControlHeight: boolean;
  38220. /**
  38221. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38222. */
  38223. axisControlRotation: boolean;
  38224. /**
  38225. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38226. * relation to mouseWheel events.
  38227. */
  38228. wheelPrecision: number;
  38229. /**
  38230. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38231. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38232. */
  38233. wheelDeltaPercentage: number;
  38234. private _wheel;
  38235. private _observer;
  38236. /**
  38237. * Attach the input controls to a specific dom element to get the input from.
  38238. * @param element Defines the element the controls should be listened from
  38239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38240. */
  38241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38242. /**
  38243. * Detach the current controls from the specified dom element.
  38244. * @param element Defines the element to stop listening the inputs from
  38245. */
  38246. detachControl(element: Nullable<HTMLElement>): void;
  38247. /**
  38248. * Gets the class name of the current intput.
  38249. * @returns the class name
  38250. */
  38251. getClassName(): string;
  38252. /**
  38253. * Get the friendly name associated with the input class.
  38254. * @returns the input friendly name
  38255. */
  38256. getSimpleName(): string;
  38257. }
  38258. }
  38259. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38260. import { Nullable } from "babylonjs/types";
  38261. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38262. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38263. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38264. /**
  38265. * Manage the pointers inputs to control an follow camera.
  38266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38267. */
  38268. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38269. /**
  38270. * Defines the camera the input is attached to.
  38271. */
  38272. camera: FollowCamera;
  38273. /**
  38274. * Gets the class name of the current input.
  38275. * @returns the class name
  38276. */
  38277. getClassName(): string;
  38278. /**
  38279. * Defines the pointer angular sensibility along the X axis or how fast is
  38280. * the camera rotating.
  38281. * A negative number will reverse the axis direction.
  38282. */
  38283. angularSensibilityX: number;
  38284. /**
  38285. * Defines the pointer angular sensibility along the Y axis or how fast is
  38286. * the camera rotating.
  38287. * A negative number will reverse the axis direction.
  38288. */
  38289. angularSensibilityY: number;
  38290. /**
  38291. * Defines the pointer pinch precision or how fast is the camera zooming.
  38292. * A negative number will reverse the axis direction.
  38293. */
  38294. pinchPrecision: number;
  38295. /**
  38296. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38297. * from 0.
  38298. * It defines the percentage of current camera.radius to use as delta when
  38299. * pinch zoom is used.
  38300. */
  38301. pinchDeltaPercentage: number;
  38302. /**
  38303. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38304. */
  38305. axisXControlRadius: boolean;
  38306. /**
  38307. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38308. */
  38309. axisXControlHeight: boolean;
  38310. /**
  38311. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38312. */
  38313. axisXControlRotation: boolean;
  38314. /**
  38315. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38316. */
  38317. axisYControlRadius: boolean;
  38318. /**
  38319. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38320. */
  38321. axisYControlHeight: boolean;
  38322. /**
  38323. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38324. */
  38325. axisYControlRotation: boolean;
  38326. /**
  38327. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38328. */
  38329. axisPinchControlRadius: boolean;
  38330. /**
  38331. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38332. */
  38333. axisPinchControlHeight: boolean;
  38334. /**
  38335. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38336. */
  38337. axisPinchControlRotation: boolean;
  38338. /**
  38339. * Log error messages if basic misconfiguration has occurred.
  38340. */
  38341. warningEnable: boolean;
  38342. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38343. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38344. private _warningCounter;
  38345. private _warning;
  38346. }
  38347. }
  38348. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38349. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38350. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38351. /**
  38352. * Default Inputs manager for the FollowCamera.
  38353. * It groups all the default supported inputs for ease of use.
  38354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38355. */
  38356. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38357. /**
  38358. * Instantiates a new FollowCameraInputsManager.
  38359. * @param camera Defines the camera the inputs belong to
  38360. */
  38361. constructor(camera: FollowCamera);
  38362. /**
  38363. * Add keyboard input support to the input manager.
  38364. * @returns the current input manager
  38365. */
  38366. addKeyboard(): FollowCameraInputsManager;
  38367. /**
  38368. * Add mouse wheel input support to the input manager.
  38369. * @returns the current input manager
  38370. */
  38371. addMouseWheel(): FollowCameraInputsManager;
  38372. /**
  38373. * Add pointers input support to the input manager.
  38374. * @returns the current input manager
  38375. */
  38376. addPointers(): FollowCameraInputsManager;
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): FollowCameraInputsManager;
  38382. }
  38383. }
  38384. declare module "babylonjs/Cameras/followCamera" {
  38385. import { Nullable } from "babylonjs/types";
  38386. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38387. import { Scene } from "babylonjs/scene";
  38388. import { Vector3 } from "babylonjs/Maths/math";
  38389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38390. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38391. /**
  38392. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38393. * an arc rotate version arcFollowCamera are available.
  38394. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38395. */
  38396. export class FollowCamera extends TargetCamera {
  38397. /**
  38398. * Distance the follow camera should follow an object at
  38399. */
  38400. radius: number;
  38401. /**
  38402. * Minimum allowed distance of the camera to the axis of rotation
  38403. * (The camera can not get closer).
  38404. * This can help limiting how the Camera is able to move in the scene.
  38405. */
  38406. lowerRadiusLimit: Nullable<number>;
  38407. /**
  38408. * Maximum allowed distance of the camera to the axis of rotation
  38409. * (The camera can not get further).
  38410. * This can help limiting how the Camera is able to move in the scene.
  38411. */
  38412. upperRadiusLimit: Nullable<number>;
  38413. /**
  38414. * Define a rotation offset between the camera and the object it follows
  38415. */
  38416. rotationOffset: number;
  38417. /**
  38418. * Minimum allowed angle to camera position relative to target object.
  38419. * This can help limiting how the Camera is able to move in the scene.
  38420. */
  38421. lowerRotationOffsetLimit: Nullable<number>;
  38422. /**
  38423. * Maximum allowed angle to camera position relative to target object.
  38424. * This can help limiting how the Camera is able to move in the scene.
  38425. */
  38426. upperRotationOffsetLimit: Nullable<number>;
  38427. /**
  38428. * Define a height offset between the camera and the object it follows.
  38429. * It can help following an object from the top (like a car chaing a plane)
  38430. */
  38431. heightOffset: number;
  38432. /**
  38433. * Minimum allowed height of camera position relative to target object.
  38434. * This can help limiting how the Camera is able to move in the scene.
  38435. */
  38436. lowerHeightOffsetLimit: Nullable<number>;
  38437. /**
  38438. * Maximum allowed height of camera position relative to target object.
  38439. * This can help limiting how the Camera is able to move in the scene.
  38440. */
  38441. upperHeightOffsetLimit: Nullable<number>;
  38442. /**
  38443. * Define how fast the camera can accelerate to follow it s target.
  38444. */
  38445. cameraAcceleration: number;
  38446. /**
  38447. * Define the speed limit of the camera following an object.
  38448. */
  38449. maxCameraSpeed: number;
  38450. /**
  38451. * Define the target of the camera.
  38452. */
  38453. lockedTarget: Nullable<AbstractMesh>;
  38454. /**
  38455. * Defines the input associated with the camera.
  38456. */
  38457. inputs: FollowCameraInputsManager;
  38458. /**
  38459. * Instantiates the follow camera.
  38460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38461. * @param name Define the name of the camera in the scene
  38462. * @param position Define the position of the camera
  38463. * @param scene Define the scene the camera belong to
  38464. * @param lockedTarget Define the target of the camera
  38465. */
  38466. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38467. private _follow;
  38468. /**
  38469. * Attached controls to the current camera.
  38470. * @param element Defines the element the controls should be listened from
  38471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38472. */
  38473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38474. /**
  38475. * Detach the current controls from the camera.
  38476. * The camera will stop reacting to inputs.
  38477. * @param element Defines the element to stop listening the inputs from
  38478. */
  38479. detachControl(element: HTMLElement): void;
  38480. /** @hidden */
  38481. _checkInputs(): void;
  38482. private _checkLimits;
  38483. /**
  38484. * Gets the camera class name.
  38485. * @returns the class name
  38486. */
  38487. getClassName(): string;
  38488. }
  38489. /**
  38490. * Arc Rotate version of the follow camera.
  38491. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38492. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38493. */
  38494. export class ArcFollowCamera extends TargetCamera {
  38495. /** The longitudinal angle of the camera */
  38496. alpha: number;
  38497. /** The latitudinal angle of the camera */
  38498. beta: number;
  38499. /** The radius of the camera from its target */
  38500. radius: number;
  38501. /** Define the camera target (the messh it should follow) */
  38502. target: Nullable<AbstractMesh>;
  38503. private _cartesianCoordinates;
  38504. /**
  38505. * Instantiates a new ArcFollowCamera
  38506. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38507. * @param name Define the name of the camera
  38508. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38509. * @param beta Define the rotation angle of the camera around the elevation axis
  38510. * @param radius Define the radius of the camera from its target point
  38511. * @param target Define the target of the camera
  38512. * @param scene Define the scene the camera belongs to
  38513. */
  38514. constructor(name: string,
  38515. /** The longitudinal angle of the camera */
  38516. alpha: number,
  38517. /** The latitudinal angle of the camera */
  38518. beta: number,
  38519. /** The radius of the camera from its target */
  38520. radius: number,
  38521. /** Define the camera target (the messh it should follow) */
  38522. target: Nullable<AbstractMesh>, scene: Scene);
  38523. private _follow;
  38524. /** @hidden */
  38525. _checkInputs(): void;
  38526. /**
  38527. * Returns the class name of the object.
  38528. * It is mostly used internally for serialization purposes.
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38535. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38536. import { Nullable } from "babylonjs/types";
  38537. /**
  38538. * Manage the keyboard inputs to control the movement of a follow camera.
  38539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38540. */
  38541. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38542. /**
  38543. * Defines the camera the input is attached to.
  38544. */
  38545. camera: FollowCamera;
  38546. /**
  38547. * Defines the list of key codes associated with the up action (increase heightOffset)
  38548. */
  38549. keysHeightOffsetIncr: number[];
  38550. /**
  38551. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38552. */
  38553. keysHeightOffsetDecr: number[];
  38554. /**
  38555. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38556. */
  38557. keysHeightOffsetModifierAlt: boolean;
  38558. /**
  38559. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38560. */
  38561. keysHeightOffsetModifierCtrl: boolean;
  38562. /**
  38563. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38564. */
  38565. keysHeightOffsetModifierShift: boolean;
  38566. /**
  38567. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38568. */
  38569. keysRotationOffsetIncr: number[];
  38570. /**
  38571. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38572. */
  38573. keysRotationOffsetDecr: number[];
  38574. /**
  38575. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38576. */
  38577. keysRotationOffsetModifierAlt: boolean;
  38578. /**
  38579. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38580. */
  38581. keysRotationOffsetModifierCtrl: boolean;
  38582. /**
  38583. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38584. */
  38585. keysRotationOffsetModifierShift: boolean;
  38586. /**
  38587. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38588. */
  38589. keysRadiusIncr: number[];
  38590. /**
  38591. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38592. */
  38593. keysRadiusDecr: number[];
  38594. /**
  38595. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38596. */
  38597. keysRadiusModifierAlt: boolean;
  38598. /**
  38599. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38600. */
  38601. keysRadiusModifierCtrl: boolean;
  38602. /**
  38603. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38604. */
  38605. keysRadiusModifierShift: boolean;
  38606. /**
  38607. * Defines the rate of change of heightOffset.
  38608. */
  38609. heightSensibility: number;
  38610. /**
  38611. * Defines the rate of change of rotationOffset.
  38612. */
  38613. rotationSensibility: number;
  38614. /**
  38615. * Defines the rate of change of radius.
  38616. */
  38617. radiusSensibility: number;
  38618. private _keys;
  38619. private _ctrlPressed;
  38620. private _altPressed;
  38621. private _shiftPressed;
  38622. private _onCanvasBlurObserver;
  38623. private _onKeyboardObserver;
  38624. private _engine;
  38625. private _scene;
  38626. /**
  38627. * Attach the input controls to a specific dom element to get the input from.
  38628. * @param element Defines the element the controls should be listened from
  38629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38630. */
  38631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38632. /**
  38633. * Detach the current controls from the specified dom element.
  38634. * @param element Defines the element to stop listening the inputs from
  38635. */
  38636. detachControl(element: Nullable<HTMLElement>): void;
  38637. /**
  38638. * Update the current camera state depending on the inputs that have been used this frame.
  38639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38640. */
  38641. checkInputs(): void;
  38642. /**
  38643. * Gets the class name of the current input.
  38644. * @returns the class name
  38645. */
  38646. getClassName(): string;
  38647. /**
  38648. * Get the friendly name associated with the input class.
  38649. * @returns the input friendly name
  38650. */
  38651. getSimpleName(): string;
  38652. /**
  38653. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38654. * allow modification of the heightOffset value.
  38655. */
  38656. private _modifierHeightOffset;
  38657. /**
  38658. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38659. * allow modification of the rotationOffset value.
  38660. */
  38661. private _modifierRotationOffset;
  38662. /**
  38663. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38664. * allow modification of the radius value.
  38665. */
  38666. private _modifierRadius;
  38667. }
  38668. }
  38669. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38670. import { Nullable } from "babylonjs/types";
  38671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38672. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38673. import { Observable } from "babylonjs/Misc/observable";
  38674. module "babylonjs/Cameras/freeCameraInputsManager" {
  38675. interface FreeCameraInputsManager {
  38676. /**
  38677. * @hidden
  38678. */
  38679. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38680. /**
  38681. * Add orientation input support to the input manager.
  38682. * @returns the current input manager
  38683. */
  38684. addDeviceOrientation(): FreeCameraInputsManager;
  38685. }
  38686. }
  38687. /**
  38688. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38689. * Screen rotation is taken into account.
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38693. private _camera;
  38694. private _screenOrientationAngle;
  38695. private _constantTranform;
  38696. private _screenQuaternion;
  38697. private _alpha;
  38698. private _beta;
  38699. private _gamma;
  38700. /**
  38701. * Can be used to detect if a device orientation sensor is availible on a device
  38702. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38703. * @returns a promise that will resolve on orientation change
  38704. */
  38705. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38706. /**
  38707. * @hidden
  38708. */
  38709. _onDeviceOrientationChangedObservable: Observable<void>;
  38710. /**
  38711. * Instantiates a new input
  38712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38713. */
  38714. constructor();
  38715. /**
  38716. * Define the camera controlled by the input.
  38717. */
  38718. camera: FreeCamera;
  38719. /**
  38720. * Attach the input controls to a specific dom element to get the input from.
  38721. * @param element Defines the element the controls should be listened from
  38722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38723. */
  38724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38725. private _orientationChanged;
  38726. private _deviceOrientation;
  38727. /**
  38728. * Detach the current controls from the specified dom element.
  38729. * @param element Defines the element to stop listening the inputs from
  38730. */
  38731. detachControl(element: Nullable<HTMLElement>): void;
  38732. /**
  38733. * Update the current camera state depending on the inputs that have been used this frame.
  38734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38735. */
  38736. checkInputs(): void;
  38737. /**
  38738. * Gets the class name of the current intput.
  38739. * @returns the class name
  38740. */
  38741. getClassName(): string;
  38742. /**
  38743. * Get the friendly name associated with the input class.
  38744. * @returns the input friendly name
  38745. */
  38746. getSimpleName(): string;
  38747. }
  38748. }
  38749. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38750. import { Nullable } from "babylonjs/types";
  38751. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38752. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38753. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38754. /**
  38755. * Manage the gamepad inputs to control a free camera.
  38756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38757. */
  38758. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38759. /**
  38760. * Define the camera the input is attached to.
  38761. */
  38762. camera: FreeCamera;
  38763. /**
  38764. * Define the Gamepad controlling the input
  38765. */
  38766. gamepad: Nullable<Gamepad>;
  38767. /**
  38768. * Defines the gamepad rotation sensiblity.
  38769. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38770. */
  38771. gamepadAngularSensibility: number;
  38772. /**
  38773. * Defines the gamepad move sensiblity.
  38774. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38775. */
  38776. gamepadMoveSensibility: number;
  38777. private _onGamepadConnectedObserver;
  38778. private _onGamepadDisconnectedObserver;
  38779. private _cameraTransform;
  38780. private _deltaTransform;
  38781. private _vector3;
  38782. private _vector2;
  38783. /**
  38784. * Attach the input controls to a specific dom element to get the input from.
  38785. * @param element Defines the element the controls should be listened from
  38786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38787. */
  38788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38789. /**
  38790. * Detach the current controls from the specified dom element.
  38791. * @param element Defines the element to stop listening the inputs from
  38792. */
  38793. detachControl(element: Nullable<HTMLElement>): void;
  38794. /**
  38795. * Update the current camera state depending on the inputs that have been used this frame.
  38796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38797. */
  38798. checkInputs(): void;
  38799. /**
  38800. * Gets the class name of the current intput.
  38801. * @returns the class name
  38802. */
  38803. getClassName(): string;
  38804. /**
  38805. * Get the friendly name associated with the input class.
  38806. * @returns the input friendly name
  38807. */
  38808. getSimpleName(): string;
  38809. }
  38810. }
  38811. declare module "babylonjs/Misc/virtualJoystick" {
  38812. import { Nullable } from "babylonjs/types";
  38813. import { Vector3 } from "babylonjs/Maths/math";
  38814. /**
  38815. * Defines the potential axis of a Joystick
  38816. */
  38817. export enum JoystickAxis {
  38818. /** X axis */
  38819. X = 0,
  38820. /** Y axis */
  38821. Y = 1,
  38822. /** Z axis */
  38823. Z = 2
  38824. }
  38825. /**
  38826. * Class used to define virtual joystick (used in touch mode)
  38827. */
  38828. export class VirtualJoystick {
  38829. /**
  38830. * Gets or sets a boolean indicating that left and right values must be inverted
  38831. */
  38832. reverseLeftRight: boolean;
  38833. /**
  38834. * Gets or sets a boolean indicating that up and down values must be inverted
  38835. */
  38836. reverseUpDown: boolean;
  38837. /**
  38838. * Gets the offset value for the position (ie. the change of the position value)
  38839. */
  38840. deltaPosition: Vector3;
  38841. /**
  38842. * Gets a boolean indicating if the virtual joystick was pressed
  38843. */
  38844. pressed: boolean;
  38845. /**
  38846. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38847. */
  38848. static Canvas: Nullable<HTMLCanvasElement>;
  38849. private static _globalJoystickIndex;
  38850. private static vjCanvasContext;
  38851. private static vjCanvasWidth;
  38852. private static vjCanvasHeight;
  38853. private static halfWidth;
  38854. private _action;
  38855. private _axisTargetedByLeftAndRight;
  38856. private _axisTargetedByUpAndDown;
  38857. private _joystickSensibility;
  38858. private _inversedSensibility;
  38859. private _joystickPointerID;
  38860. private _joystickColor;
  38861. private _joystickPointerPos;
  38862. private _joystickPreviousPointerPos;
  38863. private _joystickPointerStartPos;
  38864. private _deltaJoystickVector;
  38865. private _leftJoystick;
  38866. private _touches;
  38867. private _onPointerDownHandlerRef;
  38868. private _onPointerMoveHandlerRef;
  38869. private _onPointerUpHandlerRef;
  38870. private _onResize;
  38871. /**
  38872. * Creates a new virtual joystick
  38873. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38874. */
  38875. constructor(leftJoystick?: boolean);
  38876. /**
  38877. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38878. * @param newJoystickSensibility defines the new sensibility
  38879. */
  38880. setJoystickSensibility(newJoystickSensibility: number): void;
  38881. private _onPointerDown;
  38882. private _onPointerMove;
  38883. private _onPointerUp;
  38884. /**
  38885. * Change the color of the virtual joystick
  38886. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38887. */
  38888. setJoystickColor(newColor: string): void;
  38889. /**
  38890. * Defines a callback to call when the joystick is touched
  38891. * @param action defines the callback
  38892. */
  38893. setActionOnTouch(action: () => any): void;
  38894. /**
  38895. * Defines which axis you'd like to control for left & right
  38896. * @param axis defines the axis to use
  38897. */
  38898. setAxisForLeftRight(axis: JoystickAxis): void;
  38899. /**
  38900. * Defines which axis you'd like to control for up & down
  38901. * @param axis defines the axis to use
  38902. */
  38903. setAxisForUpDown(axis: JoystickAxis): void;
  38904. private _drawVirtualJoystick;
  38905. /**
  38906. * Release internal HTML canvas
  38907. */
  38908. releaseCanvas(): void;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38912. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38913. import { Nullable } from "babylonjs/types";
  38914. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38916. module "babylonjs/Cameras/freeCameraInputsManager" {
  38917. interface FreeCameraInputsManager {
  38918. /**
  38919. * Add virtual joystick input support to the input manager.
  38920. * @returns the current input manager
  38921. */
  38922. addVirtualJoystick(): FreeCameraInputsManager;
  38923. }
  38924. }
  38925. /**
  38926. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38928. */
  38929. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38930. /**
  38931. * Defines the camera the input is attached to.
  38932. */
  38933. camera: FreeCamera;
  38934. private _leftjoystick;
  38935. private _rightjoystick;
  38936. /**
  38937. * Gets the left stick of the virtual joystick.
  38938. * @returns The virtual Joystick
  38939. */
  38940. getLeftJoystick(): VirtualJoystick;
  38941. /**
  38942. * Gets the right stick of the virtual joystick.
  38943. * @returns The virtual Joystick
  38944. */
  38945. getRightJoystick(): VirtualJoystick;
  38946. /**
  38947. * Update the current camera state depending on the inputs that have been used this frame.
  38948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38949. */
  38950. checkInputs(): void;
  38951. /**
  38952. * Attach the input controls to a specific dom element to get the input from.
  38953. * @param element Defines the element the controls should be listened from
  38954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38955. */
  38956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38957. /**
  38958. * Detach the current controls from the specified dom element.
  38959. * @param element Defines the element to stop listening the inputs from
  38960. */
  38961. detachControl(element: Nullable<HTMLElement>): void;
  38962. /**
  38963. * Gets the class name of the current intput.
  38964. * @returns the class name
  38965. */
  38966. getClassName(): string;
  38967. /**
  38968. * Get the friendly name associated with the input class.
  38969. * @returns the input friendly name
  38970. */
  38971. getSimpleName(): string;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/Inputs/index" {
  38975. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38976. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38977. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38978. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38979. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38980. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38981. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38982. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38983. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38984. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38985. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38986. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38987. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38988. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38989. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38990. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38991. }
  38992. declare module "babylonjs/Cameras/touchCamera" {
  38993. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38994. import { Scene } from "babylonjs/scene";
  38995. import { Vector3 } from "babylonjs/Maths/math";
  38996. /**
  38997. * This represents a FPS type of camera controlled by touch.
  38998. * This is like a universal camera minus the Gamepad controls.
  38999. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39000. */
  39001. export class TouchCamera extends FreeCamera {
  39002. /**
  39003. * Defines the touch sensibility for rotation.
  39004. * The higher the faster.
  39005. */
  39006. touchAngularSensibility: number;
  39007. /**
  39008. * Defines the touch sensibility for move.
  39009. * The higher the faster.
  39010. */
  39011. touchMoveSensibility: number;
  39012. /**
  39013. * Instantiates a new touch camera.
  39014. * This represents a FPS type of camera controlled by touch.
  39015. * This is like a universal camera minus the Gamepad controls.
  39016. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39017. * @param name Define the name of the camera in the scene
  39018. * @param position Define the start position of the camera in the scene
  39019. * @param scene Define the scene the camera belongs to
  39020. */
  39021. constructor(name: string, position: Vector3, scene: Scene);
  39022. /**
  39023. * Gets the current object class name.
  39024. * @return the class name
  39025. */
  39026. getClassName(): string;
  39027. /** @hidden */
  39028. _setupInputs(): void;
  39029. }
  39030. }
  39031. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39032. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39033. import { Scene } from "babylonjs/scene";
  39034. import { Vector3, Axis } from "babylonjs/Maths/math";
  39035. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39036. /**
  39037. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39038. * being tilted forward or back and left or right.
  39039. */
  39040. export class DeviceOrientationCamera extends FreeCamera {
  39041. private _initialQuaternion;
  39042. private _quaternionCache;
  39043. private _tmpDragQuaternion;
  39044. /**
  39045. * Creates a new device orientation camera
  39046. * @param name The name of the camera
  39047. * @param position The start position camera
  39048. * @param scene The scene the camera belongs to
  39049. */
  39050. constructor(name: string, position: Vector3, scene: Scene);
  39051. /**
  39052. * @hidden
  39053. * Disabled pointer input on first orientation sensor update (Default: true)
  39054. */
  39055. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39056. private _dragFactor;
  39057. /**
  39058. * Enabled turning on the y axis when the orientation sensor is active
  39059. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39060. */
  39061. enableHorizontalDragging(dragFactor?: number): void;
  39062. /**
  39063. * Gets the current instance class name ("DeviceOrientationCamera").
  39064. * This helps avoiding instanceof at run time.
  39065. * @returns the class name
  39066. */
  39067. getClassName(): string;
  39068. /**
  39069. * @hidden
  39070. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39071. */
  39072. _checkInputs(): void;
  39073. /**
  39074. * Reset the camera to its default orientation on the specified axis only.
  39075. * @param axis The axis to reset
  39076. */
  39077. resetToCurrentRotation(axis?: Axis): void;
  39078. }
  39079. }
  39080. declare module "babylonjs/Gamepads/xboxGamepad" {
  39081. import { Observable } from "babylonjs/Misc/observable";
  39082. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39083. /**
  39084. * Defines supported buttons for XBox360 compatible gamepads
  39085. */
  39086. export enum Xbox360Button {
  39087. /** A */
  39088. A = 0,
  39089. /** B */
  39090. B = 1,
  39091. /** X */
  39092. X = 2,
  39093. /** Y */
  39094. Y = 3,
  39095. /** Start */
  39096. Start = 4,
  39097. /** Back */
  39098. Back = 5,
  39099. /** Left button */
  39100. LB = 6,
  39101. /** Right button */
  39102. RB = 7,
  39103. /** Left stick */
  39104. LeftStick = 8,
  39105. /** Right stick */
  39106. RightStick = 9
  39107. }
  39108. /** Defines values for XBox360 DPad */
  39109. export enum Xbox360Dpad {
  39110. /** Up */
  39111. Up = 0,
  39112. /** Down */
  39113. Down = 1,
  39114. /** Left */
  39115. Left = 2,
  39116. /** Right */
  39117. Right = 3
  39118. }
  39119. /**
  39120. * Defines a XBox360 gamepad
  39121. */
  39122. export class Xbox360Pad extends Gamepad {
  39123. private _leftTrigger;
  39124. private _rightTrigger;
  39125. private _onlefttriggerchanged;
  39126. private _onrighttriggerchanged;
  39127. private _onbuttondown;
  39128. private _onbuttonup;
  39129. private _ondpaddown;
  39130. private _ondpadup;
  39131. /** Observable raised when a button is pressed */
  39132. onButtonDownObservable: Observable<Xbox360Button>;
  39133. /** Observable raised when a button is released */
  39134. onButtonUpObservable: Observable<Xbox360Button>;
  39135. /** Observable raised when a pad is pressed */
  39136. onPadDownObservable: Observable<Xbox360Dpad>;
  39137. /** Observable raised when a pad is released */
  39138. onPadUpObservable: Observable<Xbox360Dpad>;
  39139. private _buttonA;
  39140. private _buttonB;
  39141. private _buttonX;
  39142. private _buttonY;
  39143. private _buttonBack;
  39144. private _buttonStart;
  39145. private _buttonLB;
  39146. private _buttonRB;
  39147. private _buttonLeftStick;
  39148. private _buttonRightStick;
  39149. private _dPadUp;
  39150. private _dPadDown;
  39151. private _dPadLeft;
  39152. private _dPadRight;
  39153. private _isXboxOnePad;
  39154. /**
  39155. * Creates a new XBox360 gamepad object
  39156. * @param id defines the id of this gamepad
  39157. * @param index defines its index
  39158. * @param gamepad defines the internal HTML gamepad object
  39159. * @param xboxOne defines if it is a XBox One gamepad
  39160. */
  39161. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39162. /**
  39163. * Defines the callback to call when left trigger is pressed
  39164. * @param callback defines the callback to use
  39165. */
  39166. onlefttriggerchanged(callback: (value: number) => void): void;
  39167. /**
  39168. * Defines the callback to call when right trigger is pressed
  39169. * @param callback defines the callback to use
  39170. */
  39171. onrighttriggerchanged(callback: (value: number) => void): void;
  39172. /**
  39173. * Gets the left trigger value
  39174. */
  39175. /**
  39176. * Sets the left trigger value
  39177. */
  39178. leftTrigger: number;
  39179. /**
  39180. * Gets the right trigger value
  39181. */
  39182. /**
  39183. * Sets the right trigger value
  39184. */
  39185. rightTrigger: number;
  39186. /**
  39187. * Defines the callback to call when a button is pressed
  39188. * @param callback defines the callback to use
  39189. */
  39190. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39191. /**
  39192. * Defines the callback to call when a button is released
  39193. * @param callback defines the callback to use
  39194. */
  39195. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39196. /**
  39197. * Defines the callback to call when a pad is pressed
  39198. * @param callback defines the callback to use
  39199. */
  39200. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39201. /**
  39202. * Defines the callback to call when a pad is released
  39203. * @param callback defines the callback to use
  39204. */
  39205. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39206. private _setButtonValue;
  39207. private _setDPadValue;
  39208. /**
  39209. * Gets the value of the `A` button
  39210. */
  39211. /**
  39212. * Sets the value of the `A` button
  39213. */
  39214. buttonA: number;
  39215. /**
  39216. * Gets the value of the `B` button
  39217. */
  39218. /**
  39219. * Sets the value of the `B` button
  39220. */
  39221. buttonB: number;
  39222. /**
  39223. * Gets the value of the `X` button
  39224. */
  39225. /**
  39226. * Sets the value of the `X` button
  39227. */
  39228. buttonX: number;
  39229. /**
  39230. * Gets the value of the `Y` button
  39231. */
  39232. /**
  39233. * Sets the value of the `Y` button
  39234. */
  39235. buttonY: number;
  39236. /**
  39237. * Gets the value of the `Start` button
  39238. */
  39239. /**
  39240. * Sets the value of the `Start` button
  39241. */
  39242. buttonStart: number;
  39243. /**
  39244. * Gets the value of the `Back` button
  39245. */
  39246. /**
  39247. * Sets the value of the `Back` button
  39248. */
  39249. buttonBack: number;
  39250. /**
  39251. * Gets the value of the `Left` button
  39252. */
  39253. /**
  39254. * Sets the value of the `Left` button
  39255. */
  39256. buttonLB: number;
  39257. /**
  39258. * Gets the value of the `Right` button
  39259. */
  39260. /**
  39261. * Sets the value of the `Right` button
  39262. */
  39263. buttonRB: number;
  39264. /**
  39265. * Gets the value of the Left joystick
  39266. */
  39267. /**
  39268. * Sets the value of the Left joystick
  39269. */
  39270. buttonLeftStick: number;
  39271. /**
  39272. * Gets the value of the Right joystick
  39273. */
  39274. /**
  39275. * Sets the value of the Right joystick
  39276. */
  39277. buttonRightStick: number;
  39278. /**
  39279. * Gets the value of D-pad up
  39280. */
  39281. /**
  39282. * Sets the value of D-pad up
  39283. */
  39284. dPadUp: number;
  39285. /**
  39286. * Gets the value of D-pad down
  39287. */
  39288. /**
  39289. * Sets the value of D-pad down
  39290. */
  39291. dPadDown: number;
  39292. /**
  39293. * Gets the value of D-pad left
  39294. */
  39295. /**
  39296. * Sets the value of D-pad left
  39297. */
  39298. dPadLeft: number;
  39299. /**
  39300. * Gets the value of D-pad right
  39301. */
  39302. /**
  39303. * Sets the value of D-pad right
  39304. */
  39305. dPadRight: number;
  39306. /**
  39307. * Force the gamepad to synchronize with device values
  39308. */
  39309. update(): void;
  39310. /**
  39311. * Disposes the gamepad
  39312. */
  39313. dispose(): void;
  39314. }
  39315. }
  39316. declare module "babylonjs/Gamepads/gamepadManager" {
  39317. import { Observable } from "babylonjs/Misc/observable";
  39318. import { Nullable } from "babylonjs/types";
  39319. import { Scene } from "babylonjs/scene";
  39320. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39321. /**
  39322. * Manager for handling gamepads
  39323. */
  39324. export class GamepadManager {
  39325. private _scene?;
  39326. private _babylonGamepads;
  39327. private _oneGamepadConnected;
  39328. /** @hidden */
  39329. _isMonitoring: boolean;
  39330. private _gamepadEventSupported;
  39331. private _gamepadSupport;
  39332. /**
  39333. * observable to be triggered when the gamepad controller has been connected
  39334. */
  39335. onGamepadConnectedObservable: Observable<Gamepad>;
  39336. /**
  39337. * observable to be triggered when the gamepad controller has been disconnected
  39338. */
  39339. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39340. private _onGamepadConnectedEvent;
  39341. private _onGamepadDisconnectedEvent;
  39342. /**
  39343. * Initializes the gamepad manager
  39344. * @param _scene BabylonJS scene
  39345. */
  39346. constructor(_scene?: Scene | undefined);
  39347. /**
  39348. * The gamepads in the game pad manager
  39349. */
  39350. readonly gamepads: Gamepad[];
  39351. /**
  39352. * Get the gamepad controllers based on type
  39353. * @param type The type of gamepad controller
  39354. * @returns Nullable gamepad
  39355. */
  39356. getGamepadByType(type?: number): Nullable<Gamepad>;
  39357. /**
  39358. * Disposes the gamepad manager
  39359. */
  39360. dispose(): void;
  39361. private _addNewGamepad;
  39362. private _startMonitoringGamepads;
  39363. private _stopMonitoringGamepads;
  39364. /** @hidden */
  39365. _checkGamepadsStatus(): void;
  39366. private _updateGamepadObjects;
  39367. }
  39368. }
  39369. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39370. import { Nullable } from "babylonjs/types";
  39371. import { Scene } from "babylonjs/scene";
  39372. import { ISceneComponent } from "babylonjs/sceneComponent";
  39373. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39374. module "babylonjs/scene" {
  39375. interface Scene {
  39376. /** @hidden */
  39377. _gamepadManager: Nullable<GamepadManager>;
  39378. /**
  39379. * Gets the gamepad manager associated with the scene
  39380. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39381. */
  39382. gamepadManager: GamepadManager;
  39383. }
  39384. }
  39385. module "babylonjs/Cameras/freeCameraInputsManager" {
  39386. /**
  39387. * Interface representing a free camera inputs manager
  39388. */
  39389. interface FreeCameraInputsManager {
  39390. /**
  39391. * Adds gamepad input support to the FreeCameraInputsManager.
  39392. * @returns the FreeCameraInputsManager
  39393. */
  39394. addGamepad(): FreeCameraInputsManager;
  39395. }
  39396. }
  39397. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39398. /**
  39399. * Interface representing an arc rotate camera inputs manager
  39400. */
  39401. interface ArcRotateCameraInputsManager {
  39402. /**
  39403. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39404. * @returns the camera inputs manager
  39405. */
  39406. addGamepad(): ArcRotateCameraInputsManager;
  39407. }
  39408. }
  39409. /**
  39410. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39411. */
  39412. export class GamepadSystemSceneComponent implements ISceneComponent {
  39413. /**
  39414. * The component name helpfull to identify the component in the list of scene components.
  39415. */
  39416. readonly name: string;
  39417. /**
  39418. * The scene the component belongs to.
  39419. */
  39420. scene: Scene;
  39421. /**
  39422. * Creates a new instance of the component for the given scene
  39423. * @param scene Defines the scene to register the component in
  39424. */
  39425. constructor(scene: Scene);
  39426. /**
  39427. * Registers the component in a given scene
  39428. */
  39429. register(): void;
  39430. /**
  39431. * Rebuilds the elements related to this component in case of
  39432. * context lost for instance.
  39433. */
  39434. rebuild(): void;
  39435. /**
  39436. * Disposes the component and the associated ressources
  39437. */
  39438. dispose(): void;
  39439. private _beforeCameraUpdate;
  39440. }
  39441. }
  39442. declare module "babylonjs/Cameras/universalCamera" {
  39443. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39444. import { Scene } from "babylonjs/scene";
  39445. import { Vector3 } from "babylonjs/Maths/math";
  39446. import "babylonjs/Gamepads/gamepadSceneComponent";
  39447. /**
  39448. * 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,
  39449. * which still works and will still be found in many Playgrounds.
  39450. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39451. */
  39452. export class UniversalCamera extends TouchCamera {
  39453. /**
  39454. * Defines the gamepad rotation sensiblity.
  39455. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39456. */
  39457. gamepadAngularSensibility: number;
  39458. /**
  39459. * Defines the gamepad move sensiblity.
  39460. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39461. */
  39462. gamepadMoveSensibility: number;
  39463. /**
  39464. * 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,
  39465. * which still works and will still be found in many Playgrounds.
  39466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39467. * @param name Define the name of the camera in the scene
  39468. * @param position Define the start position of the camera in the scene
  39469. * @param scene Define the scene the camera belongs to
  39470. */
  39471. constructor(name: string, position: Vector3, scene: Scene);
  39472. /**
  39473. * Gets the current object class name.
  39474. * @return the class name
  39475. */
  39476. getClassName(): string;
  39477. }
  39478. }
  39479. declare module "babylonjs/Cameras/gamepadCamera" {
  39480. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39481. import { Scene } from "babylonjs/scene";
  39482. import { Vector3 } from "babylonjs/Maths/math";
  39483. /**
  39484. * This represents a FPS type of camera. This is only here for back compat purpose.
  39485. * Please use the UniversalCamera instead as both are identical.
  39486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39487. */
  39488. export class GamepadCamera extends UniversalCamera {
  39489. /**
  39490. * Instantiates a new Gamepad Camera
  39491. * This represents a FPS type of camera. This is only here for back compat purpose.
  39492. * Please use the UniversalCamera instead as both are identical.
  39493. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39494. * @param name Define the name of the camera in the scene
  39495. * @param position Define the start position of the camera in the scene
  39496. * @param scene Define the scene the camera belongs to
  39497. */
  39498. constructor(name: string, position: Vector3, scene: Scene);
  39499. /**
  39500. * Gets the current object class name.
  39501. * @return the class name
  39502. */
  39503. getClassName(): string;
  39504. }
  39505. }
  39506. declare module "babylonjs/Shaders/pass.fragment" {
  39507. /** @hidden */
  39508. export var passPixelShader: {
  39509. name: string;
  39510. shader: string;
  39511. };
  39512. }
  39513. declare module "babylonjs/Shaders/passCube.fragment" {
  39514. /** @hidden */
  39515. export var passCubePixelShader: {
  39516. name: string;
  39517. shader: string;
  39518. };
  39519. }
  39520. declare module "babylonjs/PostProcesses/passPostProcess" {
  39521. import { Nullable } from "babylonjs/types";
  39522. import { Camera } from "babylonjs/Cameras/camera";
  39523. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39524. import { Engine } from "babylonjs/Engines/engine";
  39525. import "babylonjs/Shaders/pass.fragment";
  39526. import "babylonjs/Shaders/passCube.fragment";
  39527. /**
  39528. * PassPostProcess which produces an output the same as it's input
  39529. */
  39530. export class PassPostProcess extends PostProcess {
  39531. /**
  39532. * Creates the PassPostProcess
  39533. * @param name The name of the effect.
  39534. * @param options The required width/height ratio to downsize to before computing the render pass.
  39535. * @param camera The camera to apply the render pass to.
  39536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39537. * @param engine The engine which the post process will be applied. (default: current engine)
  39538. * @param reusable If the post process can be reused on the same frame. (default: false)
  39539. * @param textureType The type of texture to be used when performing the post processing.
  39540. * @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)
  39541. */
  39542. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39543. }
  39544. /**
  39545. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39546. */
  39547. export class PassCubePostProcess extends PostProcess {
  39548. private _face;
  39549. /**
  39550. * Gets or sets the cube face to display.
  39551. * * 0 is +X
  39552. * * 1 is -X
  39553. * * 2 is +Y
  39554. * * 3 is -Y
  39555. * * 4 is +Z
  39556. * * 5 is -Z
  39557. */
  39558. face: number;
  39559. /**
  39560. * Creates the PassCubePostProcess
  39561. * @param name The name of the effect.
  39562. * @param options The required width/height ratio to downsize to before computing the render pass.
  39563. * @param camera The camera to apply the render pass to.
  39564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39565. * @param engine The engine which the post process will be applied. (default: current engine)
  39566. * @param reusable If the post process can be reused on the same frame. (default: false)
  39567. * @param textureType The type of texture to be used when performing the post processing.
  39568. * @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)
  39569. */
  39570. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39571. }
  39572. }
  39573. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39574. /** @hidden */
  39575. export var anaglyphPixelShader: {
  39576. name: string;
  39577. shader: string;
  39578. };
  39579. }
  39580. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39581. import { Engine } from "babylonjs/Engines/engine";
  39582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39583. import { Camera } from "babylonjs/Cameras/camera";
  39584. import "babylonjs/Shaders/anaglyph.fragment";
  39585. /**
  39586. * Postprocess used to generate anaglyphic rendering
  39587. */
  39588. export class AnaglyphPostProcess extends PostProcess {
  39589. private _passedProcess;
  39590. /**
  39591. * Creates a new AnaglyphPostProcess
  39592. * @param name defines postprocess name
  39593. * @param options defines creation options or target ratio scale
  39594. * @param rigCameras defines cameras using this postprocess
  39595. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39596. * @param engine defines hosting engine
  39597. * @param reusable defines if the postprocess will be reused multiple times per frame
  39598. */
  39599. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39600. }
  39601. }
  39602. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39603. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39604. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39605. import { Scene } from "babylonjs/scene";
  39606. import { Vector3 } from "babylonjs/Maths/math";
  39607. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39608. /**
  39609. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39610. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39611. */
  39612. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39613. /**
  39614. * Creates a new AnaglyphArcRotateCamera
  39615. * @param name defines camera name
  39616. * @param alpha defines alpha angle (in radians)
  39617. * @param beta defines beta angle (in radians)
  39618. * @param radius defines radius
  39619. * @param target defines camera target
  39620. * @param interaxialDistance defines distance between each color axis
  39621. * @param scene defines the hosting scene
  39622. */
  39623. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39624. /**
  39625. * Gets camera class name
  39626. * @returns AnaglyphArcRotateCamera
  39627. */
  39628. getClassName(): string;
  39629. }
  39630. }
  39631. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39633. import { Scene } from "babylonjs/scene";
  39634. import { Vector3 } from "babylonjs/Maths/math";
  39635. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39636. /**
  39637. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39638. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39639. */
  39640. export class AnaglyphFreeCamera extends FreeCamera {
  39641. /**
  39642. * Creates a new AnaglyphFreeCamera
  39643. * @param name defines camera name
  39644. * @param position defines initial position
  39645. * @param interaxialDistance defines distance between each color axis
  39646. * @param scene defines the hosting scene
  39647. */
  39648. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39649. /**
  39650. * Gets camera class name
  39651. * @returns AnaglyphFreeCamera
  39652. */
  39653. getClassName(): string;
  39654. }
  39655. }
  39656. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39657. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39658. import { Scene } from "babylonjs/scene";
  39659. import { Vector3 } from "babylonjs/Maths/math";
  39660. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39661. /**
  39662. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39663. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39664. */
  39665. export class AnaglyphGamepadCamera extends GamepadCamera {
  39666. /**
  39667. * Creates a new AnaglyphGamepadCamera
  39668. * @param name defines camera name
  39669. * @param position defines initial position
  39670. * @param interaxialDistance defines distance between each color axis
  39671. * @param scene defines the hosting scene
  39672. */
  39673. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39674. /**
  39675. * Gets camera class name
  39676. * @returns AnaglyphGamepadCamera
  39677. */
  39678. getClassName(): string;
  39679. }
  39680. }
  39681. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39682. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39683. import { Scene } from "babylonjs/scene";
  39684. import { Vector3 } from "babylonjs/Maths/math";
  39685. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39686. /**
  39687. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39688. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39689. */
  39690. export class AnaglyphUniversalCamera extends UniversalCamera {
  39691. /**
  39692. * Creates a new AnaglyphUniversalCamera
  39693. * @param name defines camera name
  39694. * @param position defines initial position
  39695. * @param interaxialDistance defines distance between each color axis
  39696. * @param scene defines the hosting scene
  39697. */
  39698. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39699. /**
  39700. * Gets camera class name
  39701. * @returns AnaglyphUniversalCamera
  39702. */
  39703. getClassName(): string;
  39704. }
  39705. }
  39706. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39707. /** @hidden */
  39708. export var stereoscopicInterlacePixelShader: {
  39709. name: string;
  39710. shader: string;
  39711. };
  39712. }
  39713. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39714. import { Camera } from "babylonjs/Cameras/camera";
  39715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39716. import { Engine } from "babylonjs/Engines/engine";
  39717. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39718. /**
  39719. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39720. */
  39721. export class StereoscopicInterlacePostProcess extends PostProcess {
  39722. private _stepSize;
  39723. private _passedProcess;
  39724. /**
  39725. * Initializes a StereoscopicInterlacePostProcess
  39726. * @param name The name of the effect.
  39727. * @param rigCameras The rig cameras to be appled to the post process
  39728. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39730. * @param engine The engine which the post process will be applied. (default: current engine)
  39731. * @param reusable If the post process can be reused on the same frame. (default: false)
  39732. */
  39733. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39734. }
  39735. }
  39736. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39737. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39738. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39739. import { Scene } from "babylonjs/scene";
  39740. import { Vector3 } from "babylonjs/Maths/math";
  39741. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39742. /**
  39743. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39744. * @see http://doc.babylonjs.com/features/cameras
  39745. */
  39746. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39747. /**
  39748. * Creates a new StereoscopicArcRotateCamera
  39749. * @param name defines camera name
  39750. * @param alpha defines alpha angle (in radians)
  39751. * @param beta defines beta angle (in radians)
  39752. * @param radius defines radius
  39753. * @param target defines camera target
  39754. * @param interaxialDistance defines distance between each color axis
  39755. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39756. * @param scene defines the hosting scene
  39757. */
  39758. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39759. /**
  39760. * Gets camera class name
  39761. * @returns StereoscopicArcRotateCamera
  39762. */
  39763. getClassName(): string;
  39764. }
  39765. }
  39766. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39768. import { Scene } from "babylonjs/scene";
  39769. import { Vector3 } from "babylonjs/Maths/math";
  39770. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39771. /**
  39772. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39773. * @see http://doc.babylonjs.com/features/cameras
  39774. */
  39775. export class StereoscopicFreeCamera extends FreeCamera {
  39776. /**
  39777. * Creates a new StereoscopicFreeCamera
  39778. * @param name defines camera name
  39779. * @param position defines initial position
  39780. * @param interaxialDistance defines distance between each color axis
  39781. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39782. * @param scene defines the hosting scene
  39783. */
  39784. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39785. /**
  39786. * Gets camera class name
  39787. * @returns StereoscopicFreeCamera
  39788. */
  39789. getClassName(): string;
  39790. }
  39791. }
  39792. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39793. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39794. import { Scene } from "babylonjs/scene";
  39795. import { Vector3 } from "babylonjs/Maths/math";
  39796. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39797. /**
  39798. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39799. * @see http://doc.babylonjs.com/features/cameras
  39800. */
  39801. export class StereoscopicGamepadCamera extends GamepadCamera {
  39802. /**
  39803. * Creates a new StereoscopicGamepadCamera
  39804. * @param name defines camera name
  39805. * @param position defines initial position
  39806. * @param interaxialDistance defines distance between each color axis
  39807. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39808. * @param scene defines the hosting scene
  39809. */
  39810. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39811. /**
  39812. * Gets camera class name
  39813. * @returns StereoscopicGamepadCamera
  39814. */
  39815. getClassName(): string;
  39816. }
  39817. }
  39818. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39819. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39820. import { Scene } from "babylonjs/scene";
  39821. import { Vector3 } from "babylonjs/Maths/math";
  39822. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39823. /**
  39824. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39825. * @see http://doc.babylonjs.com/features/cameras
  39826. */
  39827. export class StereoscopicUniversalCamera extends UniversalCamera {
  39828. /**
  39829. * Creates a new StereoscopicUniversalCamera
  39830. * @param name defines camera name
  39831. * @param position defines initial position
  39832. * @param interaxialDistance defines distance between each color axis
  39833. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39834. * @param scene defines the hosting scene
  39835. */
  39836. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39837. /**
  39838. * Gets camera class name
  39839. * @returns StereoscopicUniversalCamera
  39840. */
  39841. getClassName(): string;
  39842. }
  39843. }
  39844. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39845. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39846. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39847. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39848. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39849. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39850. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39851. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39852. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39853. }
  39854. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39856. import { Scene } from "babylonjs/scene";
  39857. import { Vector3 } from "babylonjs/Maths/math";
  39858. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39859. /**
  39860. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39861. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39862. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39863. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39864. */
  39865. export class VirtualJoysticksCamera extends FreeCamera {
  39866. /**
  39867. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39868. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39869. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39870. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39871. * @param name Define the name of the camera in the scene
  39872. * @param position Define the start position of the camera in the scene
  39873. * @param scene Define the scene the camera belongs to
  39874. */
  39875. constructor(name: string, position: Vector3, scene: Scene);
  39876. /**
  39877. * Gets the current object class name.
  39878. * @return the class name
  39879. */
  39880. getClassName(): string;
  39881. }
  39882. }
  39883. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39884. import { Matrix } from "babylonjs/Maths/math";
  39885. /**
  39886. * This represents all the required metrics to create a VR camera.
  39887. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39888. */
  39889. export class VRCameraMetrics {
  39890. /**
  39891. * Define the horizontal resolution off the screen.
  39892. */
  39893. hResolution: number;
  39894. /**
  39895. * Define the vertical resolution off the screen.
  39896. */
  39897. vResolution: number;
  39898. /**
  39899. * Define the horizontal screen size.
  39900. */
  39901. hScreenSize: number;
  39902. /**
  39903. * Define the vertical screen size.
  39904. */
  39905. vScreenSize: number;
  39906. /**
  39907. * Define the vertical screen center position.
  39908. */
  39909. vScreenCenter: number;
  39910. /**
  39911. * Define the distance of the eyes to the screen.
  39912. */
  39913. eyeToScreenDistance: number;
  39914. /**
  39915. * Define the distance between both lenses
  39916. */
  39917. lensSeparationDistance: number;
  39918. /**
  39919. * Define the distance between both viewer's eyes.
  39920. */
  39921. interpupillaryDistance: number;
  39922. /**
  39923. * Define the distortion factor of the VR postprocess.
  39924. * Please, touch with care.
  39925. */
  39926. distortionK: number[];
  39927. /**
  39928. * Define the chromatic aberration correction factors for the VR post process.
  39929. */
  39930. chromaAbCorrection: number[];
  39931. /**
  39932. * Define the scale factor of the post process.
  39933. * The smaller the better but the slower.
  39934. */
  39935. postProcessScaleFactor: number;
  39936. /**
  39937. * Define an offset for the lens center.
  39938. */
  39939. lensCenterOffset: number;
  39940. /**
  39941. * Define if the current vr camera should compensate the distortion of the lense or not.
  39942. */
  39943. compensateDistortion: boolean;
  39944. /**
  39945. * Defines if multiview should be enabled when rendering (Default: false)
  39946. */
  39947. multiviewEnabled: boolean;
  39948. /**
  39949. * Gets the rendering aspect ratio based on the provided resolutions.
  39950. */
  39951. readonly aspectRatio: number;
  39952. /**
  39953. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39954. */
  39955. readonly aspectRatioFov: number;
  39956. /**
  39957. * @hidden
  39958. */
  39959. readonly leftHMatrix: Matrix;
  39960. /**
  39961. * @hidden
  39962. */
  39963. readonly rightHMatrix: Matrix;
  39964. /**
  39965. * @hidden
  39966. */
  39967. readonly leftPreViewMatrix: Matrix;
  39968. /**
  39969. * @hidden
  39970. */
  39971. readonly rightPreViewMatrix: Matrix;
  39972. /**
  39973. * Get the default VRMetrics based on the most generic setup.
  39974. * @returns the default vr metrics
  39975. */
  39976. static GetDefault(): VRCameraMetrics;
  39977. }
  39978. }
  39979. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39980. /** @hidden */
  39981. export var vrDistortionCorrectionPixelShader: {
  39982. name: string;
  39983. shader: string;
  39984. };
  39985. }
  39986. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39987. import { Camera } from "babylonjs/Cameras/camera";
  39988. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39990. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39991. /**
  39992. * VRDistortionCorrectionPostProcess used for mobile VR
  39993. */
  39994. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39995. private _isRightEye;
  39996. private _distortionFactors;
  39997. private _postProcessScaleFactor;
  39998. private _lensCenterOffset;
  39999. private _scaleIn;
  40000. private _scaleFactor;
  40001. private _lensCenter;
  40002. /**
  40003. * Initializes the VRDistortionCorrectionPostProcess
  40004. * @param name The name of the effect.
  40005. * @param camera The camera to apply the render pass to.
  40006. * @param isRightEye If this is for the right eye distortion
  40007. * @param vrMetrics All the required metrics for the VR camera
  40008. */
  40009. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40010. }
  40011. }
  40012. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40013. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40014. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40015. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40016. import { Scene } from "babylonjs/scene";
  40017. import { Vector3 } from "babylonjs/Maths/math";
  40018. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40019. import "babylonjs/Cameras/RigModes/vrRigMode";
  40020. /**
  40021. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40023. */
  40024. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40025. /**
  40026. * Creates a new VRDeviceOrientationArcRotateCamera
  40027. * @param name defines camera name
  40028. * @param alpha defines the camera rotation along the logitudinal axis
  40029. * @param beta defines the camera rotation along the latitudinal axis
  40030. * @param radius defines the camera distance from its target
  40031. * @param target defines the camera target
  40032. * @param scene defines the scene the camera belongs to
  40033. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40034. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40035. */
  40036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40037. /**
  40038. * Gets camera class name
  40039. * @returns VRDeviceOrientationArcRotateCamera
  40040. */
  40041. getClassName(): string;
  40042. }
  40043. }
  40044. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40045. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40046. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector3 } from "babylonjs/Maths/math";
  40049. import "babylonjs/Cameras/RigModes/vrRigMode";
  40050. /**
  40051. * Camera used to simulate VR rendering (based on FreeCamera)
  40052. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40053. */
  40054. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40055. /**
  40056. * Creates a new VRDeviceOrientationFreeCamera
  40057. * @param name defines camera name
  40058. * @param position defines the start position of the camera
  40059. * @param scene defines the scene the camera belongs to
  40060. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40061. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40062. */
  40063. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40064. /**
  40065. * Gets camera class name
  40066. * @returns VRDeviceOrientationFreeCamera
  40067. */
  40068. getClassName(): string;
  40069. }
  40070. }
  40071. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40072. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40073. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40074. import { Scene } from "babylonjs/scene";
  40075. import { Vector3 } from "babylonjs/Maths/math";
  40076. import "babylonjs/Gamepads/gamepadSceneComponent";
  40077. /**
  40078. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40079. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40080. */
  40081. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40082. /**
  40083. * Creates a new VRDeviceOrientationGamepadCamera
  40084. * @param name defines camera name
  40085. * @param position defines the start position of the camera
  40086. * @param scene defines the scene the camera belongs to
  40087. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40088. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40089. */
  40090. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40091. /**
  40092. * Gets camera class name
  40093. * @returns VRDeviceOrientationGamepadCamera
  40094. */
  40095. getClassName(): string;
  40096. }
  40097. }
  40098. declare module "babylonjs/Materials/pushMaterial" {
  40099. import { Nullable } from "babylonjs/types";
  40100. import { Scene } from "babylonjs/scene";
  40101. import { Matrix } from "babylonjs/Maths/math";
  40102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40103. import { Mesh } from "babylonjs/Meshes/mesh";
  40104. import { Material } from "babylonjs/Materials/material";
  40105. import { Effect } from "babylonjs/Materials/effect";
  40106. /**
  40107. * Base class of materials working in push mode in babylon JS
  40108. * @hidden
  40109. */
  40110. export class PushMaterial extends Material {
  40111. protected _activeEffect: Effect;
  40112. protected _normalMatrix: Matrix;
  40113. /**
  40114. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40115. * This means that the material can keep using a previous shader while a new one is being compiled.
  40116. * This is mostly used when shader parallel compilation is supported (true by default)
  40117. */
  40118. allowShaderHotSwapping: boolean;
  40119. constructor(name: string, scene: Scene);
  40120. getEffect(): Effect;
  40121. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40122. /**
  40123. * Binds the given world matrix to the active effect
  40124. *
  40125. * @param world the matrix to bind
  40126. */
  40127. bindOnlyWorldMatrix(world: Matrix): void;
  40128. /**
  40129. * Binds the given normal matrix to the active effect
  40130. *
  40131. * @param normalMatrix the matrix to bind
  40132. */
  40133. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40134. bind(world: Matrix, mesh?: Mesh): void;
  40135. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40136. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40137. }
  40138. }
  40139. declare module "babylonjs/Materials/materialFlags" {
  40140. /**
  40141. * This groups all the flags used to control the materials channel.
  40142. */
  40143. export class MaterialFlags {
  40144. private static _DiffuseTextureEnabled;
  40145. /**
  40146. * Are diffuse textures enabled in the application.
  40147. */
  40148. static DiffuseTextureEnabled: boolean;
  40149. private static _AmbientTextureEnabled;
  40150. /**
  40151. * Are ambient textures enabled in the application.
  40152. */
  40153. static AmbientTextureEnabled: boolean;
  40154. private static _OpacityTextureEnabled;
  40155. /**
  40156. * Are opacity textures enabled in the application.
  40157. */
  40158. static OpacityTextureEnabled: boolean;
  40159. private static _ReflectionTextureEnabled;
  40160. /**
  40161. * Are reflection textures enabled in the application.
  40162. */
  40163. static ReflectionTextureEnabled: boolean;
  40164. private static _EmissiveTextureEnabled;
  40165. /**
  40166. * Are emissive textures enabled in the application.
  40167. */
  40168. static EmissiveTextureEnabled: boolean;
  40169. private static _SpecularTextureEnabled;
  40170. /**
  40171. * Are specular textures enabled in the application.
  40172. */
  40173. static SpecularTextureEnabled: boolean;
  40174. private static _BumpTextureEnabled;
  40175. /**
  40176. * Are bump textures enabled in the application.
  40177. */
  40178. static BumpTextureEnabled: boolean;
  40179. private static _LightmapTextureEnabled;
  40180. /**
  40181. * Are lightmap textures enabled in the application.
  40182. */
  40183. static LightmapTextureEnabled: boolean;
  40184. private static _RefractionTextureEnabled;
  40185. /**
  40186. * Are refraction textures enabled in the application.
  40187. */
  40188. static RefractionTextureEnabled: boolean;
  40189. private static _ColorGradingTextureEnabled;
  40190. /**
  40191. * Are color grading textures enabled in the application.
  40192. */
  40193. static ColorGradingTextureEnabled: boolean;
  40194. private static _FresnelEnabled;
  40195. /**
  40196. * Are fresnels enabled in the application.
  40197. */
  40198. static FresnelEnabled: boolean;
  40199. private static _ClearCoatTextureEnabled;
  40200. /**
  40201. * Are clear coat textures enabled in the application.
  40202. */
  40203. static ClearCoatTextureEnabled: boolean;
  40204. private static _ClearCoatBumpTextureEnabled;
  40205. /**
  40206. * Are clear coat bump textures enabled in the application.
  40207. */
  40208. static ClearCoatBumpTextureEnabled: boolean;
  40209. private static _ClearCoatTintTextureEnabled;
  40210. /**
  40211. * Are clear coat tint textures enabled in the application.
  40212. */
  40213. static ClearCoatTintTextureEnabled: boolean;
  40214. private static _SheenTextureEnabled;
  40215. /**
  40216. * Are sheen textures enabled in the application.
  40217. */
  40218. static SheenTextureEnabled: boolean;
  40219. private static _AnisotropicTextureEnabled;
  40220. /**
  40221. * Are anisotropic textures enabled in the application.
  40222. */
  40223. static AnisotropicTextureEnabled: boolean;
  40224. private static _ThicknessTextureEnabled;
  40225. /**
  40226. * Are thickness textures enabled in the application.
  40227. */
  40228. static ThicknessTextureEnabled: boolean;
  40229. }
  40230. }
  40231. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40232. /** @hidden */
  40233. export var defaultFragmentDeclaration: {
  40234. name: string;
  40235. shader: string;
  40236. };
  40237. }
  40238. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40239. /** @hidden */
  40240. export var defaultUboDeclaration: {
  40241. name: string;
  40242. shader: string;
  40243. };
  40244. }
  40245. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40246. /** @hidden */
  40247. export var lightFragmentDeclaration: {
  40248. name: string;
  40249. shader: string;
  40250. };
  40251. }
  40252. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40253. /** @hidden */
  40254. export var lightUboDeclaration: {
  40255. name: string;
  40256. shader: string;
  40257. };
  40258. }
  40259. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40260. /** @hidden */
  40261. export var lightsFragmentFunctions: {
  40262. name: string;
  40263. shader: string;
  40264. };
  40265. }
  40266. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40267. /** @hidden */
  40268. export var shadowsFragmentFunctions: {
  40269. name: string;
  40270. shader: string;
  40271. };
  40272. }
  40273. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40274. /** @hidden */
  40275. export var fresnelFunction: {
  40276. name: string;
  40277. shader: string;
  40278. };
  40279. }
  40280. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40281. /** @hidden */
  40282. export var reflectionFunction: {
  40283. name: string;
  40284. shader: string;
  40285. };
  40286. }
  40287. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40288. /** @hidden */
  40289. export var bumpFragmentFunctions: {
  40290. name: string;
  40291. shader: string;
  40292. };
  40293. }
  40294. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40295. /** @hidden */
  40296. export var logDepthDeclaration: {
  40297. name: string;
  40298. shader: string;
  40299. };
  40300. }
  40301. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40302. /** @hidden */
  40303. export var bumpFragment: {
  40304. name: string;
  40305. shader: string;
  40306. };
  40307. }
  40308. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40309. /** @hidden */
  40310. export var depthPrePass: {
  40311. name: string;
  40312. shader: string;
  40313. };
  40314. }
  40315. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40316. /** @hidden */
  40317. export var lightFragment: {
  40318. name: string;
  40319. shader: string;
  40320. };
  40321. }
  40322. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40323. /** @hidden */
  40324. export var logDepthFragment: {
  40325. name: string;
  40326. shader: string;
  40327. };
  40328. }
  40329. declare module "babylonjs/Shaders/default.fragment" {
  40330. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40331. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40333. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40334. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40335. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40336. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40337. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40338. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40339. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40341. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40342. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40343. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40344. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40345. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40346. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40347. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40348. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40349. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40350. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40351. /** @hidden */
  40352. export var defaultPixelShader: {
  40353. name: string;
  40354. shader: string;
  40355. };
  40356. }
  40357. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40358. /** @hidden */
  40359. export var defaultVertexDeclaration: {
  40360. name: string;
  40361. shader: string;
  40362. };
  40363. }
  40364. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40365. /** @hidden */
  40366. export var bumpVertexDeclaration: {
  40367. name: string;
  40368. shader: string;
  40369. };
  40370. }
  40371. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40372. /** @hidden */
  40373. export var bumpVertex: {
  40374. name: string;
  40375. shader: string;
  40376. };
  40377. }
  40378. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40379. /** @hidden */
  40380. export var fogVertex: {
  40381. name: string;
  40382. shader: string;
  40383. };
  40384. }
  40385. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40386. /** @hidden */
  40387. export var shadowsVertex: {
  40388. name: string;
  40389. shader: string;
  40390. };
  40391. }
  40392. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40393. /** @hidden */
  40394. export var pointCloudVertex: {
  40395. name: string;
  40396. shader: string;
  40397. };
  40398. }
  40399. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40400. /** @hidden */
  40401. export var logDepthVertex: {
  40402. name: string;
  40403. shader: string;
  40404. };
  40405. }
  40406. declare module "babylonjs/Shaders/default.vertex" {
  40407. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40408. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40410. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40411. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40412. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40413. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40414. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40415. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40416. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40419. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40423. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40424. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40425. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40426. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40427. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40428. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40429. /** @hidden */
  40430. export var defaultVertexShader: {
  40431. name: string;
  40432. shader: string;
  40433. };
  40434. }
  40435. declare module "babylonjs/Materials/standardMaterial" {
  40436. import { SmartArray } from "babylonjs/Misc/smartArray";
  40437. import { IAnimatable } from "babylonjs/Misc/tools";
  40438. import { Nullable } from "babylonjs/types";
  40439. import { Scene } from "babylonjs/scene";
  40440. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40443. import { Mesh } from "babylonjs/Meshes/mesh";
  40444. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40445. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40446. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40448. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40451. import "babylonjs/Shaders/default.fragment";
  40452. import "babylonjs/Shaders/default.vertex";
  40453. /** @hidden */
  40454. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40455. MAINUV1: boolean;
  40456. MAINUV2: boolean;
  40457. DIFFUSE: boolean;
  40458. DIFFUSEDIRECTUV: number;
  40459. AMBIENT: boolean;
  40460. AMBIENTDIRECTUV: number;
  40461. OPACITY: boolean;
  40462. OPACITYDIRECTUV: number;
  40463. OPACITYRGB: boolean;
  40464. REFLECTION: boolean;
  40465. EMISSIVE: boolean;
  40466. EMISSIVEDIRECTUV: number;
  40467. SPECULAR: boolean;
  40468. SPECULARDIRECTUV: number;
  40469. BUMP: boolean;
  40470. BUMPDIRECTUV: number;
  40471. PARALLAX: boolean;
  40472. PARALLAXOCCLUSION: boolean;
  40473. SPECULAROVERALPHA: boolean;
  40474. CLIPPLANE: boolean;
  40475. CLIPPLANE2: boolean;
  40476. CLIPPLANE3: boolean;
  40477. CLIPPLANE4: boolean;
  40478. ALPHATEST: boolean;
  40479. DEPTHPREPASS: boolean;
  40480. ALPHAFROMDIFFUSE: boolean;
  40481. POINTSIZE: boolean;
  40482. FOG: boolean;
  40483. SPECULARTERM: boolean;
  40484. DIFFUSEFRESNEL: boolean;
  40485. OPACITYFRESNEL: boolean;
  40486. REFLECTIONFRESNEL: boolean;
  40487. REFRACTIONFRESNEL: boolean;
  40488. EMISSIVEFRESNEL: boolean;
  40489. FRESNEL: boolean;
  40490. NORMAL: boolean;
  40491. UV1: boolean;
  40492. UV2: boolean;
  40493. VERTEXCOLOR: boolean;
  40494. VERTEXALPHA: boolean;
  40495. NUM_BONE_INFLUENCERS: number;
  40496. BonesPerMesh: number;
  40497. BONETEXTURE: boolean;
  40498. INSTANCES: boolean;
  40499. GLOSSINESS: boolean;
  40500. ROUGHNESS: boolean;
  40501. EMISSIVEASILLUMINATION: boolean;
  40502. LINKEMISSIVEWITHDIFFUSE: boolean;
  40503. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40504. LIGHTMAP: boolean;
  40505. LIGHTMAPDIRECTUV: number;
  40506. OBJECTSPACE_NORMALMAP: boolean;
  40507. USELIGHTMAPASSHADOWMAP: boolean;
  40508. REFLECTIONMAP_3D: boolean;
  40509. REFLECTIONMAP_SPHERICAL: boolean;
  40510. REFLECTIONMAP_PLANAR: boolean;
  40511. REFLECTIONMAP_CUBIC: boolean;
  40512. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40513. REFLECTIONMAP_PROJECTION: boolean;
  40514. REFLECTIONMAP_SKYBOX: boolean;
  40515. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40516. REFLECTIONMAP_EXPLICIT: boolean;
  40517. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40518. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40519. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40520. INVERTCUBICMAP: boolean;
  40521. LOGARITHMICDEPTH: boolean;
  40522. REFRACTION: boolean;
  40523. REFRACTIONMAP_3D: boolean;
  40524. REFLECTIONOVERALPHA: boolean;
  40525. TWOSIDEDLIGHTING: boolean;
  40526. SHADOWFLOAT: boolean;
  40527. MORPHTARGETS: boolean;
  40528. MORPHTARGETS_NORMAL: boolean;
  40529. MORPHTARGETS_TANGENT: boolean;
  40530. MORPHTARGETS_UV: boolean;
  40531. NUM_MORPH_INFLUENCERS: number;
  40532. NONUNIFORMSCALING: boolean;
  40533. PREMULTIPLYALPHA: boolean;
  40534. IMAGEPROCESSING: boolean;
  40535. VIGNETTE: boolean;
  40536. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40537. VIGNETTEBLENDMODEOPAQUE: boolean;
  40538. TONEMAPPING: boolean;
  40539. TONEMAPPING_ACES: boolean;
  40540. CONTRAST: boolean;
  40541. COLORCURVES: boolean;
  40542. COLORGRADING: boolean;
  40543. COLORGRADING3D: boolean;
  40544. SAMPLER3DGREENDEPTH: boolean;
  40545. SAMPLER3DBGRMAP: boolean;
  40546. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40547. MULTIVIEW: boolean;
  40548. /**
  40549. * If the reflection texture on this material is in linear color space
  40550. * @hidden
  40551. */
  40552. IS_REFLECTION_LINEAR: boolean;
  40553. /**
  40554. * If the refraction texture on this material is in linear color space
  40555. * @hidden
  40556. */
  40557. IS_REFRACTION_LINEAR: boolean;
  40558. EXPOSURE: boolean;
  40559. constructor();
  40560. setReflectionMode(modeToEnable: string): void;
  40561. }
  40562. /**
  40563. * This is the default material used in Babylon. It is the best trade off between quality
  40564. * and performances.
  40565. * @see http://doc.babylonjs.com/babylon101/materials
  40566. */
  40567. export class StandardMaterial extends PushMaterial {
  40568. private _diffuseTexture;
  40569. /**
  40570. * The basic texture of the material as viewed under a light.
  40571. */
  40572. diffuseTexture: Nullable<BaseTexture>;
  40573. private _ambientTexture;
  40574. /**
  40575. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40576. */
  40577. ambientTexture: Nullable<BaseTexture>;
  40578. private _opacityTexture;
  40579. /**
  40580. * Define the transparency of the material from a texture.
  40581. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40582. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40583. */
  40584. opacityTexture: Nullable<BaseTexture>;
  40585. private _reflectionTexture;
  40586. /**
  40587. * Define the texture used to display the reflection.
  40588. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40589. */
  40590. reflectionTexture: Nullable<BaseTexture>;
  40591. private _emissiveTexture;
  40592. /**
  40593. * Define texture of the material as if self lit.
  40594. * This will be mixed in the final result even in the absence of light.
  40595. */
  40596. emissiveTexture: Nullable<BaseTexture>;
  40597. private _specularTexture;
  40598. /**
  40599. * Define how the color and intensity of the highlight given by the light in the material.
  40600. */
  40601. specularTexture: Nullable<BaseTexture>;
  40602. private _bumpTexture;
  40603. /**
  40604. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40605. * 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.
  40606. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40607. */
  40608. bumpTexture: Nullable<BaseTexture>;
  40609. private _lightmapTexture;
  40610. /**
  40611. * Complex lighting can be computationally expensive to compute at runtime.
  40612. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40613. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40614. */
  40615. lightmapTexture: Nullable<BaseTexture>;
  40616. private _refractionTexture;
  40617. /**
  40618. * Define the texture used to display the refraction.
  40619. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40620. */
  40621. refractionTexture: Nullable<BaseTexture>;
  40622. /**
  40623. * The color of the material lit by the environmental background lighting.
  40624. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40625. */
  40626. ambientColor: Color3;
  40627. /**
  40628. * The basic color of the material as viewed under a light.
  40629. */
  40630. diffuseColor: Color3;
  40631. /**
  40632. * Define how the color and intensity of the highlight given by the light in the material.
  40633. */
  40634. specularColor: Color3;
  40635. /**
  40636. * Define the color of the material as if self lit.
  40637. * This will be mixed in the final result even in the absence of light.
  40638. */
  40639. emissiveColor: Color3;
  40640. /**
  40641. * Defines how sharp are the highlights in the material.
  40642. * The bigger the value the sharper giving a more glossy feeling to the result.
  40643. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40644. */
  40645. specularPower: number;
  40646. private _useAlphaFromDiffuseTexture;
  40647. /**
  40648. * Does the transparency come from the diffuse texture alpha channel.
  40649. */
  40650. useAlphaFromDiffuseTexture: boolean;
  40651. private _useEmissiveAsIllumination;
  40652. /**
  40653. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40654. */
  40655. useEmissiveAsIllumination: boolean;
  40656. private _linkEmissiveWithDiffuse;
  40657. /**
  40658. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40659. * the emissive level when the final color is close to one.
  40660. */
  40661. linkEmissiveWithDiffuse: boolean;
  40662. private _useSpecularOverAlpha;
  40663. /**
  40664. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40666. */
  40667. useSpecularOverAlpha: boolean;
  40668. private _useReflectionOverAlpha;
  40669. /**
  40670. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40671. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40672. */
  40673. useReflectionOverAlpha: boolean;
  40674. private _disableLighting;
  40675. /**
  40676. * Does lights from the scene impacts this material.
  40677. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40678. */
  40679. disableLighting: boolean;
  40680. private _useObjectSpaceNormalMap;
  40681. /**
  40682. * Allows using an object space normal map (instead of tangent space).
  40683. */
  40684. useObjectSpaceNormalMap: boolean;
  40685. private _useParallax;
  40686. /**
  40687. * Is parallax enabled or not.
  40688. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40689. */
  40690. useParallax: boolean;
  40691. private _useParallaxOcclusion;
  40692. /**
  40693. * Is parallax occlusion enabled or not.
  40694. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40695. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40696. */
  40697. useParallaxOcclusion: boolean;
  40698. /**
  40699. * 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.
  40700. */
  40701. parallaxScaleBias: number;
  40702. private _roughness;
  40703. /**
  40704. * Helps to define how blurry the reflections should appears in the material.
  40705. */
  40706. roughness: number;
  40707. /**
  40708. * In case of refraction, define the value of the index of refraction.
  40709. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40710. */
  40711. indexOfRefraction: number;
  40712. /**
  40713. * Invert the refraction texture alongside the y axis.
  40714. * It can be useful with procedural textures or probe for instance.
  40715. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40716. */
  40717. invertRefractionY: boolean;
  40718. /**
  40719. * Defines the alpha limits in alpha test mode.
  40720. */
  40721. alphaCutOff: number;
  40722. private _useLightmapAsShadowmap;
  40723. /**
  40724. * In case of light mapping, define whether the map contains light or shadow informations.
  40725. */
  40726. useLightmapAsShadowmap: boolean;
  40727. private _diffuseFresnelParameters;
  40728. /**
  40729. * Define the diffuse fresnel parameters of the material.
  40730. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40731. */
  40732. diffuseFresnelParameters: FresnelParameters;
  40733. private _opacityFresnelParameters;
  40734. /**
  40735. * Define the opacity fresnel parameters of the material.
  40736. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40737. */
  40738. opacityFresnelParameters: FresnelParameters;
  40739. private _reflectionFresnelParameters;
  40740. /**
  40741. * Define the reflection fresnel parameters of the material.
  40742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40743. */
  40744. reflectionFresnelParameters: FresnelParameters;
  40745. private _refractionFresnelParameters;
  40746. /**
  40747. * Define the refraction fresnel parameters of the material.
  40748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40749. */
  40750. refractionFresnelParameters: FresnelParameters;
  40751. private _emissiveFresnelParameters;
  40752. /**
  40753. * Define the emissive fresnel parameters of the material.
  40754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40755. */
  40756. emissiveFresnelParameters: FresnelParameters;
  40757. private _useReflectionFresnelFromSpecular;
  40758. /**
  40759. * If true automatically deducts the fresnels values from the material specularity.
  40760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40761. */
  40762. useReflectionFresnelFromSpecular: boolean;
  40763. private _useGlossinessFromSpecularMapAlpha;
  40764. /**
  40765. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40766. */
  40767. useGlossinessFromSpecularMapAlpha: boolean;
  40768. private _maxSimultaneousLights;
  40769. /**
  40770. * Defines the maximum number of lights that can be used in the material
  40771. */
  40772. maxSimultaneousLights: number;
  40773. private _invertNormalMapX;
  40774. /**
  40775. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40776. */
  40777. invertNormalMapX: boolean;
  40778. private _invertNormalMapY;
  40779. /**
  40780. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40781. */
  40782. invertNormalMapY: boolean;
  40783. private _twoSidedLighting;
  40784. /**
  40785. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40786. */
  40787. twoSidedLighting: boolean;
  40788. /**
  40789. * Default configuration related to image processing available in the standard Material.
  40790. */
  40791. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40792. /**
  40793. * Gets the image processing configuration used either in this material.
  40794. */
  40795. /**
  40796. * Sets the Default image processing configuration used either in the this material.
  40797. *
  40798. * If sets to null, the scene one is in use.
  40799. */
  40800. imageProcessingConfiguration: ImageProcessingConfiguration;
  40801. /**
  40802. * Keep track of the image processing observer to allow dispose and replace.
  40803. */
  40804. private _imageProcessingObserver;
  40805. /**
  40806. * Attaches a new image processing configuration to the Standard Material.
  40807. * @param configuration
  40808. */
  40809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40810. /**
  40811. * Gets wether the color curves effect is enabled.
  40812. */
  40813. /**
  40814. * Sets wether the color curves effect is enabled.
  40815. */
  40816. cameraColorCurvesEnabled: boolean;
  40817. /**
  40818. * Gets wether the color grading effect is enabled.
  40819. */
  40820. /**
  40821. * Gets wether the color grading effect is enabled.
  40822. */
  40823. cameraColorGradingEnabled: boolean;
  40824. /**
  40825. * Gets wether tonemapping is enabled or not.
  40826. */
  40827. /**
  40828. * Sets wether tonemapping is enabled or not
  40829. */
  40830. cameraToneMappingEnabled: boolean;
  40831. /**
  40832. * The camera exposure used on this material.
  40833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40834. * This corresponds to a photographic exposure.
  40835. */
  40836. /**
  40837. * The camera exposure used on this material.
  40838. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40839. * This corresponds to a photographic exposure.
  40840. */
  40841. cameraExposure: number;
  40842. /**
  40843. * Gets The camera contrast used on this material.
  40844. */
  40845. /**
  40846. * Sets The camera contrast used on this material.
  40847. */
  40848. cameraContrast: number;
  40849. /**
  40850. * Gets the Color Grading 2D Lookup Texture.
  40851. */
  40852. /**
  40853. * Sets the Color Grading 2D Lookup Texture.
  40854. */
  40855. cameraColorGradingTexture: Nullable<BaseTexture>;
  40856. /**
  40857. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40858. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40859. * 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;
  40860. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40861. */
  40862. /**
  40863. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40864. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40865. * 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;
  40866. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40867. */
  40868. cameraColorCurves: Nullable<ColorCurves>;
  40869. /**
  40870. * Custom callback helping to override the default shader used in the material.
  40871. */
  40872. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40873. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40874. protected _worldViewProjectionMatrix: Matrix;
  40875. protected _globalAmbientColor: Color3;
  40876. protected _useLogarithmicDepth: boolean;
  40877. /**
  40878. * Instantiates a new standard material.
  40879. * This is the default material used in Babylon. It is the best trade off between quality
  40880. * and performances.
  40881. * @see http://doc.babylonjs.com/babylon101/materials
  40882. * @param name Define the name of the material in the scene
  40883. * @param scene Define the scene the material belong to
  40884. */
  40885. constructor(name: string, scene: Scene);
  40886. /**
  40887. * Gets a boolean indicating that current material needs to register RTT
  40888. */
  40889. readonly hasRenderTargetTextures: boolean;
  40890. /**
  40891. * Gets the current class name of the material e.g. "StandardMaterial"
  40892. * Mainly use in serialization.
  40893. * @returns the class name
  40894. */
  40895. getClassName(): string;
  40896. /**
  40897. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40898. * You can try switching to logarithmic depth.
  40899. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40900. */
  40901. useLogarithmicDepth: boolean;
  40902. /**
  40903. * Specifies if the material will require alpha blending
  40904. * @returns a boolean specifying if alpha blending is needed
  40905. */
  40906. needAlphaBlending(): boolean;
  40907. /**
  40908. * Specifies if this material should be rendered in alpha test mode
  40909. * @returns a boolean specifying if an alpha test is needed.
  40910. */
  40911. needAlphaTesting(): boolean;
  40912. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40913. /**
  40914. * Get the texture used for alpha test purpose.
  40915. * @returns the diffuse texture in case of the standard material.
  40916. */
  40917. getAlphaTestTexture(): Nullable<BaseTexture>;
  40918. /**
  40919. * Get if the submesh is ready to be used and all its information available.
  40920. * Child classes can use it to update shaders
  40921. * @param mesh defines the mesh to check
  40922. * @param subMesh defines which submesh to check
  40923. * @param useInstances specifies that instances should be used
  40924. * @returns a boolean indicating that the submesh is ready or not
  40925. */
  40926. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40927. /**
  40928. * Builds the material UBO layouts.
  40929. * Used internally during the effect preparation.
  40930. */
  40931. buildUniformLayout(): void;
  40932. /**
  40933. * Unbinds the material from the mesh
  40934. */
  40935. unbind(): void;
  40936. /**
  40937. * Binds the submesh to this material by preparing the effect and shader to draw
  40938. * @param world defines the world transformation matrix
  40939. * @param mesh defines the mesh containing the submesh
  40940. * @param subMesh defines the submesh to bind the material to
  40941. */
  40942. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40943. /**
  40944. * Get the list of animatables in the material.
  40945. * @returns the list of animatables object used in the material
  40946. */
  40947. getAnimatables(): IAnimatable[];
  40948. /**
  40949. * Gets the active textures from the material
  40950. * @returns an array of textures
  40951. */
  40952. getActiveTextures(): BaseTexture[];
  40953. /**
  40954. * Specifies if the material uses a texture
  40955. * @param texture defines the texture to check against the material
  40956. * @returns a boolean specifying if the material uses the texture
  40957. */
  40958. hasTexture(texture: BaseTexture): boolean;
  40959. /**
  40960. * Disposes the material
  40961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40963. */
  40964. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40965. /**
  40966. * Makes a duplicate of the material, and gives it a new name
  40967. * @param name defines the new name for the duplicated material
  40968. * @returns the cloned material
  40969. */
  40970. clone(name: string): StandardMaterial;
  40971. /**
  40972. * Serializes this material in a JSON representation
  40973. * @returns the serialized material object
  40974. */
  40975. serialize(): any;
  40976. /**
  40977. * Creates a standard material from parsed material data
  40978. * @param source defines the JSON representation of the material
  40979. * @param scene defines the hosting scene
  40980. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40981. * @returns a new standard material
  40982. */
  40983. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40984. /**
  40985. * Are diffuse textures enabled in the application.
  40986. */
  40987. static DiffuseTextureEnabled: boolean;
  40988. /**
  40989. * Are ambient textures enabled in the application.
  40990. */
  40991. static AmbientTextureEnabled: boolean;
  40992. /**
  40993. * Are opacity textures enabled in the application.
  40994. */
  40995. static OpacityTextureEnabled: boolean;
  40996. /**
  40997. * Are reflection textures enabled in the application.
  40998. */
  40999. static ReflectionTextureEnabled: boolean;
  41000. /**
  41001. * Are emissive textures enabled in the application.
  41002. */
  41003. static EmissiveTextureEnabled: boolean;
  41004. /**
  41005. * Are specular textures enabled in the application.
  41006. */
  41007. static SpecularTextureEnabled: boolean;
  41008. /**
  41009. * Are bump textures enabled in the application.
  41010. */
  41011. static BumpTextureEnabled: boolean;
  41012. /**
  41013. * Are lightmap textures enabled in the application.
  41014. */
  41015. static LightmapTextureEnabled: boolean;
  41016. /**
  41017. * Are refraction textures enabled in the application.
  41018. */
  41019. static RefractionTextureEnabled: boolean;
  41020. /**
  41021. * Are color grading textures enabled in the application.
  41022. */
  41023. static ColorGradingTextureEnabled: boolean;
  41024. /**
  41025. * Are fresnels enabled in the application.
  41026. */
  41027. static FresnelEnabled: boolean;
  41028. }
  41029. }
  41030. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41031. import { Scene } from "babylonjs/scene";
  41032. import { Texture } from "babylonjs/Materials/Textures/texture";
  41033. /**
  41034. * A class extending Texture allowing drawing on a texture
  41035. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41036. */
  41037. export class DynamicTexture extends Texture {
  41038. private _generateMipMaps;
  41039. private _canvas;
  41040. private _context;
  41041. private _engine;
  41042. /**
  41043. * Creates a DynamicTexture
  41044. * @param name defines the name of the texture
  41045. * @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
  41046. * @param scene defines the scene where you want the texture
  41047. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41048. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41049. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41050. */
  41051. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41052. /**
  41053. * Get the current class name of the texture useful for serialization or dynamic coding.
  41054. * @returns "DynamicTexture"
  41055. */
  41056. getClassName(): string;
  41057. /**
  41058. * Gets the current state of canRescale
  41059. */
  41060. readonly canRescale: boolean;
  41061. private _recreate;
  41062. /**
  41063. * Scales the texture
  41064. * @param ratio the scale factor to apply to both width and height
  41065. */
  41066. scale(ratio: number): void;
  41067. /**
  41068. * Resizes the texture
  41069. * @param width the new width
  41070. * @param height the new height
  41071. */
  41072. scaleTo(width: number, height: number): void;
  41073. /**
  41074. * Gets the context of the canvas used by the texture
  41075. * @returns the canvas context of the dynamic texture
  41076. */
  41077. getContext(): CanvasRenderingContext2D;
  41078. /**
  41079. * Clears the texture
  41080. */
  41081. clear(): void;
  41082. /**
  41083. * Updates the texture
  41084. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41085. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41086. */
  41087. update(invertY?: boolean, premulAlpha?: boolean): void;
  41088. /**
  41089. * Draws text onto the texture
  41090. * @param text defines the text to be drawn
  41091. * @param x defines the placement of the text from the left
  41092. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41093. * @param font defines the font to be used with font-style, font-size, font-name
  41094. * @param color defines the color used for the text
  41095. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41096. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41097. * @param update defines whether texture is immediately update (default is true)
  41098. */
  41099. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41100. /**
  41101. * Clones the texture
  41102. * @returns the clone of the texture.
  41103. */
  41104. clone(): DynamicTexture;
  41105. /**
  41106. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41107. * @returns a serialized dynamic texture object
  41108. */
  41109. serialize(): any;
  41110. /** @hidden */
  41111. _rebuild(): void;
  41112. }
  41113. }
  41114. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41115. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41118. /** @hidden */
  41119. export var imageProcessingPixelShader: {
  41120. name: string;
  41121. shader: string;
  41122. };
  41123. }
  41124. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41125. import { Nullable } from "babylonjs/types";
  41126. import { Color4 } from "babylonjs/Maths/math";
  41127. import { Camera } from "babylonjs/Cameras/camera";
  41128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41129. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41130. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41132. import { Engine } from "babylonjs/Engines/engine";
  41133. import "babylonjs/Shaders/imageProcessing.fragment";
  41134. import "babylonjs/Shaders/postprocess.vertex";
  41135. /**
  41136. * ImageProcessingPostProcess
  41137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41138. */
  41139. export class ImageProcessingPostProcess extends PostProcess {
  41140. /**
  41141. * Default configuration related to image processing available in the PBR Material.
  41142. */
  41143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41144. /**
  41145. * Gets the image processing configuration used either in this material.
  41146. */
  41147. /**
  41148. * Sets the Default image processing configuration used either in the this material.
  41149. *
  41150. * If sets to null, the scene one is in use.
  41151. */
  41152. imageProcessingConfiguration: ImageProcessingConfiguration;
  41153. /**
  41154. * Keep track of the image processing observer to allow dispose and replace.
  41155. */
  41156. private _imageProcessingObserver;
  41157. /**
  41158. * Attaches a new image processing configuration to the PBR Material.
  41159. * @param configuration
  41160. */
  41161. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41162. /**
  41163. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41164. */
  41165. /**
  41166. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41167. */
  41168. colorCurves: Nullable<ColorCurves>;
  41169. /**
  41170. * Gets wether the color curves effect is enabled.
  41171. */
  41172. /**
  41173. * Sets wether the color curves effect is enabled.
  41174. */
  41175. colorCurvesEnabled: boolean;
  41176. /**
  41177. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41178. */
  41179. /**
  41180. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41181. */
  41182. colorGradingTexture: Nullable<BaseTexture>;
  41183. /**
  41184. * Gets wether the color grading effect is enabled.
  41185. */
  41186. /**
  41187. * Gets wether the color grading effect is enabled.
  41188. */
  41189. colorGradingEnabled: boolean;
  41190. /**
  41191. * Gets exposure used in the effect.
  41192. */
  41193. /**
  41194. * Sets exposure used in the effect.
  41195. */
  41196. exposure: number;
  41197. /**
  41198. * Gets wether tonemapping is enabled or not.
  41199. */
  41200. /**
  41201. * Sets wether tonemapping is enabled or not
  41202. */
  41203. toneMappingEnabled: boolean;
  41204. /**
  41205. * Gets the type of tone mapping effect.
  41206. */
  41207. /**
  41208. * Sets the type of tone mapping effect.
  41209. */
  41210. toneMappingType: number;
  41211. /**
  41212. * Gets contrast used in the effect.
  41213. */
  41214. /**
  41215. * Sets contrast used in the effect.
  41216. */
  41217. contrast: number;
  41218. /**
  41219. * Gets Vignette stretch size.
  41220. */
  41221. /**
  41222. * Sets Vignette stretch size.
  41223. */
  41224. vignetteStretch: number;
  41225. /**
  41226. * Gets Vignette centre X Offset.
  41227. */
  41228. /**
  41229. * Sets Vignette centre X Offset.
  41230. */
  41231. vignetteCentreX: number;
  41232. /**
  41233. * Gets Vignette centre Y Offset.
  41234. */
  41235. /**
  41236. * Sets Vignette centre Y Offset.
  41237. */
  41238. vignetteCentreY: number;
  41239. /**
  41240. * Gets Vignette weight or intensity of the vignette effect.
  41241. */
  41242. /**
  41243. * Sets Vignette weight or intensity of the vignette effect.
  41244. */
  41245. vignetteWeight: number;
  41246. /**
  41247. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41248. * if vignetteEnabled is set to true.
  41249. */
  41250. /**
  41251. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41252. * if vignetteEnabled is set to true.
  41253. */
  41254. vignetteColor: Color4;
  41255. /**
  41256. * Gets Camera field of view used by the Vignette effect.
  41257. */
  41258. /**
  41259. * Sets Camera field of view used by the Vignette effect.
  41260. */
  41261. vignetteCameraFov: number;
  41262. /**
  41263. * Gets the vignette blend mode allowing different kind of effect.
  41264. */
  41265. /**
  41266. * Sets the vignette blend mode allowing different kind of effect.
  41267. */
  41268. vignetteBlendMode: number;
  41269. /**
  41270. * Gets wether the vignette effect is enabled.
  41271. */
  41272. /**
  41273. * Sets wether the vignette effect is enabled.
  41274. */
  41275. vignetteEnabled: boolean;
  41276. private _fromLinearSpace;
  41277. /**
  41278. * Gets wether the input of the processing is in Gamma or Linear Space.
  41279. */
  41280. /**
  41281. * Sets wether the input of the processing is in Gamma or Linear Space.
  41282. */
  41283. fromLinearSpace: boolean;
  41284. /**
  41285. * Defines cache preventing GC.
  41286. */
  41287. private _defines;
  41288. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41289. /**
  41290. * "ImageProcessingPostProcess"
  41291. * @returns "ImageProcessingPostProcess"
  41292. */
  41293. getClassName(): string;
  41294. protected _updateParameters(): void;
  41295. dispose(camera?: Camera): void;
  41296. }
  41297. }
  41298. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41299. import { Scene } from "babylonjs/scene";
  41300. import { Color3 } from "babylonjs/Maths/math";
  41301. import { Mesh } from "babylonjs/Meshes/mesh";
  41302. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41303. import { Nullable } from "babylonjs/types";
  41304. /**
  41305. * Class containing static functions to help procedurally build meshes
  41306. */
  41307. export class GroundBuilder {
  41308. /**
  41309. * Creates a ground mesh
  41310. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41311. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41313. * @param name defines the name of the mesh
  41314. * @param options defines the options used to create the mesh
  41315. * @param scene defines the hosting scene
  41316. * @returns the ground mesh
  41317. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41318. */
  41319. static CreateGround(name: string, options: {
  41320. width?: number;
  41321. height?: number;
  41322. subdivisions?: number;
  41323. subdivisionsX?: number;
  41324. subdivisionsY?: number;
  41325. updatable?: boolean;
  41326. }, scene: any): Mesh;
  41327. /**
  41328. * Creates a tiled ground mesh
  41329. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41330. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41331. * * 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
  41332. * * 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
  41333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41334. * @param name defines the name of the mesh
  41335. * @param options defines the options used to create the mesh
  41336. * @param scene defines the hosting scene
  41337. * @returns the tiled ground mesh
  41338. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41339. */
  41340. static CreateTiledGround(name: string, options: {
  41341. xmin: number;
  41342. zmin: number;
  41343. xmax: number;
  41344. zmax: number;
  41345. subdivisions?: {
  41346. w: number;
  41347. h: number;
  41348. };
  41349. precision?: {
  41350. w: number;
  41351. h: number;
  41352. };
  41353. updatable?: boolean;
  41354. }, scene?: Nullable<Scene>): Mesh;
  41355. /**
  41356. * Creates a ground mesh from a height map
  41357. * * The parameter `url` sets the URL of the height map image resource.
  41358. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41359. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41360. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41361. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41362. * * 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.
  41363. * * 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).
  41364. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41366. * @param name defines the name of the mesh
  41367. * @param url defines the url to the height map
  41368. * @param options defines the options used to create the mesh
  41369. * @param scene defines the hosting scene
  41370. * @returns the ground mesh
  41371. * @see https://doc.babylonjs.com/babylon101/height_map
  41372. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41373. */
  41374. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41375. width?: number;
  41376. height?: number;
  41377. subdivisions?: number;
  41378. minHeight?: number;
  41379. maxHeight?: number;
  41380. colorFilter?: Color3;
  41381. alphaFilter?: number;
  41382. updatable?: boolean;
  41383. onReady?: (mesh: GroundMesh) => void;
  41384. }, scene?: Nullable<Scene>): GroundMesh;
  41385. }
  41386. }
  41387. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41388. import { Vector4 } from "babylonjs/Maths/math";
  41389. import { Mesh } from "babylonjs/Meshes/mesh";
  41390. /**
  41391. * Class containing static functions to help procedurally build meshes
  41392. */
  41393. export class TorusBuilder {
  41394. /**
  41395. * Creates a torus mesh
  41396. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41397. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41398. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41402. * @param name defines the name of the mesh
  41403. * @param options defines the options used to create the mesh
  41404. * @param scene defines the hosting scene
  41405. * @returns the torus mesh
  41406. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41407. */
  41408. static CreateTorus(name: string, options: {
  41409. diameter?: number;
  41410. thickness?: number;
  41411. tessellation?: number;
  41412. updatable?: boolean;
  41413. sideOrientation?: number;
  41414. frontUVs?: Vector4;
  41415. backUVs?: Vector4;
  41416. }, scene: any): Mesh;
  41417. }
  41418. }
  41419. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41420. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41421. import { Mesh } from "babylonjs/Meshes/mesh";
  41422. /**
  41423. * Class containing static functions to help procedurally build meshes
  41424. */
  41425. export class CylinderBuilder {
  41426. /**
  41427. * Creates a cylinder or a cone mesh
  41428. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41429. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41430. * * 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.
  41431. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41432. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41433. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41434. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41435. * * 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).
  41436. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41437. * * 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).
  41438. * * 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
  41439. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41440. * * 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
  41441. * * 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.
  41442. * * If `enclose` is false, a ring surface is one element.
  41443. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41444. * * 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
  41445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41448. * @param name defines the name of the mesh
  41449. * @param options defines the options used to create the mesh
  41450. * @param scene defines the hosting scene
  41451. * @returns the cylinder mesh
  41452. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41453. */
  41454. static CreateCylinder(name: string, options: {
  41455. height?: number;
  41456. diameterTop?: number;
  41457. diameterBottom?: number;
  41458. diameter?: number;
  41459. tessellation?: number;
  41460. subdivisions?: number;
  41461. arc?: number;
  41462. faceColors?: Color4[];
  41463. faceUV?: Vector4[];
  41464. updatable?: boolean;
  41465. hasRings?: boolean;
  41466. enclose?: boolean;
  41467. cap?: number;
  41468. sideOrientation?: number;
  41469. frontUVs?: Vector4;
  41470. backUVs?: Vector4;
  41471. }, scene: any): Mesh;
  41472. }
  41473. }
  41474. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41475. import { Observable } from "babylonjs/Misc/observable";
  41476. import { Nullable } from "babylonjs/types";
  41477. import { Camera } from "babylonjs/Cameras/camera";
  41478. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41479. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41480. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41481. import { Scene } from "babylonjs/scene";
  41482. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41483. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41485. import { Mesh } from "babylonjs/Meshes/mesh";
  41486. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41487. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41488. import "babylonjs/Meshes/Builders/groundBuilder";
  41489. import "babylonjs/Meshes/Builders/torusBuilder";
  41490. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41491. import "babylonjs/Gamepads/gamepadSceneComponent";
  41492. import "babylonjs/Animations/animatable";
  41493. /**
  41494. * Options to modify the vr teleportation behavior.
  41495. */
  41496. export interface VRTeleportationOptions {
  41497. /**
  41498. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41499. */
  41500. floorMeshName?: string;
  41501. /**
  41502. * A list of meshes to be used as the teleportation floor. (default: empty)
  41503. */
  41504. floorMeshes?: Mesh[];
  41505. }
  41506. /**
  41507. * Options to modify the vr experience helper's behavior.
  41508. */
  41509. export interface VRExperienceHelperOptions extends WebVROptions {
  41510. /**
  41511. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41512. */
  41513. createDeviceOrientationCamera?: boolean;
  41514. /**
  41515. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41516. */
  41517. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41518. /**
  41519. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41520. */
  41521. laserToggle?: boolean;
  41522. /**
  41523. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41524. */
  41525. floorMeshes?: Mesh[];
  41526. /**
  41527. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41528. */
  41529. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41530. }
  41531. /**
  41532. * Event containing information after VR has been entered
  41533. */
  41534. export class OnAfterEnteringVRObservableEvent {
  41535. /**
  41536. * If entering vr was successful
  41537. */
  41538. success: boolean;
  41539. }
  41540. /**
  41541. * Helps to quickly add VR support to an existing scene.
  41542. * See http://doc.babylonjs.com/how_to/webvr_helper
  41543. */
  41544. export class VRExperienceHelper {
  41545. /** Options to modify the vr experience helper's behavior. */
  41546. webVROptions: VRExperienceHelperOptions;
  41547. private _scene;
  41548. private _position;
  41549. private _btnVR;
  41550. private _btnVRDisplayed;
  41551. private _webVRsupported;
  41552. private _webVRready;
  41553. private _webVRrequesting;
  41554. private _webVRpresenting;
  41555. private _hasEnteredVR;
  41556. private _fullscreenVRpresenting;
  41557. private _canvas;
  41558. private _webVRCamera;
  41559. private _vrDeviceOrientationCamera;
  41560. private _deviceOrientationCamera;
  41561. private _existingCamera;
  41562. private _onKeyDown;
  41563. private _onVrDisplayPresentChange;
  41564. private _onVRDisplayChanged;
  41565. private _onVRRequestPresentStart;
  41566. private _onVRRequestPresentComplete;
  41567. /**
  41568. * Observable raised right before entering VR.
  41569. */
  41570. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41571. /**
  41572. * Observable raised when entering VR has completed.
  41573. */
  41574. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41575. /**
  41576. * Observable raised when exiting VR.
  41577. */
  41578. onExitingVRObservable: Observable<VRExperienceHelper>;
  41579. /**
  41580. * Observable raised when controller mesh is loaded.
  41581. */
  41582. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41583. /** Return this.onEnteringVRObservable
  41584. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41585. */
  41586. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41587. /** Return this.onExitingVRObservable
  41588. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41589. */
  41590. readonly onExitingVR: Observable<VRExperienceHelper>;
  41591. /** Return this.onControllerMeshLoadedObservable
  41592. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41593. */
  41594. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41595. private _rayLength;
  41596. private _useCustomVRButton;
  41597. private _teleportationRequested;
  41598. private _teleportActive;
  41599. private _floorMeshName;
  41600. private _floorMeshesCollection;
  41601. private _rotationAllowed;
  41602. private _teleportBackwardsVector;
  41603. private _teleportationTarget;
  41604. private _isDefaultTeleportationTarget;
  41605. private _postProcessMove;
  41606. private _teleportationFillColor;
  41607. private _teleportationBorderColor;
  41608. private _rotationAngle;
  41609. private _haloCenter;
  41610. private _cameraGazer;
  41611. private _padSensibilityUp;
  41612. private _padSensibilityDown;
  41613. private _leftController;
  41614. private _rightController;
  41615. /**
  41616. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41617. */
  41618. onNewMeshSelected: Observable<AbstractMesh>;
  41619. /**
  41620. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41621. */
  41622. onNewMeshPicked: Observable<PickingInfo>;
  41623. private _circleEase;
  41624. /**
  41625. * Observable raised before camera teleportation
  41626. */
  41627. onBeforeCameraTeleport: Observable<Vector3>;
  41628. /**
  41629. * Observable raised after camera teleportation
  41630. */
  41631. onAfterCameraTeleport: Observable<Vector3>;
  41632. /**
  41633. * Observable raised when current selected mesh gets unselected
  41634. */
  41635. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41636. private _raySelectionPredicate;
  41637. /**
  41638. * To be optionaly changed by user to define custom ray selection
  41639. */
  41640. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41641. /**
  41642. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41643. */
  41644. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41645. /**
  41646. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41647. */
  41648. teleportationEnabled: boolean;
  41649. private _defaultHeight;
  41650. private _teleportationInitialized;
  41651. private _interactionsEnabled;
  41652. private _interactionsRequested;
  41653. private _displayGaze;
  41654. private _displayLaserPointer;
  41655. /**
  41656. * The mesh used to display where the user is going to teleport.
  41657. */
  41658. /**
  41659. * Sets the mesh to be used to display where the user is going to teleport.
  41660. */
  41661. teleportationTarget: Mesh;
  41662. /**
  41663. * 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
  41664. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41665. * See http://doc.babylonjs.com/resources/baking_transformations
  41666. */
  41667. gazeTrackerMesh: Mesh;
  41668. /**
  41669. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41670. */
  41671. updateGazeTrackerScale: boolean;
  41672. /**
  41673. * If the gaze trackers color should be updated when selecting meshes
  41674. */
  41675. updateGazeTrackerColor: boolean;
  41676. /**
  41677. * The gaze tracking mesh corresponding to the left controller
  41678. */
  41679. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41680. /**
  41681. * The gaze tracking mesh corresponding to the right controller
  41682. */
  41683. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41684. /**
  41685. * If the ray of the gaze should be displayed.
  41686. */
  41687. /**
  41688. * Sets if the ray of the gaze should be displayed.
  41689. */
  41690. displayGaze: boolean;
  41691. /**
  41692. * If the ray of the LaserPointer should be displayed.
  41693. */
  41694. /**
  41695. * Sets if the ray of the LaserPointer should be displayed.
  41696. */
  41697. displayLaserPointer: boolean;
  41698. /**
  41699. * The deviceOrientationCamera used as the camera when not in VR.
  41700. */
  41701. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41702. /**
  41703. * Based on the current WebVR support, returns the current VR camera used.
  41704. */
  41705. readonly currentVRCamera: Nullable<Camera>;
  41706. /**
  41707. * The webVRCamera which is used when in VR.
  41708. */
  41709. readonly webVRCamera: WebVRFreeCamera;
  41710. /**
  41711. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41712. */
  41713. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41714. private readonly _teleportationRequestInitiated;
  41715. /**
  41716. * Defines wether or not Pointer lock should be requested when switching to
  41717. * full screen.
  41718. */
  41719. requestPointerLockOnFullScreen: boolean;
  41720. /**
  41721. * Instantiates a VRExperienceHelper.
  41722. * Helps to quickly add VR support to an existing scene.
  41723. * @param scene The scene the VRExperienceHelper belongs to.
  41724. * @param webVROptions Options to modify the vr experience helper's behavior.
  41725. */
  41726. constructor(scene: Scene,
  41727. /** Options to modify the vr experience helper's behavior. */
  41728. webVROptions?: VRExperienceHelperOptions);
  41729. private _onDefaultMeshLoaded;
  41730. private _onResize;
  41731. private _onFullscreenChange;
  41732. /**
  41733. * Gets a value indicating if we are currently in VR mode.
  41734. */
  41735. readonly isInVRMode: boolean;
  41736. private onVrDisplayPresentChange;
  41737. private onVRDisplayChanged;
  41738. private moveButtonToBottomRight;
  41739. private displayVRButton;
  41740. private updateButtonVisibility;
  41741. private _cachedAngularSensibility;
  41742. /**
  41743. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41744. * Otherwise, will use the fullscreen API.
  41745. */
  41746. enterVR(): void;
  41747. /**
  41748. * Attempt to exit VR, or fullscreen.
  41749. */
  41750. exitVR(): void;
  41751. /**
  41752. * The position of the vr experience helper.
  41753. */
  41754. /**
  41755. * Sets the position of the vr experience helper.
  41756. */
  41757. position: Vector3;
  41758. /**
  41759. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41760. */
  41761. enableInteractions(): void;
  41762. private readonly _noControllerIsActive;
  41763. private beforeRender;
  41764. private _isTeleportationFloor;
  41765. /**
  41766. * Adds a floor mesh to be used for teleportation.
  41767. * @param floorMesh the mesh to be used for teleportation.
  41768. */
  41769. addFloorMesh(floorMesh: Mesh): void;
  41770. /**
  41771. * Removes a floor mesh from being used for teleportation.
  41772. * @param floorMesh the mesh to be removed.
  41773. */
  41774. removeFloorMesh(floorMesh: Mesh): void;
  41775. /**
  41776. * Enables interactions and teleportation using the VR controllers and gaze.
  41777. * @param vrTeleportationOptions options to modify teleportation behavior.
  41778. */
  41779. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41780. private _onNewGamepadConnected;
  41781. private _tryEnableInteractionOnController;
  41782. private _onNewGamepadDisconnected;
  41783. private _enableInteractionOnController;
  41784. private _checkTeleportWithRay;
  41785. private _checkRotate;
  41786. private _checkTeleportBackwards;
  41787. private _enableTeleportationOnController;
  41788. private _createTeleportationCircles;
  41789. private _displayTeleportationTarget;
  41790. private _hideTeleportationTarget;
  41791. private _rotateCamera;
  41792. private _moveTeleportationSelectorTo;
  41793. private _workingVector;
  41794. private _workingQuaternion;
  41795. private _workingMatrix;
  41796. /**
  41797. * Teleports the users feet to the desired location
  41798. * @param location The location where the user's feet should be placed
  41799. */
  41800. teleportCamera(location: Vector3): void;
  41801. private _convertNormalToDirectionOfRay;
  41802. private _castRayAndSelectObject;
  41803. private _notifySelectedMeshUnselected;
  41804. /**
  41805. * Sets the color of the laser ray from the vr controllers.
  41806. * @param color new color for the ray.
  41807. */
  41808. changeLaserColor(color: Color3): void;
  41809. /**
  41810. * Sets the color of the ray from the vr headsets gaze.
  41811. * @param color new color for the ray.
  41812. */
  41813. changeGazeColor(color: Color3): void;
  41814. /**
  41815. * Exits VR and disposes of the vr experience helper
  41816. */
  41817. dispose(): void;
  41818. /**
  41819. * Gets the name of the VRExperienceHelper class
  41820. * @returns "VRExperienceHelper"
  41821. */
  41822. getClassName(): string;
  41823. }
  41824. }
  41825. declare module "babylonjs/Cameras/VR/index" {
  41826. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41827. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41828. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41829. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41830. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41831. export * from "babylonjs/Cameras/VR/webVRCamera";
  41832. }
  41833. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41834. import { Observable } from "babylonjs/Misc/observable";
  41835. import { Nullable } from "babylonjs/types";
  41836. import { IDisposable, Scene } from "babylonjs/scene";
  41837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41838. /**
  41839. * Manages an XRSession to work with Babylon's engine
  41840. * @see https://doc.babylonjs.com/how_to/webxr
  41841. */
  41842. export class WebXRSessionManager implements IDisposable {
  41843. private scene;
  41844. /**
  41845. * Fires every time a new xrFrame arrives which can be used to update the camera
  41846. */
  41847. onXRFrameObservable: Observable<any>;
  41848. /**
  41849. * Fires when the xr session is ended either by the device or manually done
  41850. */
  41851. onXRSessionEnded: Observable<any>;
  41852. /**
  41853. * Underlying xr session
  41854. */
  41855. session: XRSession;
  41856. /**
  41857. * Type of reference space used when creating the session
  41858. */
  41859. referenceSpace: XRReferenceSpace;
  41860. /** @hidden */
  41861. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41862. /**
  41863. * Current XR frame
  41864. */
  41865. currentFrame: Nullable<XRFrame>;
  41866. private _xrNavigator;
  41867. private baseLayer;
  41868. /**
  41869. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41870. * @param scene The scene which the session should be created for
  41871. */
  41872. constructor(scene: Scene);
  41873. /**
  41874. * Initializes the manager
  41875. * After initialization enterXR can be called to start an XR session
  41876. * @returns Promise which resolves after it is initialized
  41877. */
  41878. initializeAsync(): Promise<void>;
  41879. /**
  41880. * Initializes an xr session
  41881. * @param xrSessionMode mode to initialize
  41882. * @returns a promise which will resolve once the session has been initialized
  41883. */
  41884. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41885. /**
  41886. * Sets the reference space on the xr session
  41887. * @param referenceSpace space to set
  41888. * @returns a promise that will resolve once the reference space has been set
  41889. */
  41890. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41891. /**
  41892. * Updates the render state of the session
  41893. * @param state state to set
  41894. * @returns a promise that resolves once the render state has been updated
  41895. */
  41896. updateRenderStateAsync(state: any): Promise<void>;
  41897. /**
  41898. * Starts rendering to the xr layer
  41899. * @returns a promise that will resolve once rendering has started
  41900. */
  41901. startRenderingToXRAsync(): Promise<void>;
  41902. /**
  41903. * Stops the xrSession and restores the renderloop
  41904. * @returns Promise which resolves after it exits XR
  41905. */
  41906. exitXRAsync(): Promise<void>;
  41907. /**
  41908. * Checks if a session would be supported for the creation options specified
  41909. * @param sessionMode session mode to check if supported eg. immersive-vr
  41910. * @returns true if supported
  41911. */
  41912. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41913. /**
  41914. * @hidden
  41915. * Converts the render layer of xrSession to a render target
  41916. * @param session session to create render target for
  41917. * @param scene scene the new render target should be created for
  41918. */
  41919. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41920. /**
  41921. * Disposes of the session manager
  41922. */
  41923. dispose(): void;
  41924. }
  41925. }
  41926. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41927. import { Scene } from "babylonjs/scene";
  41928. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41929. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41930. /**
  41931. * WebXR Camera which holds the views for the xrSession
  41932. * @see https://doc.babylonjs.com/how_to/webxr
  41933. */
  41934. export class WebXRCamera extends FreeCamera {
  41935. private static _TmpMatrix;
  41936. /**
  41937. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41938. * @param name the name of the camera
  41939. * @param scene the scene to add the camera to
  41940. */
  41941. constructor(name: string, scene: Scene);
  41942. private _updateNumberOfRigCameras;
  41943. /** @hidden */
  41944. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41945. /**
  41946. * Updates the cameras position from the current pose information of the XR session
  41947. * @param xrSessionManager the session containing pose information
  41948. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41949. */
  41950. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41951. }
  41952. }
  41953. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41954. import { Nullable } from "babylonjs/types";
  41955. import { IDisposable } from "babylonjs/scene";
  41956. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41957. /**
  41958. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41959. */
  41960. export class WebXRManagedOutputCanvas implements IDisposable {
  41961. private helper;
  41962. private _canvas;
  41963. /**
  41964. * xrpresent context of the canvas which can be used to display/mirror xr content
  41965. */
  41966. canvasContext: WebGLRenderingContext;
  41967. /**
  41968. * xr layer for the canvas
  41969. */
  41970. xrLayer: Nullable<XRWebGLLayer>;
  41971. /**
  41972. * Initializes the xr layer for the session
  41973. * @param xrSession xr session
  41974. * @returns a promise that will resolve once the XR Layer has been created
  41975. */
  41976. initializeXRLayerAsync(xrSession: any): any;
  41977. /**
  41978. * Initializes the canvas to be added/removed upon entering/exiting xr
  41979. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41980. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41981. */
  41982. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41983. /**
  41984. * Disposes of the object
  41985. */
  41986. dispose(): void;
  41987. private _setManagedOutputCanvas;
  41988. private _addCanvas;
  41989. private _removeCanvas;
  41990. }
  41991. }
  41992. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41993. import { Observable } from "babylonjs/Misc/observable";
  41994. import { IDisposable, Scene } from "babylonjs/scene";
  41995. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41997. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41998. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41999. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42000. /**
  42001. * States of the webXR experience
  42002. */
  42003. export enum WebXRState {
  42004. /**
  42005. * Transitioning to being in XR mode
  42006. */
  42007. ENTERING_XR = 0,
  42008. /**
  42009. * Transitioning to non XR mode
  42010. */
  42011. EXITING_XR = 1,
  42012. /**
  42013. * In XR mode and presenting
  42014. */
  42015. IN_XR = 2,
  42016. /**
  42017. * Not entered XR mode
  42018. */
  42019. NOT_IN_XR = 3
  42020. }
  42021. /**
  42022. * Helper class used to enable XR
  42023. * @see https://doc.babylonjs.com/how_to/webxr
  42024. */
  42025. export class WebXRExperienceHelper implements IDisposable {
  42026. private scene;
  42027. /**
  42028. * 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
  42029. */
  42030. container: AbstractMesh;
  42031. /**
  42032. * Camera used to render xr content
  42033. */
  42034. camera: WebXRCamera;
  42035. /**
  42036. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42037. */
  42038. state: WebXRState;
  42039. private _setState;
  42040. private static _TmpVector;
  42041. /**
  42042. * Fires when the state of the experience helper has changed
  42043. */
  42044. onStateChangedObservable: Observable<WebXRState>;
  42045. /** Session manager used to keep track of xr session */
  42046. sessionManager: WebXRSessionManager;
  42047. private _nonVRCamera;
  42048. private _originalSceneAutoClear;
  42049. private _supported;
  42050. /**
  42051. * Creates the experience helper
  42052. * @param scene the scene to attach the experience helper to
  42053. * @returns a promise for the experience helper
  42054. */
  42055. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42056. /**
  42057. * Creates a WebXRExperienceHelper
  42058. * @param scene The scene the helper should be created in
  42059. */
  42060. private constructor();
  42061. /**
  42062. * Exits XR mode and returns the scene to its original state
  42063. * @returns promise that resolves after xr mode has exited
  42064. */
  42065. exitXRAsync(): Promise<void>;
  42066. /**
  42067. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42068. * @param sessionCreationOptions options for the XR session
  42069. * @param referenceSpaceType frame of reference of the XR session
  42070. * @param outputCanvas the output canvas that will be used to enter XR mode
  42071. * @returns promise that resolves after xr mode has entered
  42072. */
  42073. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42074. /**
  42075. * Updates the global position of the camera by moving the camera's container
  42076. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42077. * @param position The desired global position of the camera
  42078. */
  42079. setPositionOfCameraUsingContainer(position: Vector3): void;
  42080. /**
  42081. * Rotates the xr camera by rotating the camera's container around the camera's position
  42082. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42083. * @param rotation the desired quaternion rotation to apply to the camera
  42084. */
  42085. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42086. /**
  42087. * Disposes of the experience helper
  42088. */
  42089. dispose(): void;
  42090. }
  42091. }
  42092. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42093. import { Nullable } from "babylonjs/types";
  42094. import { Observable } from "babylonjs/Misc/observable";
  42095. import { IDisposable, Scene } from "babylonjs/scene";
  42096. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42097. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42098. /**
  42099. * Button which can be used to enter a different mode of XR
  42100. */
  42101. export class WebXREnterExitUIButton {
  42102. /** button element */
  42103. element: HTMLElement;
  42104. /** XR initialization options for the button */
  42105. sessionMode: XRSessionMode;
  42106. /** Reference space type */
  42107. referenceSpaceType: XRReferenceSpaceType;
  42108. /**
  42109. * Creates a WebXREnterExitUIButton
  42110. * @param element button element
  42111. * @param sessionMode XR initialization session mode
  42112. * @param referenceSpaceType the type of reference space to be used
  42113. */
  42114. constructor(
  42115. /** button element */
  42116. element: HTMLElement,
  42117. /** XR initialization options for the button */
  42118. sessionMode: XRSessionMode,
  42119. /** Reference space type */
  42120. referenceSpaceType: XRReferenceSpaceType);
  42121. /**
  42122. * Overwritable function which can be used to update the button's visuals when the state changes
  42123. * @param activeButton the current active button in the UI
  42124. */
  42125. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42126. }
  42127. /**
  42128. * Options to create the webXR UI
  42129. */
  42130. export class WebXREnterExitUIOptions {
  42131. /**
  42132. * Context to enter xr with
  42133. */
  42134. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42135. /**
  42136. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42137. */
  42138. customButtons?: Array<WebXREnterExitUIButton>;
  42139. }
  42140. /**
  42141. * UI to allow the user to enter/exit XR mode
  42142. */
  42143. export class WebXREnterExitUI implements IDisposable {
  42144. private scene;
  42145. private _overlay;
  42146. private _buttons;
  42147. private _activeButton;
  42148. /**
  42149. * Fired every time the active button is changed.
  42150. *
  42151. * When xr is entered via a button that launches xr that button will be the callback parameter
  42152. *
  42153. * When exiting xr the callback parameter will be null)
  42154. */
  42155. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42156. /**
  42157. * Creates UI to allow the user to enter/exit XR mode
  42158. * @param scene the scene to add the ui to
  42159. * @param helper the xr experience helper to enter/exit xr with
  42160. * @param options options to configure the UI
  42161. * @returns the created ui
  42162. */
  42163. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42164. private constructor();
  42165. private _updateButtons;
  42166. /**
  42167. * Disposes of the object
  42168. */
  42169. dispose(): void;
  42170. }
  42171. }
  42172. declare module "babylonjs/Cameras/XR/webXRInput" {
  42173. import { Nullable } from "babylonjs/types";
  42174. import { Observable } from "babylonjs/Misc/observable";
  42175. import { IDisposable, Scene } from "babylonjs/scene";
  42176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42177. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42178. /**
  42179. * Represents an XR input
  42180. */
  42181. export class WebXRController {
  42182. private scene;
  42183. /** The underlying input source for the controller */
  42184. inputSource: XRInputSource;
  42185. private parentContainer;
  42186. /**
  42187. * 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
  42188. */
  42189. grip?: AbstractMesh;
  42190. /**
  42191. * Pointer which can be used to select objects or attach a visible laser to
  42192. */
  42193. pointer: AbstractMesh;
  42194. private _tmpMatrix;
  42195. /**
  42196. * Creates the controller
  42197. * @see https://doc.babylonjs.com/how_to/webxr
  42198. * @param scene the scene which the controller should be associated to
  42199. * @param inputSource the underlying input source for the controller
  42200. * @param parentContainer parent that the controller meshes should be children of
  42201. */
  42202. constructor(scene: Scene,
  42203. /** The underlying input source for the controller */
  42204. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42205. /**
  42206. * Updates the controller pose based on the given XRFrame
  42207. * @param xrFrame xr frame to update the pose with
  42208. * @param referenceSpace reference space to use
  42209. */
  42210. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42211. /**
  42212. * Disposes of the object
  42213. */
  42214. dispose(): void;
  42215. }
  42216. /**
  42217. * XR input used to track XR inputs such as controllers/rays
  42218. */
  42219. export class WebXRInput implements IDisposable {
  42220. private helper;
  42221. /**
  42222. * XR controllers being tracked
  42223. */
  42224. controllers: Array<WebXRController>;
  42225. private _frameObserver;
  42226. /**
  42227. * Event when a controller has been connected/added
  42228. */
  42229. onControllerAddedObservable: Observable<WebXRController>;
  42230. /**
  42231. * Event when a controller has been removed/disconnected
  42232. */
  42233. onControllerRemovedObservable: Observable<WebXRController>;
  42234. /**
  42235. * Initializes the WebXRInput
  42236. * @param helper experience helper which the input should be created for
  42237. */
  42238. constructor(helper: WebXRExperienceHelper);
  42239. private _onInputSourcesChange;
  42240. private _addAndRemoveControllers;
  42241. /**
  42242. * Disposes of the object
  42243. */
  42244. dispose(): void;
  42245. }
  42246. }
  42247. declare module "babylonjs/Cameras/XR/index" {
  42248. export * from "babylonjs/Cameras/XR/webXRCamera";
  42249. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42250. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42251. export * from "babylonjs/Cameras/XR/webXRInput";
  42252. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42253. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42254. }
  42255. declare module "babylonjs/Cameras/RigModes/index" {
  42256. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42257. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42258. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42259. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42260. }
  42261. declare module "babylonjs/Cameras/index" {
  42262. export * from "babylonjs/Cameras/Inputs/index";
  42263. export * from "babylonjs/Cameras/cameraInputsManager";
  42264. export * from "babylonjs/Cameras/camera";
  42265. export * from "babylonjs/Cameras/targetCamera";
  42266. export * from "babylonjs/Cameras/freeCamera";
  42267. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42268. export * from "babylonjs/Cameras/touchCamera";
  42269. export * from "babylonjs/Cameras/arcRotateCamera";
  42270. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42271. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42272. export * from "babylonjs/Cameras/flyCamera";
  42273. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42274. export * from "babylonjs/Cameras/followCamera";
  42275. export * from "babylonjs/Cameras/gamepadCamera";
  42276. export * from "babylonjs/Cameras/Stereoscopic/index";
  42277. export * from "babylonjs/Cameras/universalCamera";
  42278. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42279. export * from "babylonjs/Cameras/VR/index";
  42280. export * from "babylonjs/Cameras/XR/index";
  42281. export * from "babylonjs/Cameras/RigModes/index";
  42282. }
  42283. declare module "babylonjs/Collisions/index" {
  42284. export * from "babylonjs/Collisions/collider";
  42285. export * from "babylonjs/Collisions/collisionCoordinator";
  42286. export * from "babylonjs/Collisions/pickingInfo";
  42287. export * from "babylonjs/Collisions/intersectionInfo";
  42288. export * from "babylonjs/Collisions/meshCollisionData";
  42289. }
  42290. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42291. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42292. import { Vector3, Plane } from "babylonjs/Maths/math";
  42293. import { Ray } from "babylonjs/Culling/ray";
  42294. /**
  42295. * Contains an array of blocks representing the octree
  42296. */
  42297. export interface IOctreeContainer<T> {
  42298. /**
  42299. * Blocks within the octree
  42300. */
  42301. blocks: Array<OctreeBlock<T>>;
  42302. }
  42303. /**
  42304. * Class used to store a cell in an octree
  42305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42306. */
  42307. export class OctreeBlock<T> {
  42308. /**
  42309. * Gets the content of the current block
  42310. */
  42311. entries: T[];
  42312. /**
  42313. * Gets the list of block children
  42314. */
  42315. blocks: Array<OctreeBlock<T>>;
  42316. private _depth;
  42317. private _maxDepth;
  42318. private _capacity;
  42319. private _minPoint;
  42320. private _maxPoint;
  42321. private _boundingVectors;
  42322. private _creationFunc;
  42323. /**
  42324. * Creates a new block
  42325. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42326. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42327. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42328. * @param depth defines the current depth of this block in the octree
  42329. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42330. * @param creationFunc defines a callback to call when an element is added to the block
  42331. */
  42332. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42333. /**
  42334. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42335. */
  42336. readonly capacity: number;
  42337. /**
  42338. * Gets the minimum vector (in world space) of the block's bounding box
  42339. */
  42340. readonly minPoint: Vector3;
  42341. /**
  42342. * Gets the maximum vector (in world space) of the block's bounding box
  42343. */
  42344. readonly maxPoint: Vector3;
  42345. /**
  42346. * Add a new element to this block
  42347. * @param entry defines the element to add
  42348. */
  42349. addEntry(entry: T): void;
  42350. /**
  42351. * Remove an element from this block
  42352. * @param entry defines the element to remove
  42353. */
  42354. removeEntry(entry: T): void;
  42355. /**
  42356. * Add an array of elements to this block
  42357. * @param entries defines the array of elements to add
  42358. */
  42359. addEntries(entries: T[]): void;
  42360. /**
  42361. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42362. * @param frustumPlanes defines the frustum planes to test
  42363. * @param selection defines the array to store current content if selection is positive
  42364. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42365. */
  42366. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42367. /**
  42368. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42369. * @param sphereCenter defines the bounding sphere center
  42370. * @param sphereRadius defines the bounding sphere radius
  42371. * @param selection defines the array to store current content if selection is positive
  42372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42373. */
  42374. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42375. /**
  42376. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42377. * @param ray defines the ray to test with
  42378. * @param selection defines the array to store current content if selection is positive
  42379. */
  42380. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42381. /**
  42382. * Subdivide the content into child blocks (this block will then be empty)
  42383. */
  42384. createInnerBlocks(): void;
  42385. /**
  42386. * @hidden
  42387. */
  42388. 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;
  42389. }
  42390. }
  42391. declare module "babylonjs/Culling/Octrees/octree" {
  42392. import { SmartArray } from "babylonjs/Misc/smartArray";
  42393. import { Vector3, Plane } from "babylonjs/Maths/math";
  42394. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42396. import { Ray } from "babylonjs/Culling/ray";
  42397. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42398. /**
  42399. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42401. */
  42402. export class Octree<T> {
  42403. /** 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.) */
  42404. maxDepth: number;
  42405. /**
  42406. * Blocks within the octree containing objects
  42407. */
  42408. blocks: Array<OctreeBlock<T>>;
  42409. /**
  42410. * Content stored in the octree
  42411. */
  42412. dynamicContent: T[];
  42413. private _maxBlockCapacity;
  42414. private _selectionContent;
  42415. private _creationFunc;
  42416. /**
  42417. * Creates a octree
  42418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42419. * @param creationFunc function to be used to instatiate the octree
  42420. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42421. * @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.)
  42422. */
  42423. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42424. /** 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.) */
  42425. maxDepth?: number);
  42426. /**
  42427. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42428. * @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);
  42429. * @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);
  42430. * @param entries meshes to be added to the octree blocks
  42431. */
  42432. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42433. /**
  42434. * Adds a mesh to the octree
  42435. * @param entry Mesh to add to the octree
  42436. */
  42437. addMesh(entry: T): void;
  42438. /**
  42439. * Remove an element from the octree
  42440. * @param entry defines the element to remove
  42441. */
  42442. removeMesh(entry: T): void;
  42443. /**
  42444. * Selects an array of meshes within the frustum
  42445. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42446. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42447. * @returns array of meshes within the frustum
  42448. */
  42449. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42450. /**
  42451. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42452. * @param sphereCenter defines the bounding sphere center
  42453. * @param sphereRadius defines the bounding sphere radius
  42454. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42455. * @returns an array of objects that intersect the sphere
  42456. */
  42457. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42458. /**
  42459. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42460. * @param ray defines the ray to test with
  42461. * @returns array of intersected objects
  42462. */
  42463. intersectsRay(ray: Ray): SmartArray<T>;
  42464. /**
  42465. * Adds a mesh into the octree block if it intersects the block
  42466. */
  42467. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42468. /**
  42469. * Adds a submesh into the octree block if it intersects the block
  42470. */
  42471. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42472. }
  42473. }
  42474. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42475. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42476. import { Scene } from "babylonjs/scene";
  42477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42479. import { Ray } from "babylonjs/Culling/ray";
  42480. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42481. import { Collider } from "babylonjs/Collisions/collider";
  42482. module "babylonjs/scene" {
  42483. interface Scene {
  42484. /**
  42485. * @hidden
  42486. * Backing Filed
  42487. */
  42488. _selectionOctree: Octree<AbstractMesh>;
  42489. /**
  42490. * Gets the octree used to boost mesh selection (picking)
  42491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42492. */
  42493. selectionOctree: Octree<AbstractMesh>;
  42494. /**
  42495. * Creates or updates the octree used to boost selection (picking)
  42496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42497. * @param maxCapacity defines the maximum capacity per leaf
  42498. * @param maxDepth defines the maximum depth of the octree
  42499. * @returns an octree of AbstractMesh
  42500. */
  42501. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42502. }
  42503. }
  42504. module "babylonjs/Meshes/abstractMesh" {
  42505. interface AbstractMesh {
  42506. /**
  42507. * @hidden
  42508. * Backing Field
  42509. */
  42510. _submeshesOctree: Octree<SubMesh>;
  42511. /**
  42512. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42513. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42514. * @param maxCapacity defines the maximum size of each block (64 by default)
  42515. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42516. * @returns the new octree
  42517. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42519. */
  42520. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42521. }
  42522. }
  42523. /**
  42524. * Defines the octree scene component responsible to manage any octrees
  42525. * in a given scene.
  42526. */
  42527. export class OctreeSceneComponent {
  42528. /**
  42529. * The component name help to identify the component in the list of scene components.
  42530. */
  42531. readonly name: string;
  42532. /**
  42533. * The scene the component belongs to.
  42534. */
  42535. scene: Scene;
  42536. /**
  42537. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42538. */
  42539. readonly checksIsEnabled: boolean;
  42540. /**
  42541. * Creates a new instance of the component for the given scene
  42542. * @param scene Defines the scene to register the component in
  42543. */
  42544. constructor(scene: Scene);
  42545. /**
  42546. * Registers the component in a given scene
  42547. */
  42548. register(): void;
  42549. /**
  42550. * Return the list of active meshes
  42551. * @returns the list of active meshes
  42552. */
  42553. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42554. /**
  42555. * Return the list of active sub meshes
  42556. * @param mesh The mesh to get the candidates sub meshes from
  42557. * @returns the list of active sub meshes
  42558. */
  42559. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42560. private _tempRay;
  42561. /**
  42562. * Return the list of sub meshes intersecting with a given local ray
  42563. * @param mesh defines the mesh to find the submesh for
  42564. * @param localRay defines the ray in local space
  42565. * @returns the list of intersecting sub meshes
  42566. */
  42567. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42568. /**
  42569. * Return the list of sub meshes colliding with a collider
  42570. * @param mesh defines the mesh to find the submesh for
  42571. * @param collider defines the collider to evaluate the collision against
  42572. * @returns the list of colliding sub meshes
  42573. */
  42574. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42575. /**
  42576. * Rebuilds the elements related to this component in case of
  42577. * context lost for instance.
  42578. */
  42579. rebuild(): void;
  42580. /**
  42581. * Disposes the component and the associated ressources.
  42582. */
  42583. dispose(): void;
  42584. }
  42585. }
  42586. declare module "babylonjs/Culling/Octrees/index" {
  42587. export * from "babylonjs/Culling/Octrees/octree";
  42588. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42589. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42590. }
  42591. declare module "babylonjs/Culling/index" {
  42592. export * from "babylonjs/Culling/boundingBox";
  42593. export * from "babylonjs/Culling/boundingInfo";
  42594. export * from "babylonjs/Culling/boundingSphere";
  42595. export * from "babylonjs/Culling/Octrees/index";
  42596. export * from "babylonjs/Culling/ray";
  42597. }
  42598. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42599. import { IDisposable, Scene } from "babylonjs/scene";
  42600. import { Nullable } from "babylonjs/types";
  42601. import { Observable } from "babylonjs/Misc/observable";
  42602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42603. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42604. import { Camera } from "babylonjs/Cameras/camera";
  42605. /**
  42606. * Renders a layer on top of an existing scene
  42607. */
  42608. export class UtilityLayerRenderer implements IDisposable {
  42609. /** the original scene that will be rendered on top of */
  42610. originalScene: Scene;
  42611. private _pointerCaptures;
  42612. private _lastPointerEvents;
  42613. private static _DefaultUtilityLayer;
  42614. private static _DefaultKeepDepthUtilityLayer;
  42615. private _sharedGizmoLight;
  42616. private _renderCamera;
  42617. /**
  42618. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42619. * @returns the camera that is used when rendering the utility layer
  42620. */
  42621. getRenderCamera(): Nullable<Camera>;
  42622. /**
  42623. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42624. * @param cam the camera that should be used when rendering the utility layer
  42625. */
  42626. setRenderCamera(cam: Nullable<Camera>): void;
  42627. /**
  42628. * @hidden
  42629. * Light which used by gizmos to get light shading
  42630. */
  42631. _getSharedGizmoLight(): HemisphericLight;
  42632. /**
  42633. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42634. */
  42635. pickUtilitySceneFirst: boolean;
  42636. /**
  42637. * 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)
  42638. */
  42639. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42640. /**
  42641. * 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)
  42642. */
  42643. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42644. /**
  42645. * The scene that is rendered on top of the original scene
  42646. */
  42647. utilityLayerScene: Scene;
  42648. /**
  42649. * If the utility layer should automatically be rendered on top of existing scene
  42650. */
  42651. shouldRender: boolean;
  42652. /**
  42653. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42654. */
  42655. onlyCheckPointerDownEvents: boolean;
  42656. /**
  42657. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42658. */
  42659. processAllEvents: boolean;
  42660. /**
  42661. * Observable raised when the pointer move from the utility layer scene to the main scene
  42662. */
  42663. onPointerOutObservable: Observable<number>;
  42664. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42665. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42666. private _afterRenderObserver;
  42667. private _sceneDisposeObserver;
  42668. private _originalPointerObserver;
  42669. /**
  42670. * Instantiates a UtilityLayerRenderer
  42671. * @param originalScene the original scene that will be rendered on top of
  42672. * @param handleEvents boolean indicating if the utility layer should handle events
  42673. */
  42674. constructor(
  42675. /** the original scene that will be rendered on top of */
  42676. originalScene: Scene, handleEvents?: boolean);
  42677. private _notifyObservers;
  42678. /**
  42679. * Renders the utility layers scene on top of the original scene
  42680. */
  42681. render(): void;
  42682. /**
  42683. * Disposes of the renderer
  42684. */
  42685. dispose(): void;
  42686. private _updateCamera;
  42687. }
  42688. }
  42689. declare module "babylonjs/Gizmos/gizmo" {
  42690. import { Nullable } from "babylonjs/types";
  42691. import { IDisposable } from "babylonjs/scene";
  42692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42693. import { Mesh } from "babylonjs/Meshes/mesh";
  42694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42695. /**
  42696. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42697. */
  42698. export class Gizmo implements IDisposable {
  42699. /** The utility layer the gizmo will be added to */
  42700. gizmoLayer: UtilityLayerRenderer;
  42701. /**
  42702. * The root mesh of the gizmo
  42703. */
  42704. _rootMesh: Mesh;
  42705. private _attachedMesh;
  42706. /**
  42707. * Ratio for the scale of the gizmo (Default: 1)
  42708. */
  42709. scaleRatio: number;
  42710. /**
  42711. * If a custom mesh has been set (Default: false)
  42712. */
  42713. protected _customMeshSet: boolean;
  42714. /**
  42715. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42716. * * When set, interactions will be enabled
  42717. */
  42718. attachedMesh: Nullable<AbstractMesh>;
  42719. /**
  42720. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42721. * @param mesh The mesh to replace the default mesh of the gizmo
  42722. */
  42723. setCustomMesh(mesh: Mesh): void;
  42724. /**
  42725. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42726. */
  42727. updateGizmoRotationToMatchAttachedMesh: boolean;
  42728. /**
  42729. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42730. */
  42731. updateGizmoPositionToMatchAttachedMesh: boolean;
  42732. /**
  42733. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42734. */
  42735. protected _updateScale: boolean;
  42736. protected _interactionsEnabled: boolean;
  42737. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42738. private _beforeRenderObserver;
  42739. private _tempVector;
  42740. /**
  42741. * Creates a gizmo
  42742. * @param gizmoLayer The utility layer the gizmo will be added to
  42743. */
  42744. constructor(
  42745. /** The utility layer the gizmo will be added to */
  42746. gizmoLayer?: UtilityLayerRenderer);
  42747. /**
  42748. * Updates the gizmo to match the attached mesh's position/rotation
  42749. */
  42750. protected _update(): void;
  42751. /**
  42752. * Disposes of the gizmo
  42753. */
  42754. dispose(): void;
  42755. }
  42756. }
  42757. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42758. import { Observable } from "babylonjs/Misc/observable";
  42759. import { Nullable } from "babylonjs/types";
  42760. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42761. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42763. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42764. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42766. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42767. import { Scene } from "babylonjs/scene";
  42768. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42769. /**
  42770. * Single plane drag gizmo
  42771. */
  42772. export class PlaneDragGizmo extends Gizmo {
  42773. /**
  42774. * Drag behavior responsible for the gizmos dragging interactions
  42775. */
  42776. dragBehavior: PointerDragBehavior;
  42777. private _pointerObserver;
  42778. /**
  42779. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42780. */
  42781. snapDistance: number;
  42782. /**
  42783. * Event that fires each time the gizmo snaps to a new location.
  42784. * * snapDistance is the the change in distance
  42785. */
  42786. onSnapObservable: Observable<{
  42787. snapDistance: number;
  42788. }>;
  42789. private _plane;
  42790. private _coloredMaterial;
  42791. private _hoverMaterial;
  42792. private _isEnabled;
  42793. private _parent;
  42794. /** @hidden */
  42795. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42796. /** @hidden */
  42797. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42798. /**
  42799. * Creates a PlaneDragGizmo
  42800. * @param gizmoLayer The utility layer the gizmo will be added to
  42801. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42802. * @param color The color of the gizmo
  42803. */
  42804. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42805. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42806. /**
  42807. * If the gizmo is enabled
  42808. */
  42809. isEnabled: boolean;
  42810. /**
  42811. * Disposes of the gizmo
  42812. */
  42813. dispose(): void;
  42814. }
  42815. }
  42816. declare module "babylonjs/Gizmos/positionGizmo" {
  42817. import { Observable } from "babylonjs/Misc/observable";
  42818. import { Nullable } from "babylonjs/types";
  42819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42820. import { Mesh } from "babylonjs/Meshes/mesh";
  42821. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42822. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42823. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42824. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42825. /**
  42826. * Gizmo that enables dragging a mesh along 3 axis
  42827. */
  42828. export class PositionGizmo extends Gizmo {
  42829. /**
  42830. * Internal gizmo used for interactions on the x axis
  42831. */
  42832. xGizmo: AxisDragGizmo;
  42833. /**
  42834. * Internal gizmo used for interactions on the y axis
  42835. */
  42836. yGizmo: AxisDragGizmo;
  42837. /**
  42838. * Internal gizmo used for interactions on the z axis
  42839. */
  42840. zGizmo: AxisDragGizmo;
  42841. /**
  42842. * Internal gizmo used for interactions on the yz plane
  42843. */
  42844. xPlaneGizmo: PlaneDragGizmo;
  42845. /**
  42846. * Internal gizmo used for interactions on the xz plane
  42847. */
  42848. yPlaneGizmo: PlaneDragGizmo;
  42849. /**
  42850. * Internal gizmo used for interactions on the xy plane
  42851. */
  42852. zPlaneGizmo: PlaneDragGizmo;
  42853. /**
  42854. * private variables
  42855. */
  42856. private _meshAttached;
  42857. private _updateGizmoRotationToMatchAttachedMesh;
  42858. private _snapDistance;
  42859. private _scaleRatio;
  42860. /** Fires an event when any of it's sub gizmos are dragged */
  42861. onDragStartObservable: Observable<unknown>;
  42862. /** Fires an event when any of it's sub gizmos are released from dragging */
  42863. onDragEndObservable: Observable<unknown>;
  42864. /**
  42865. * If set to true, planar drag is enabled
  42866. */
  42867. private _planarGizmoEnabled;
  42868. attachedMesh: Nullable<AbstractMesh>;
  42869. /**
  42870. * Creates a PositionGizmo
  42871. * @param gizmoLayer The utility layer the gizmo will be added to
  42872. */
  42873. constructor(gizmoLayer?: UtilityLayerRenderer);
  42874. /**
  42875. * If the planar drag gizmo is enabled
  42876. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42877. */
  42878. planarGizmoEnabled: boolean;
  42879. updateGizmoRotationToMatchAttachedMesh: boolean;
  42880. /**
  42881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42882. */
  42883. snapDistance: number;
  42884. /**
  42885. * Ratio for the scale of the gizmo (Default: 1)
  42886. */
  42887. scaleRatio: number;
  42888. /**
  42889. * Disposes of the gizmo
  42890. */
  42891. dispose(): void;
  42892. /**
  42893. * CustomMeshes are not supported by this gizmo
  42894. * @param mesh The mesh to replace the default mesh of the gizmo
  42895. */
  42896. setCustomMesh(mesh: Mesh): void;
  42897. }
  42898. }
  42899. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42900. import { Observable } from "babylonjs/Misc/observable";
  42901. import { Nullable } from "babylonjs/types";
  42902. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42903. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42905. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42906. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42907. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42908. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42909. import { Scene } from "babylonjs/scene";
  42910. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42911. /**
  42912. * Single axis drag gizmo
  42913. */
  42914. export class AxisDragGizmo extends Gizmo {
  42915. /**
  42916. * Drag behavior responsible for the gizmos dragging interactions
  42917. */
  42918. dragBehavior: PointerDragBehavior;
  42919. private _pointerObserver;
  42920. /**
  42921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42922. */
  42923. snapDistance: number;
  42924. /**
  42925. * Event that fires each time the gizmo snaps to a new location.
  42926. * * snapDistance is the the change in distance
  42927. */
  42928. onSnapObservable: Observable<{
  42929. snapDistance: number;
  42930. }>;
  42931. private _isEnabled;
  42932. private _parent;
  42933. private _arrow;
  42934. private _coloredMaterial;
  42935. private _hoverMaterial;
  42936. /** @hidden */
  42937. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42938. /** @hidden */
  42939. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42940. /**
  42941. * Creates an AxisDragGizmo
  42942. * @param gizmoLayer The utility layer the gizmo will be added to
  42943. * @param dragAxis The axis which the gizmo will be able to drag on
  42944. * @param color The color of the gizmo
  42945. */
  42946. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42948. /**
  42949. * If the gizmo is enabled
  42950. */
  42951. isEnabled: boolean;
  42952. /**
  42953. * Disposes of the gizmo
  42954. */
  42955. dispose(): void;
  42956. }
  42957. }
  42958. declare module "babylonjs/Debug/axesViewer" {
  42959. import { Vector3 } from "babylonjs/Maths/math";
  42960. import { Nullable } from "babylonjs/types";
  42961. import { Scene } from "babylonjs/scene";
  42962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42963. /**
  42964. * The Axes viewer will show 3 axes in a specific point in space
  42965. */
  42966. export class AxesViewer {
  42967. private _xAxis;
  42968. private _yAxis;
  42969. private _zAxis;
  42970. private _scaleLinesFactor;
  42971. private _instanced;
  42972. /**
  42973. * Gets the hosting scene
  42974. */
  42975. scene: Scene;
  42976. /**
  42977. * Gets or sets a number used to scale line length
  42978. */
  42979. scaleLines: number;
  42980. /** Gets the node hierarchy used to render x-axis */
  42981. readonly xAxis: TransformNode;
  42982. /** Gets the node hierarchy used to render y-axis */
  42983. readonly yAxis: TransformNode;
  42984. /** Gets the node hierarchy used to render z-axis */
  42985. readonly zAxis: TransformNode;
  42986. /**
  42987. * Creates a new AxesViewer
  42988. * @param scene defines the hosting scene
  42989. * @param scaleLines defines a number used to scale line length (1 by default)
  42990. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42991. * @param xAxis defines the node hierarchy used to render the x-axis
  42992. * @param yAxis defines the node hierarchy used to render the y-axis
  42993. * @param zAxis defines the node hierarchy used to render the z-axis
  42994. */
  42995. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42996. /**
  42997. * Force the viewer to update
  42998. * @param position defines the position of the viewer
  42999. * @param xaxis defines the x axis of the viewer
  43000. * @param yaxis defines the y axis of the viewer
  43001. * @param zaxis defines the z axis of the viewer
  43002. */
  43003. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43004. /**
  43005. * Creates an instance of this axes viewer.
  43006. * @returns a new axes viewer with instanced meshes
  43007. */
  43008. createInstance(): AxesViewer;
  43009. /** Releases resources */
  43010. dispose(): void;
  43011. private static _SetRenderingGroupId;
  43012. }
  43013. }
  43014. declare module "babylonjs/Debug/boneAxesViewer" {
  43015. import { Nullable } from "babylonjs/types";
  43016. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  43017. import { Vector3 } from "babylonjs/Maths/math";
  43018. import { Mesh } from "babylonjs/Meshes/mesh";
  43019. import { Bone } from "babylonjs/Bones/bone";
  43020. import { Scene } from "babylonjs/scene";
  43021. /**
  43022. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43023. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43024. */
  43025. export class BoneAxesViewer extends AxesViewer {
  43026. /**
  43027. * Gets or sets the target mesh where to display the axes viewer
  43028. */
  43029. mesh: Nullable<Mesh>;
  43030. /**
  43031. * Gets or sets the target bone where to display the axes viewer
  43032. */
  43033. bone: Nullable<Bone>;
  43034. /** Gets current position */
  43035. pos: Vector3;
  43036. /** Gets direction of X axis */
  43037. xaxis: Vector3;
  43038. /** Gets direction of Y axis */
  43039. yaxis: Vector3;
  43040. /** Gets direction of Z axis */
  43041. zaxis: Vector3;
  43042. /**
  43043. * Creates a new BoneAxesViewer
  43044. * @param scene defines the hosting scene
  43045. * @param bone defines the target bone
  43046. * @param mesh defines the target mesh
  43047. * @param scaleLines defines a scaling factor for line length (1 by default)
  43048. */
  43049. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43050. /**
  43051. * Force the viewer to update
  43052. */
  43053. update(): void;
  43054. /** Releases resources */
  43055. dispose(): void;
  43056. }
  43057. }
  43058. declare module "babylonjs/Debug/debugLayer" {
  43059. import { Scene } from "babylonjs/scene";
  43060. /**
  43061. * Interface used to define scene explorer extensibility option
  43062. */
  43063. export interface IExplorerExtensibilityOption {
  43064. /**
  43065. * Define the option label
  43066. */
  43067. label: string;
  43068. /**
  43069. * Defines the action to execute on click
  43070. */
  43071. action: (entity: any) => void;
  43072. }
  43073. /**
  43074. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43075. */
  43076. export interface IExplorerExtensibilityGroup {
  43077. /**
  43078. * Defines a predicate to test if a given type mut be extended
  43079. */
  43080. predicate: (entity: any) => boolean;
  43081. /**
  43082. * Gets the list of options added to a type
  43083. */
  43084. entries: IExplorerExtensibilityOption[];
  43085. }
  43086. /**
  43087. * Interface used to define the options to use to create the Inspector
  43088. */
  43089. export interface IInspectorOptions {
  43090. /**
  43091. * Display in overlay mode (default: false)
  43092. */
  43093. overlay?: boolean;
  43094. /**
  43095. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43096. */
  43097. globalRoot?: HTMLElement;
  43098. /**
  43099. * Display the Scene explorer
  43100. */
  43101. showExplorer?: boolean;
  43102. /**
  43103. * Display the property inspector
  43104. */
  43105. showInspector?: boolean;
  43106. /**
  43107. * Display in embed mode (both panes on the right)
  43108. */
  43109. embedMode?: boolean;
  43110. /**
  43111. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43112. */
  43113. handleResize?: boolean;
  43114. /**
  43115. * Allow the panes to popup (default: true)
  43116. */
  43117. enablePopup?: boolean;
  43118. /**
  43119. * Allow the panes to be closed by users (default: true)
  43120. */
  43121. enableClose?: boolean;
  43122. /**
  43123. * Optional list of extensibility entries
  43124. */
  43125. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43126. /**
  43127. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43128. */
  43129. inspectorURL?: string;
  43130. }
  43131. module "babylonjs/scene" {
  43132. interface Scene {
  43133. /**
  43134. * @hidden
  43135. * Backing field
  43136. */
  43137. _debugLayer: DebugLayer;
  43138. /**
  43139. * Gets the debug layer (aka Inspector) associated with the scene
  43140. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43141. */
  43142. debugLayer: DebugLayer;
  43143. }
  43144. }
  43145. /**
  43146. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43147. * what is happening in your scene
  43148. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43149. */
  43150. export class DebugLayer {
  43151. /**
  43152. * Define the url to get the inspector script from.
  43153. * By default it uses the babylonjs CDN.
  43154. * @ignoreNaming
  43155. */
  43156. static InspectorURL: string;
  43157. private _scene;
  43158. private BJSINSPECTOR;
  43159. private _onPropertyChangedObservable?;
  43160. /**
  43161. * Observable triggered when a property is changed through the inspector.
  43162. */
  43163. readonly onPropertyChangedObservable: any;
  43164. /**
  43165. * Instantiates a new debug layer.
  43166. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43167. * what is happening in your scene
  43168. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43169. * @param scene Defines the scene to inspect
  43170. */
  43171. constructor(scene: Scene);
  43172. /** Creates the inspector window. */
  43173. private _createInspector;
  43174. /**
  43175. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43176. * @param entity defines the entity to select
  43177. * @param lineContainerTitle defines the specific block to highlight
  43178. */
  43179. select(entity: any, lineContainerTitle?: string): void;
  43180. /** Get the inspector from bundle or global */
  43181. private _getGlobalInspector;
  43182. /**
  43183. * Get if the inspector is visible or not.
  43184. * @returns true if visible otherwise, false
  43185. */
  43186. isVisible(): boolean;
  43187. /**
  43188. * Hide the inspector and close its window.
  43189. */
  43190. hide(): void;
  43191. /**
  43192. * Launch the debugLayer.
  43193. * @param config Define the configuration of the inspector
  43194. * @return a promise fulfilled when the debug layer is visible
  43195. */
  43196. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43197. }
  43198. }
  43199. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43200. import { Nullable } from "babylonjs/types";
  43201. import { Scene } from "babylonjs/scene";
  43202. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43203. import { Mesh } from "babylonjs/Meshes/mesh";
  43204. /**
  43205. * Class containing static functions to help procedurally build meshes
  43206. */
  43207. export class BoxBuilder {
  43208. /**
  43209. * Creates a box mesh
  43210. * * The parameter `size` sets the size (float) of each box side (default 1)
  43211. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43212. * * 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)
  43213. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43217. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43218. * @param name defines the name of the mesh
  43219. * @param options defines the options used to create the mesh
  43220. * @param scene defines the hosting scene
  43221. * @returns the box mesh
  43222. */
  43223. static CreateBox(name: string, options: {
  43224. size?: number;
  43225. width?: number;
  43226. height?: number;
  43227. depth?: number;
  43228. faceUV?: Vector4[];
  43229. faceColors?: Color4[];
  43230. sideOrientation?: number;
  43231. frontUVs?: Vector4;
  43232. backUVs?: Vector4;
  43233. wrap?: boolean;
  43234. topBaseAt?: number;
  43235. bottomBaseAt?: number;
  43236. updatable?: boolean;
  43237. }, scene?: Nullable<Scene>): Mesh;
  43238. }
  43239. }
  43240. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43241. import { Vector4 } from "babylonjs/Maths/math";
  43242. import { Mesh } from "babylonjs/Meshes/mesh";
  43243. /**
  43244. * Class containing static functions to help procedurally build meshes
  43245. */
  43246. export class SphereBuilder {
  43247. /**
  43248. * Creates a sphere mesh
  43249. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43250. * * 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`)
  43251. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43252. * * 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
  43253. * * 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)
  43254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43257. * @param name defines the name of the mesh
  43258. * @param options defines the options used to create the mesh
  43259. * @param scene defines the hosting scene
  43260. * @returns the sphere mesh
  43261. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43262. */
  43263. static CreateSphere(name: string, options: {
  43264. segments?: number;
  43265. diameter?: number;
  43266. diameterX?: number;
  43267. diameterY?: number;
  43268. diameterZ?: number;
  43269. arc?: number;
  43270. slice?: number;
  43271. sideOrientation?: number;
  43272. frontUVs?: Vector4;
  43273. backUVs?: Vector4;
  43274. updatable?: boolean;
  43275. }, scene: any): Mesh;
  43276. }
  43277. }
  43278. declare module "babylonjs/Debug/physicsViewer" {
  43279. import { Nullable } from "babylonjs/types";
  43280. import { Scene } from "babylonjs/scene";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { Mesh } from "babylonjs/Meshes/mesh";
  43283. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43285. /**
  43286. * Used to show the physics impostor around the specific mesh
  43287. */
  43288. export class PhysicsViewer {
  43289. /** @hidden */
  43290. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43291. /** @hidden */
  43292. protected _meshes: Array<Nullable<AbstractMesh>>;
  43293. /** @hidden */
  43294. protected _scene: Nullable<Scene>;
  43295. /** @hidden */
  43296. protected _numMeshes: number;
  43297. /** @hidden */
  43298. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43299. private _renderFunction;
  43300. private _utilityLayer;
  43301. private _debugBoxMesh;
  43302. private _debugSphereMesh;
  43303. private _debugCylinderMesh;
  43304. private _debugMaterial;
  43305. private _debugMeshMeshes;
  43306. /**
  43307. * Creates a new PhysicsViewer
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(scene: Scene);
  43311. /** @hidden */
  43312. protected _updateDebugMeshes(): void;
  43313. /**
  43314. * Renders a specified physic impostor
  43315. * @param impostor defines the impostor to render
  43316. * @param targetMesh defines the mesh represented by the impostor
  43317. * @returns the new debug mesh used to render the impostor
  43318. */
  43319. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43320. /**
  43321. * Hides a specified physic impostor
  43322. * @param impostor defines the impostor to hide
  43323. */
  43324. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43325. private _getDebugMaterial;
  43326. private _getDebugBoxMesh;
  43327. private _getDebugSphereMesh;
  43328. private _getDebugCylinderMesh;
  43329. private _getDebugMeshMesh;
  43330. private _getDebugMesh;
  43331. /** Releases all resources */
  43332. dispose(): void;
  43333. }
  43334. }
  43335. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43336. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43337. import { Nullable } from "babylonjs/types";
  43338. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43339. import { Scene } from "babylonjs/scene";
  43340. /**
  43341. * Class containing static functions to help procedurally build meshes
  43342. */
  43343. export class LinesBuilder {
  43344. /**
  43345. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43346. * * 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
  43347. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43348. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43349. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43350. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43351. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43352. * * 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
  43353. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43355. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43356. * @param name defines the name of the new line system
  43357. * @param options defines the options used to create the line system
  43358. * @param scene defines the hosting scene
  43359. * @returns a new line system mesh
  43360. */
  43361. static CreateLineSystem(name: string, options: {
  43362. lines: Vector3[][];
  43363. updatable?: boolean;
  43364. instance?: Nullable<LinesMesh>;
  43365. colors?: Nullable<Color4[][]>;
  43366. useVertexAlpha?: boolean;
  43367. }, scene: Nullable<Scene>): LinesMesh;
  43368. /**
  43369. * Creates a line mesh
  43370. * 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
  43371. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43372. * * The parameter `points` is an array successive Vector3
  43373. * * 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
  43374. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43375. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43376. * * When updating an instance, remember that only point positions can change, not the number of points
  43377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43379. * @param name defines the name of the new line system
  43380. * @param options defines the options used to create the line system
  43381. * @param scene defines the hosting scene
  43382. * @returns a new line mesh
  43383. */
  43384. static CreateLines(name: string, options: {
  43385. points: Vector3[];
  43386. updatable?: boolean;
  43387. instance?: Nullable<LinesMesh>;
  43388. colors?: Color4[];
  43389. useVertexAlpha?: boolean;
  43390. }, scene?: Nullable<Scene>): LinesMesh;
  43391. /**
  43392. * Creates a dashed line mesh
  43393. * * 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
  43394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43395. * * The parameter `points` is an array successive Vector3
  43396. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43397. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43398. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43399. * * 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
  43400. * * When updating an instance, remember that only point positions can change, not the number of points
  43401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43402. * @param name defines the name of the mesh
  43403. * @param options defines the options used to create the mesh
  43404. * @param scene defines the hosting scene
  43405. * @returns the dashed line mesh
  43406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43407. */
  43408. static CreateDashedLines(name: string, options: {
  43409. points: Vector3[];
  43410. dashSize?: number;
  43411. gapSize?: number;
  43412. dashNb?: number;
  43413. updatable?: boolean;
  43414. instance?: LinesMesh;
  43415. }, scene?: Nullable<Scene>): LinesMesh;
  43416. }
  43417. }
  43418. declare module "babylonjs/Debug/rayHelper" {
  43419. import { Nullable } from "babylonjs/types";
  43420. import { Ray } from "babylonjs/Culling/ray";
  43421. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43422. import { Scene } from "babylonjs/scene";
  43423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43424. import "babylonjs/Meshes/Builders/linesBuilder";
  43425. /**
  43426. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43427. * in order to better appreciate the issue one might have.
  43428. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43429. */
  43430. export class RayHelper {
  43431. /**
  43432. * Defines the ray we are currently tryin to visualize.
  43433. */
  43434. ray: Nullable<Ray>;
  43435. private _renderPoints;
  43436. private _renderLine;
  43437. private _renderFunction;
  43438. private _scene;
  43439. private _updateToMeshFunction;
  43440. private _attachedToMesh;
  43441. private _meshSpaceDirection;
  43442. private _meshSpaceOrigin;
  43443. /**
  43444. * Helper function to create a colored helper in a scene in one line.
  43445. * @param ray Defines the ray we are currently tryin to visualize
  43446. * @param scene Defines the scene the ray is used in
  43447. * @param color Defines the color we want to see the ray in
  43448. * @returns The newly created ray helper.
  43449. */
  43450. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43451. /**
  43452. * Instantiate a new ray helper.
  43453. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43454. * in order to better appreciate the issue one might have.
  43455. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43456. * @param ray Defines the ray we are currently tryin to visualize
  43457. */
  43458. constructor(ray: Ray);
  43459. /**
  43460. * Shows the ray we are willing to debug.
  43461. * @param scene Defines the scene the ray needs to be rendered in
  43462. * @param color Defines the color the ray needs to be rendered in
  43463. */
  43464. show(scene: Scene, color?: Color3): void;
  43465. /**
  43466. * Hides the ray we are debugging.
  43467. */
  43468. hide(): void;
  43469. private _render;
  43470. /**
  43471. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43472. * @param mesh Defines the mesh we want the helper attached to
  43473. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43474. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43475. * @param length Defines the length of the ray
  43476. */
  43477. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43478. /**
  43479. * Detach the ray helper from the mesh it has previously been attached to.
  43480. */
  43481. detachFromMesh(): void;
  43482. private _updateToMesh;
  43483. /**
  43484. * Dispose the helper and release its associated resources.
  43485. */
  43486. dispose(): void;
  43487. }
  43488. }
  43489. declare module "babylonjs/Debug/skeletonViewer" {
  43490. import { Color3 } from "babylonjs/Maths/math";
  43491. import { Scene } from "babylonjs/scene";
  43492. import { Nullable } from "babylonjs/types";
  43493. import { Skeleton } from "babylonjs/Bones/skeleton";
  43494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43495. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43496. /**
  43497. * Class used to render a debug view of a given skeleton
  43498. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43499. */
  43500. export class SkeletonViewer {
  43501. /** defines the skeleton to render */
  43502. skeleton: Skeleton;
  43503. /** defines the mesh attached to the skeleton */
  43504. mesh: AbstractMesh;
  43505. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43506. autoUpdateBonesMatrices: boolean;
  43507. /** defines the rendering group id to use with the viewer */
  43508. renderingGroupId: number;
  43509. /** Gets or sets the color used to render the skeleton */
  43510. color: Color3;
  43511. private _scene;
  43512. private _debugLines;
  43513. private _debugMesh;
  43514. private _isEnabled;
  43515. private _renderFunction;
  43516. private _utilityLayer;
  43517. /**
  43518. * Returns the mesh used to render the bones
  43519. */
  43520. readonly debugMesh: Nullable<LinesMesh>;
  43521. /**
  43522. * Creates a new SkeletonViewer
  43523. * @param skeleton defines the skeleton to render
  43524. * @param mesh defines the mesh attached to the skeleton
  43525. * @param scene defines the hosting scene
  43526. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43527. * @param renderingGroupId defines the rendering group id to use with the viewer
  43528. */
  43529. constructor(
  43530. /** defines the skeleton to render */
  43531. skeleton: Skeleton,
  43532. /** defines the mesh attached to the skeleton */
  43533. mesh: AbstractMesh, scene: Scene,
  43534. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43535. autoUpdateBonesMatrices?: boolean,
  43536. /** defines the rendering group id to use with the viewer */
  43537. renderingGroupId?: number);
  43538. /** Gets or sets a boolean indicating if the viewer is enabled */
  43539. isEnabled: boolean;
  43540. private _getBonePosition;
  43541. private _getLinesForBonesWithLength;
  43542. private _getLinesForBonesNoLength;
  43543. /** Update the viewer to sync with current skeleton state */
  43544. update(): void;
  43545. /** Release associated resources */
  43546. dispose(): void;
  43547. }
  43548. }
  43549. declare module "babylonjs/Debug/index" {
  43550. export * from "babylonjs/Debug/axesViewer";
  43551. export * from "babylonjs/Debug/boneAxesViewer";
  43552. export * from "babylonjs/Debug/debugLayer";
  43553. export * from "babylonjs/Debug/physicsViewer";
  43554. export * from "babylonjs/Debug/rayHelper";
  43555. export * from "babylonjs/Debug/skeletonViewer";
  43556. }
  43557. declare module "babylonjs/Engines/nullEngine" {
  43558. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43559. import { Scene } from "babylonjs/scene";
  43560. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43561. import { Engine } from "babylonjs/Engines/engine";
  43562. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43563. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43564. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43565. import { Effect } from "babylonjs/Materials/effect";
  43566. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43567. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43568. /**
  43569. * Options to create the null engine
  43570. */
  43571. export class NullEngineOptions {
  43572. /**
  43573. * Render width (Default: 512)
  43574. */
  43575. renderWidth: number;
  43576. /**
  43577. * Render height (Default: 256)
  43578. */
  43579. renderHeight: number;
  43580. /**
  43581. * Texture size (Default: 512)
  43582. */
  43583. textureSize: number;
  43584. /**
  43585. * If delta time between frames should be constant
  43586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43587. */
  43588. deterministicLockstep: boolean;
  43589. /**
  43590. * Maximum about of steps between frames (Default: 4)
  43591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43592. */
  43593. lockstepMaxSteps: number;
  43594. }
  43595. /**
  43596. * The null engine class provides support for headless version of babylon.js.
  43597. * This can be used in server side scenario or for testing purposes
  43598. */
  43599. export class NullEngine extends Engine {
  43600. private _options;
  43601. /**
  43602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43603. */
  43604. isDeterministicLockStep(): boolean;
  43605. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43606. getLockstepMaxSteps(): number;
  43607. /**
  43608. * Sets hardware scaling, used to save performance if needed
  43609. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43610. */
  43611. getHardwareScalingLevel(): number;
  43612. constructor(options?: NullEngineOptions);
  43613. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43614. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43615. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43616. getRenderWidth(useScreen?: boolean): number;
  43617. getRenderHeight(useScreen?: boolean): number;
  43618. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43619. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43620. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43621. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43622. bindSamplers(effect: Effect): void;
  43623. enableEffect(effect: Effect): void;
  43624. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43625. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43627. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43628. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43630. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43631. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43632. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43633. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43634. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43635. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43637. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43638. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43639. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43640. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43641. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43642. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43643. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43644. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43645. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43646. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43647. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43648. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43649. bindBuffers(vertexBuffers: {
  43650. [key: string]: VertexBuffer;
  43651. }, indexBuffer: DataBuffer, effect: Effect): void;
  43652. wipeCaches(bruteForce?: boolean): void;
  43653. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43656. /** @hidden */
  43657. _createTexture(): WebGLTexture;
  43658. /** @hidden */
  43659. _releaseTexture(texture: InternalTexture): void;
  43660. 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;
  43661. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43662. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43663. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43664. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43665. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43666. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43667. areAllEffectsReady(): boolean;
  43668. /**
  43669. * @hidden
  43670. * Get the current error code of the webGL context
  43671. * @returns the error code
  43672. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43673. */
  43674. getError(): number;
  43675. /** @hidden */
  43676. _getUnpackAlignement(): number;
  43677. /** @hidden */
  43678. _unpackFlipY(value: boolean): void;
  43679. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43680. /**
  43681. * Updates a dynamic vertex buffer.
  43682. * @param vertexBuffer the vertex buffer to update
  43683. * @param data the data used to update the vertex buffer
  43684. * @param byteOffset the byte offset of the data (optional)
  43685. * @param byteLength the byte length of the data (optional)
  43686. */
  43687. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43688. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43689. /** @hidden */
  43690. _bindTexture(channel: number, texture: InternalTexture): void;
  43691. /** @hidden */
  43692. _releaseBuffer(buffer: DataBuffer): boolean;
  43693. releaseEffects(): void;
  43694. displayLoadingUI(): void;
  43695. hideLoadingUI(): void;
  43696. /** @hidden */
  43697. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43698. /** @hidden */
  43699. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43700. /** @hidden */
  43701. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43702. /** @hidden */
  43703. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43704. }
  43705. }
  43706. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43707. import { Nullable, int } from "babylonjs/types";
  43708. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43709. /** @hidden */
  43710. export class _OcclusionDataStorage {
  43711. /** @hidden */
  43712. occlusionInternalRetryCounter: number;
  43713. /** @hidden */
  43714. isOcclusionQueryInProgress: boolean;
  43715. /** @hidden */
  43716. isOccluded: boolean;
  43717. /** @hidden */
  43718. occlusionRetryCount: number;
  43719. /** @hidden */
  43720. occlusionType: number;
  43721. /** @hidden */
  43722. occlusionQueryAlgorithmType: number;
  43723. }
  43724. module "babylonjs/Engines/engine" {
  43725. interface Engine {
  43726. /**
  43727. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43728. * @return the new query
  43729. */
  43730. createQuery(): WebGLQuery;
  43731. /**
  43732. * Delete and release a webGL query
  43733. * @param query defines the query to delete
  43734. * @return the current engine
  43735. */
  43736. deleteQuery(query: WebGLQuery): Engine;
  43737. /**
  43738. * Check if a given query has resolved and got its value
  43739. * @param query defines the query to check
  43740. * @returns true if the query got its value
  43741. */
  43742. isQueryResultAvailable(query: WebGLQuery): boolean;
  43743. /**
  43744. * Gets the value of a given query
  43745. * @param query defines the query to check
  43746. * @returns the value of the query
  43747. */
  43748. getQueryResult(query: WebGLQuery): number;
  43749. /**
  43750. * Initiates an occlusion query
  43751. * @param algorithmType defines the algorithm to use
  43752. * @param query defines the query to use
  43753. * @returns the current engine
  43754. * @see http://doc.babylonjs.com/features/occlusionquery
  43755. */
  43756. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43757. /**
  43758. * Ends an occlusion query
  43759. * @see http://doc.babylonjs.com/features/occlusionquery
  43760. * @param algorithmType defines the algorithm to use
  43761. * @returns the current engine
  43762. */
  43763. endOcclusionQuery(algorithmType: number): Engine;
  43764. /**
  43765. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43766. * Please note that only one query can be issued at a time
  43767. * @returns a time token used to track the time span
  43768. */
  43769. startTimeQuery(): Nullable<_TimeToken>;
  43770. /**
  43771. * Ends a time query
  43772. * @param token defines the token used to measure the time span
  43773. * @returns the time spent (in ns)
  43774. */
  43775. endTimeQuery(token: _TimeToken): int;
  43776. /** @hidden */
  43777. _currentNonTimestampToken: Nullable<_TimeToken>;
  43778. /** @hidden */
  43779. _createTimeQuery(): WebGLQuery;
  43780. /** @hidden */
  43781. _deleteTimeQuery(query: WebGLQuery): void;
  43782. /** @hidden */
  43783. _getGlAlgorithmType(algorithmType: number): number;
  43784. /** @hidden */
  43785. _getTimeQueryResult(query: WebGLQuery): any;
  43786. /** @hidden */
  43787. _getTimeQueryAvailability(query: WebGLQuery): any;
  43788. }
  43789. }
  43790. module "babylonjs/Meshes/abstractMesh" {
  43791. interface AbstractMesh {
  43792. /**
  43793. * Backing filed
  43794. * @hidden
  43795. */
  43796. __occlusionDataStorage: _OcclusionDataStorage;
  43797. /**
  43798. * Access property
  43799. * @hidden
  43800. */
  43801. _occlusionDataStorage: _OcclusionDataStorage;
  43802. /**
  43803. * 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.
  43804. * The default value is -1 which means don't break the query and wait till the result
  43805. * @see http://doc.babylonjs.com/features/occlusionquery
  43806. */
  43807. occlusionRetryCount: number;
  43808. /**
  43809. * 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:
  43810. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43811. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43812. * * 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.
  43813. * @see http://doc.babylonjs.com/features/occlusionquery
  43814. */
  43815. occlusionType: number;
  43816. /**
  43817. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43818. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43819. * * 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.
  43820. * @see http://doc.babylonjs.com/features/occlusionquery
  43821. */
  43822. occlusionQueryAlgorithmType: number;
  43823. /**
  43824. * 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
  43825. * @see http://doc.babylonjs.com/features/occlusionquery
  43826. */
  43827. isOccluded: boolean;
  43828. /**
  43829. * Flag to check the progress status of the query
  43830. * @see http://doc.babylonjs.com/features/occlusionquery
  43831. */
  43832. isOcclusionQueryInProgress: boolean;
  43833. }
  43834. }
  43835. }
  43836. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43837. import { Nullable } from "babylonjs/types";
  43838. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43839. /** @hidden */
  43840. export var _forceTransformFeedbackToBundle: boolean;
  43841. module "babylonjs/Engines/engine" {
  43842. interface Engine {
  43843. /**
  43844. * Creates a webGL transform feedback object
  43845. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43846. * @returns the webGL transform feedback object
  43847. */
  43848. createTransformFeedback(): WebGLTransformFeedback;
  43849. /**
  43850. * Delete a webGL transform feedback object
  43851. * @param value defines the webGL transform feedback object to delete
  43852. */
  43853. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43854. /**
  43855. * Bind a webGL transform feedback object to the webgl context
  43856. * @param value defines the webGL transform feedback object to bind
  43857. */
  43858. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43859. /**
  43860. * Begins a transform feedback operation
  43861. * @param usePoints defines if points or triangles must be used
  43862. */
  43863. beginTransformFeedback(usePoints: boolean): void;
  43864. /**
  43865. * Ends a transform feedback operation
  43866. */
  43867. endTransformFeedback(): void;
  43868. /**
  43869. * Specify the varyings to use with transform feedback
  43870. * @param program defines the associated webGL program
  43871. * @param value defines the list of strings representing the varying names
  43872. */
  43873. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43874. /**
  43875. * Bind a webGL buffer for a transform feedback operation
  43876. * @param value defines the webGL buffer to bind
  43877. */
  43878. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43879. }
  43880. }
  43881. }
  43882. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43883. import { Scene } from "babylonjs/scene";
  43884. import { Engine } from "babylonjs/Engines/engine";
  43885. import { Texture } from "babylonjs/Materials/Textures/texture";
  43886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43887. import "babylonjs/Engines/Extensions/engine.multiRender";
  43888. /**
  43889. * Creation options of the multi render target texture.
  43890. */
  43891. export interface IMultiRenderTargetOptions {
  43892. /**
  43893. * Define if the texture needs to create mip maps after render.
  43894. */
  43895. generateMipMaps?: boolean;
  43896. /**
  43897. * Define the types of all the draw buffers we want to create
  43898. */
  43899. types?: number[];
  43900. /**
  43901. * Define the sampling modes of all the draw buffers we want to create
  43902. */
  43903. samplingModes?: number[];
  43904. /**
  43905. * Define if a depth buffer is required
  43906. */
  43907. generateDepthBuffer?: boolean;
  43908. /**
  43909. * Define if a stencil buffer is required
  43910. */
  43911. generateStencilBuffer?: boolean;
  43912. /**
  43913. * Define if a depth texture is required instead of a depth buffer
  43914. */
  43915. generateDepthTexture?: boolean;
  43916. /**
  43917. * Define the number of desired draw buffers
  43918. */
  43919. textureCount?: number;
  43920. /**
  43921. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43922. */
  43923. doNotChangeAspectRatio?: boolean;
  43924. /**
  43925. * Define the default type of the buffers we are creating
  43926. */
  43927. defaultType?: number;
  43928. }
  43929. /**
  43930. * A multi render target, like a render target provides the ability to render to a texture.
  43931. * Unlike the render target, it can render to several draw buffers in one draw.
  43932. * This is specially interesting in deferred rendering or for any effects requiring more than
  43933. * just one color from a single pass.
  43934. */
  43935. export class MultiRenderTarget extends RenderTargetTexture {
  43936. private _internalTextures;
  43937. private _textures;
  43938. private _multiRenderTargetOptions;
  43939. /**
  43940. * Get if draw buffers are currently supported by the used hardware and browser.
  43941. */
  43942. readonly isSupported: boolean;
  43943. /**
  43944. * Get the list of textures generated by the multi render target.
  43945. */
  43946. readonly textures: Texture[];
  43947. /**
  43948. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43949. */
  43950. readonly depthTexture: Texture;
  43951. /**
  43952. * Set the wrapping mode on U of all the textures we are rendering to.
  43953. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43954. */
  43955. wrapU: number;
  43956. /**
  43957. * Set the wrapping mode on V of all the textures we are rendering to.
  43958. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43959. */
  43960. wrapV: number;
  43961. /**
  43962. * Instantiate a new multi render target texture.
  43963. * A multi render target, like a render target provides the ability to render to a texture.
  43964. * Unlike the render target, it can render to several draw buffers in one draw.
  43965. * This is specially interesting in deferred rendering or for any effects requiring more than
  43966. * just one color from a single pass.
  43967. * @param name Define the name of the texture
  43968. * @param size Define the size of the buffers to render to
  43969. * @param count Define the number of target we are rendering into
  43970. * @param scene Define the scene the texture belongs to
  43971. * @param options Define the options used to create the multi render target
  43972. */
  43973. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43974. /** @hidden */
  43975. _rebuild(): void;
  43976. private _createInternalTextures;
  43977. private _createTextures;
  43978. /**
  43979. * Define the number of samples used if MSAA is enabled.
  43980. */
  43981. samples: number;
  43982. /**
  43983. * Resize all the textures in the multi render target.
  43984. * Be carrefull as it will recreate all the data in the new texture.
  43985. * @param size Define the new size
  43986. */
  43987. resize(size: any): void;
  43988. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43989. /**
  43990. * Dispose the render targets and their associated resources
  43991. */
  43992. dispose(): void;
  43993. /**
  43994. * Release all the underlying texture used as draw buffers.
  43995. */
  43996. releaseInternalTextures(): void;
  43997. }
  43998. }
  43999. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  44000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44001. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  44002. import { Nullable } from "babylonjs/types";
  44003. module "babylonjs/Engines/engine" {
  44004. interface Engine {
  44005. /**
  44006. * Unbind a list of render target textures from the webGL context
  44007. * This is used only when drawBuffer extension or webGL2 are active
  44008. * @param textures defines the render target textures to unbind
  44009. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44010. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44011. */
  44012. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44013. /**
  44014. * Create a multi render target texture
  44015. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44016. * @param size defines the size of the texture
  44017. * @param options defines the creation options
  44018. * @returns the cube texture as an InternalTexture
  44019. */
  44020. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44021. /**
  44022. * Update the sample count for a given multiple render target texture
  44023. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44024. * @param textures defines the textures to update
  44025. * @param samples defines the sample count to set
  44026. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44027. */
  44028. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44029. }
  44030. }
  44031. }
  44032. declare module "babylonjs/Engines/Extensions/index" {
  44033. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  44034. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  44035. export * from "babylonjs/Engines/Extensions/engine.multiview";
  44036. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  44037. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  44038. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  44039. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  44040. export * from "babylonjs/Engines/Extensions/engine.webVR";
  44041. }
  44042. declare module "babylonjs/Engines/index" {
  44043. export * from "babylonjs/Engines/constants";
  44044. export * from "babylonjs/Engines/engine";
  44045. export * from "babylonjs/Engines/engineStore";
  44046. export * from "babylonjs/Engines/nullEngine";
  44047. export * from "babylonjs/Engines/Extensions/index";
  44048. export * from "babylonjs/Engines/IPipelineContext";
  44049. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  44050. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  44051. }
  44052. declare module "babylonjs/Events/clipboardEvents" {
  44053. /**
  44054. * Gather the list of clipboard event types as constants.
  44055. */
  44056. export class ClipboardEventTypes {
  44057. /**
  44058. * The clipboard event is fired when a copy command is active (pressed).
  44059. */
  44060. static readonly COPY: number;
  44061. /**
  44062. * The clipboard event is fired when a cut command is active (pressed).
  44063. */
  44064. static readonly CUT: number;
  44065. /**
  44066. * The clipboard event is fired when a paste command is active (pressed).
  44067. */
  44068. static readonly PASTE: number;
  44069. }
  44070. /**
  44071. * This class is used to store clipboard related info for the onClipboardObservable event.
  44072. */
  44073. export class ClipboardInfo {
  44074. /**
  44075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44076. */
  44077. type: number;
  44078. /**
  44079. * Defines the related dom event
  44080. */
  44081. event: ClipboardEvent;
  44082. /**
  44083. *Creates an instance of ClipboardInfo.
  44084. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44085. * @param event Defines the related dom event
  44086. */
  44087. constructor(
  44088. /**
  44089. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44090. */
  44091. type: number,
  44092. /**
  44093. * Defines the related dom event
  44094. */
  44095. event: ClipboardEvent);
  44096. /**
  44097. * Get the clipboard event's type from the keycode.
  44098. * @param keyCode Defines the keyCode for the current keyboard event.
  44099. * @return {number}
  44100. */
  44101. static GetTypeFromCharacter(keyCode: number): number;
  44102. }
  44103. }
  44104. declare module "babylonjs/Events/index" {
  44105. export * from "babylonjs/Events/keyboardEvents";
  44106. export * from "babylonjs/Events/pointerEvents";
  44107. export * from "babylonjs/Events/clipboardEvents";
  44108. }
  44109. declare module "babylonjs/Loading/sceneLoader" {
  44110. import { Observable } from "babylonjs/Misc/observable";
  44111. import { Nullable } from "babylonjs/types";
  44112. import { Scene } from "babylonjs/scene";
  44113. import { Engine } from "babylonjs/Engines/engine";
  44114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44116. import { AssetContainer } from "babylonjs/assetContainer";
  44117. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44118. import { Skeleton } from "babylonjs/Bones/skeleton";
  44119. /**
  44120. * Class used to represent data loading progression
  44121. */
  44122. export class SceneLoaderProgressEvent {
  44123. /** defines if data length to load can be evaluated */
  44124. readonly lengthComputable: boolean;
  44125. /** defines the loaded data length */
  44126. readonly loaded: number;
  44127. /** defines the data length to load */
  44128. readonly total: number;
  44129. /**
  44130. * Create a new progress event
  44131. * @param lengthComputable defines if data length to load can be evaluated
  44132. * @param loaded defines the loaded data length
  44133. * @param total defines the data length to load
  44134. */
  44135. constructor(
  44136. /** defines if data length to load can be evaluated */
  44137. lengthComputable: boolean,
  44138. /** defines the loaded data length */
  44139. loaded: number,
  44140. /** defines the data length to load */
  44141. total: number);
  44142. /**
  44143. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44144. * @param event defines the source event
  44145. * @returns a new SceneLoaderProgressEvent
  44146. */
  44147. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44148. }
  44149. /**
  44150. * Interface used by SceneLoader plugins to define supported file extensions
  44151. */
  44152. export interface ISceneLoaderPluginExtensions {
  44153. /**
  44154. * Defines the list of supported extensions
  44155. */
  44156. [extension: string]: {
  44157. isBinary: boolean;
  44158. };
  44159. }
  44160. /**
  44161. * Interface used by SceneLoader plugin factory
  44162. */
  44163. export interface ISceneLoaderPluginFactory {
  44164. /**
  44165. * Defines the name of the factory
  44166. */
  44167. name: string;
  44168. /**
  44169. * Function called to create a new plugin
  44170. * @return the new plugin
  44171. */
  44172. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44173. /**
  44174. * Boolean indicating if the plugin can direct load specific data
  44175. */
  44176. canDirectLoad?: (data: string) => boolean;
  44177. }
  44178. /**
  44179. * Interface used to define a SceneLoader plugin
  44180. */
  44181. export interface ISceneLoaderPlugin {
  44182. /**
  44183. * The friendly name of this plugin.
  44184. */
  44185. name: string;
  44186. /**
  44187. * The file extensions supported by this plugin.
  44188. */
  44189. extensions: string | ISceneLoaderPluginExtensions;
  44190. /**
  44191. * Import meshes into a scene.
  44192. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44193. * @param scene The scene to import into
  44194. * @param data The data to import
  44195. * @param rootUrl The root url for scene and resources
  44196. * @param meshes The meshes array to import into
  44197. * @param particleSystems The particle systems array to import into
  44198. * @param skeletons The skeletons array to import into
  44199. * @param onError The callback when import fails
  44200. * @returns True if successful or false otherwise
  44201. */
  44202. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44203. /**
  44204. * Load into a scene.
  44205. * @param scene The scene to load into
  44206. * @param data The data to import
  44207. * @param rootUrl The root url for scene and resources
  44208. * @param onError The callback when import fails
  44209. * @returns true if successful or false otherwise
  44210. */
  44211. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44212. /**
  44213. * The callback that returns true if the data can be directly loaded.
  44214. */
  44215. canDirectLoad?: (data: string) => boolean;
  44216. /**
  44217. * The callback that allows custom handling of the root url based on the response url.
  44218. */
  44219. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44220. /**
  44221. * Load into an asset container.
  44222. * @param scene The scene to load into
  44223. * @param data The data to import
  44224. * @param rootUrl The root url for scene and resources
  44225. * @param onError The callback when import fails
  44226. * @returns The loaded asset container
  44227. */
  44228. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44229. }
  44230. /**
  44231. * Interface used to define an async SceneLoader plugin
  44232. */
  44233. export interface ISceneLoaderPluginAsync {
  44234. /**
  44235. * The friendly name of this plugin.
  44236. */
  44237. name: string;
  44238. /**
  44239. * The file extensions supported by this plugin.
  44240. */
  44241. extensions: string | ISceneLoaderPluginExtensions;
  44242. /**
  44243. * Import meshes into a scene.
  44244. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44245. * @param scene The scene to import into
  44246. * @param data The data to import
  44247. * @param rootUrl The root url for scene and resources
  44248. * @param onProgress The callback when the load progresses
  44249. * @param fileName Defines the name of the file to load
  44250. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44251. */
  44252. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44253. meshes: AbstractMesh[];
  44254. particleSystems: IParticleSystem[];
  44255. skeletons: Skeleton[];
  44256. animationGroups: AnimationGroup[];
  44257. }>;
  44258. /**
  44259. * Load into a scene.
  44260. * @param scene The scene to load into
  44261. * @param data The data to import
  44262. * @param rootUrl The root url for scene and resources
  44263. * @param onProgress The callback when the load progresses
  44264. * @param fileName Defines the name of the file to load
  44265. * @returns Nothing
  44266. */
  44267. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44268. /**
  44269. * The callback that returns true if the data can be directly loaded.
  44270. */
  44271. canDirectLoad?: (data: string) => boolean;
  44272. /**
  44273. * The callback that allows custom handling of the root url based on the response url.
  44274. */
  44275. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44276. /**
  44277. * Load into an asset container.
  44278. * @param scene The scene to load into
  44279. * @param data The data to import
  44280. * @param rootUrl The root url for scene and resources
  44281. * @param onProgress The callback when the load progresses
  44282. * @param fileName Defines the name of the file to load
  44283. * @returns The loaded asset container
  44284. */
  44285. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44286. }
  44287. /**
  44288. * Class used to load scene from various file formats using registered plugins
  44289. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44290. */
  44291. export class SceneLoader {
  44292. /**
  44293. * No logging while loading
  44294. */
  44295. static readonly NO_LOGGING: number;
  44296. /**
  44297. * Minimal logging while loading
  44298. */
  44299. static readonly MINIMAL_LOGGING: number;
  44300. /**
  44301. * Summary logging while loading
  44302. */
  44303. static readonly SUMMARY_LOGGING: number;
  44304. /**
  44305. * Detailled logging while loading
  44306. */
  44307. static readonly DETAILED_LOGGING: number;
  44308. /**
  44309. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44310. */
  44311. static ForceFullSceneLoadingForIncremental: boolean;
  44312. /**
  44313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44314. */
  44315. static ShowLoadingScreen: boolean;
  44316. /**
  44317. * Defines the current logging level (while loading the scene)
  44318. * @ignorenaming
  44319. */
  44320. static loggingLevel: number;
  44321. /**
  44322. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44323. */
  44324. static CleanBoneMatrixWeights: boolean;
  44325. /**
  44326. * Event raised when a plugin is used to load a scene
  44327. */
  44328. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44329. private static _registeredPlugins;
  44330. private static _getDefaultPlugin;
  44331. private static _getPluginForExtension;
  44332. private static _getPluginForDirectLoad;
  44333. private static _getPluginForFilename;
  44334. private static _getDirectLoad;
  44335. private static _loadData;
  44336. private static _getFileInfo;
  44337. /**
  44338. * Gets a plugin that can load the given extension
  44339. * @param extension defines the extension to load
  44340. * @returns a plugin or null if none works
  44341. */
  44342. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44343. /**
  44344. * Gets a boolean indicating that the given extension can be loaded
  44345. * @param extension defines the extension to load
  44346. * @returns true if the extension is supported
  44347. */
  44348. static IsPluginForExtensionAvailable(extension: string): boolean;
  44349. /**
  44350. * Adds a new plugin to the list of registered plugins
  44351. * @param plugin defines the plugin to add
  44352. */
  44353. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44354. /**
  44355. * Import meshes into a scene
  44356. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44357. * @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)
  44358. * @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)
  44359. * @param scene the instance of BABYLON.Scene to append to
  44360. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44361. * @param onProgress a callback with a progress event for each file being loaded
  44362. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44363. * @param pluginExtension the extension used to determine the plugin
  44364. * @returns The loaded plugin
  44365. */
  44366. 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>;
  44367. /**
  44368. * Import meshes into a scene
  44369. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44370. * @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)
  44371. * @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)
  44372. * @param scene the instance of BABYLON.Scene to append to
  44373. * @param onProgress a callback with a progress event for each file being loaded
  44374. * @param pluginExtension the extension used to determine the plugin
  44375. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44376. */
  44377. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44378. meshes: AbstractMesh[];
  44379. particleSystems: IParticleSystem[];
  44380. skeletons: Skeleton[];
  44381. animationGroups: AnimationGroup[];
  44382. }>;
  44383. /**
  44384. * Load a scene
  44385. * @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)
  44386. * @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)
  44387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44388. * @param onSuccess a callback with the scene when import succeeds
  44389. * @param onProgress a callback with a progress event for each file being loaded
  44390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44391. * @param pluginExtension the extension used to determine the plugin
  44392. * @returns The loaded plugin
  44393. */
  44394. 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>;
  44395. /**
  44396. * Load a scene
  44397. * @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)
  44398. * @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)
  44399. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44400. * @param onProgress a callback with a progress event for each file being loaded
  44401. * @param pluginExtension the extension used to determine the plugin
  44402. * @returns The loaded scene
  44403. */
  44404. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44405. /**
  44406. * Append a scene
  44407. * @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)
  44408. * @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)
  44409. * @param scene is the instance of BABYLON.Scene to append to
  44410. * @param onSuccess a callback with the scene when import succeeds
  44411. * @param onProgress a callback with a progress event for each file being loaded
  44412. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44413. * @param pluginExtension the extension used to determine the plugin
  44414. * @returns The loaded plugin
  44415. */
  44416. 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>;
  44417. /**
  44418. * Append a scene
  44419. * @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)
  44420. * @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)
  44421. * @param scene is the instance of BABYLON.Scene to append to
  44422. * @param onProgress a callback with a progress event for each file being loaded
  44423. * @param pluginExtension the extension used to determine the plugin
  44424. * @returns The given scene
  44425. */
  44426. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44427. /**
  44428. * Load a scene into an asset container
  44429. * @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)
  44430. * @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)
  44431. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44432. * @param onSuccess a callback with the scene when import succeeds
  44433. * @param onProgress a callback with a progress event for each file being loaded
  44434. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44435. * @param pluginExtension the extension used to determine the plugin
  44436. * @returns The loaded plugin
  44437. */
  44438. 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>;
  44439. /**
  44440. * Load a scene into an asset container
  44441. * @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)
  44442. * @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)
  44443. * @param scene is the instance of Scene to append to
  44444. * @param onProgress a callback with a progress event for each file being loaded
  44445. * @param pluginExtension the extension used to determine the plugin
  44446. * @returns The loaded asset container
  44447. */
  44448. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44449. }
  44450. }
  44451. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44452. import { Scene } from "babylonjs/scene";
  44453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44454. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44455. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44456. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44457. /**
  44458. * Google Daydream controller
  44459. */
  44460. export class DaydreamController extends WebVRController {
  44461. /**
  44462. * Base Url for the controller model.
  44463. */
  44464. static MODEL_BASE_URL: string;
  44465. /**
  44466. * File name for the controller model.
  44467. */
  44468. static MODEL_FILENAME: string;
  44469. /**
  44470. * Gamepad Id prefix used to identify Daydream Controller.
  44471. */
  44472. static readonly GAMEPAD_ID_PREFIX: string;
  44473. /**
  44474. * Creates a new DaydreamController from a gamepad
  44475. * @param vrGamepad the gamepad that the controller should be created from
  44476. */
  44477. constructor(vrGamepad: any);
  44478. /**
  44479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44480. * @param scene scene in which to add meshes
  44481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44482. */
  44483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44484. /**
  44485. * Called once for each button that changed state since the last frame
  44486. * @param buttonIdx Which button index changed
  44487. * @param state New state of the button
  44488. * @param changes Which properties on the state changed since last frame
  44489. */
  44490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44491. }
  44492. }
  44493. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44494. import { Scene } from "babylonjs/scene";
  44495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44496. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44497. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44498. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44499. /**
  44500. * Gear VR Controller
  44501. */
  44502. export class GearVRController extends WebVRController {
  44503. /**
  44504. * Base Url for the controller model.
  44505. */
  44506. static MODEL_BASE_URL: string;
  44507. /**
  44508. * File name for the controller model.
  44509. */
  44510. static MODEL_FILENAME: string;
  44511. /**
  44512. * Gamepad Id prefix used to identify this controller.
  44513. */
  44514. static readonly GAMEPAD_ID_PREFIX: string;
  44515. private readonly _buttonIndexToObservableNameMap;
  44516. /**
  44517. * Creates a new GearVRController from a gamepad
  44518. * @param vrGamepad the gamepad that the controller should be created from
  44519. */
  44520. constructor(vrGamepad: any);
  44521. /**
  44522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44523. * @param scene scene in which to add meshes
  44524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44525. */
  44526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44527. /**
  44528. * Called once for each button that changed state since the last frame
  44529. * @param buttonIdx Which button index changed
  44530. * @param state New state of the button
  44531. * @param changes Which properties on the state changed since last frame
  44532. */
  44533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44534. }
  44535. }
  44536. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44537. import { Scene } from "babylonjs/scene";
  44538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44539. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44540. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44541. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44542. /**
  44543. * Generic Controller
  44544. */
  44545. export class GenericController extends WebVRController {
  44546. /**
  44547. * Base Url for the controller model.
  44548. */
  44549. static readonly MODEL_BASE_URL: string;
  44550. /**
  44551. * File name for the controller model.
  44552. */
  44553. static readonly MODEL_FILENAME: string;
  44554. /**
  44555. * Creates a new GenericController from a gamepad
  44556. * @param vrGamepad the gamepad that the controller should be created from
  44557. */
  44558. constructor(vrGamepad: any);
  44559. /**
  44560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44561. * @param scene scene in which to add meshes
  44562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44563. */
  44564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44565. /**
  44566. * Called once for each button that changed state since the last frame
  44567. * @param buttonIdx Which button index changed
  44568. * @param state New state of the button
  44569. * @param changes Which properties on the state changed since last frame
  44570. */
  44571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44572. }
  44573. }
  44574. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44575. import { Observable } from "babylonjs/Misc/observable";
  44576. import { Scene } from "babylonjs/scene";
  44577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44578. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44579. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44580. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44581. /**
  44582. * Oculus Touch Controller
  44583. */
  44584. export class OculusTouchController extends WebVRController {
  44585. /**
  44586. * Base Url for the controller model.
  44587. */
  44588. static MODEL_BASE_URL: string;
  44589. /**
  44590. * File name for the left controller model.
  44591. */
  44592. static MODEL_LEFT_FILENAME: string;
  44593. /**
  44594. * File name for the right controller model.
  44595. */
  44596. static MODEL_RIGHT_FILENAME: string;
  44597. /**
  44598. * Base Url for the Quest controller model.
  44599. */
  44600. static QUEST_MODEL_BASE_URL: string;
  44601. /**
  44602. * @hidden
  44603. * If the controllers are running on a device that needs the updated Quest controller models
  44604. */
  44605. static _IsQuest: boolean;
  44606. /**
  44607. * Fired when the secondary trigger on this controller is modified
  44608. */
  44609. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44610. /**
  44611. * Fired when the thumb rest on this controller is modified
  44612. */
  44613. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44614. /**
  44615. * Creates a new OculusTouchController from a gamepad
  44616. * @param vrGamepad the gamepad that the controller should be created from
  44617. */
  44618. constructor(vrGamepad: any);
  44619. /**
  44620. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44621. * @param scene scene in which to add meshes
  44622. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44623. */
  44624. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44625. /**
  44626. * Fired when the A button on this controller is modified
  44627. */
  44628. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44629. /**
  44630. * Fired when the B button on this controller is modified
  44631. */
  44632. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44633. /**
  44634. * Fired when the X button on this controller is modified
  44635. */
  44636. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44637. /**
  44638. * Fired when the Y button on this controller is modified
  44639. */
  44640. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44641. /**
  44642. * Called once for each button that changed state since the last frame
  44643. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44644. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44645. * 2) secondary trigger (same)
  44646. * 3) A (right) X (left), touch, pressed = value
  44647. * 4) B / Y
  44648. * 5) thumb rest
  44649. * @param buttonIdx Which button index changed
  44650. * @param state New state of the button
  44651. * @param changes Which properties on the state changed since last frame
  44652. */
  44653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44654. }
  44655. }
  44656. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44657. import { Scene } from "babylonjs/scene";
  44658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44659. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44660. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44661. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44662. import { Observable } from "babylonjs/Misc/observable";
  44663. /**
  44664. * Vive Controller
  44665. */
  44666. export class ViveController extends WebVRController {
  44667. /**
  44668. * Base Url for the controller model.
  44669. */
  44670. static MODEL_BASE_URL: string;
  44671. /**
  44672. * File name for the controller model.
  44673. */
  44674. static MODEL_FILENAME: string;
  44675. /**
  44676. * Creates a new ViveController from a gamepad
  44677. * @param vrGamepad the gamepad that the controller should be created from
  44678. */
  44679. constructor(vrGamepad: any);
  44680. /**
  44681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44682. * @param scene scene in which to add meshes
  44683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44684. */
  44685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44686. /**
  44687. * Fired when the left button on this controller is modified
  44688. */
  44689. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44690. /**
  44691. * Fired when the right button on this controller is modified
  44692. */
  44693. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44694. /**
  44695. * Fired when the menu button on this controller is modified
  44696. */
  44697. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44698. /**
  44699. * Called once for each button that changed state since the last frame
  44700. * Vive mapping:
  44701. * 0: touchpad
  44702. * 1: trigger
  44703. * 2: left AND right buttons
  44704. * 3: menu button
  44705. * @param buttonIdx Which button index changed
  44706. * @param state New state of the button
  44707. * @param changes Which properties on the state changed since last frame
  44708. */
  44709. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44710. }
  44711. }
  44712. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44713. import { Observable } from "babylonjs/Misc/observable";
  44714. import { Scene } from "babylonjs/scene";
  44715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44716. import { Ray } from "babylonjs/Culling/ray";
  44717. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44718. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44719. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44720. /**
  44721. * Defines the WindowsMotionController object that the state of the windows motion controller
  44722. */
  44723. export class WindowsMotionController extends WebVRController {
  44724. /**
  44725. * The base url used to load the left and right controller models
  44726. */
  44727. static MODEL_BASE_URL: string;
  44728. /**
  44729. * The name of the left controller model file
  44730. */
  44731. static MODEL_LEFT_FILENAME: string;
  44732. /**
  44733. * The name of the right controller model file
  44734. */
  44735. static MODEL_RIGHT_FILENAME: string;
  44736. /**
  44737. * The controller name prefix for this controller type
  44738. */
  44739. static readonly GAMEPAD_ID_PREFIX: string;
  44740. /**
  44741. * The controller id pattern for this controller type
  44742. */
  44743. private static readonly GAMEPAD_ID_PATTERN;
  44744. private _loadedMeshInfo;
  44745. private readonly _mapping;
  44746. /**
  44747. * Fired when the trackpad on this controller is clicked
  44748. */
  44749. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44750. /**
  44751. * Fired when the trackpad on this controller is modified
  44752. */
  44753. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44754. /**
  44755. * The current x and y values of this controller's trackpad
  44756. */
  44757. trackpad: StickValues;
  44758. /**
  44759. * Creates a new WindowsMotionController from a gamepad
  44760. * @param vrGamepad the gamepad that the controller should be created from
  44761. */
  44762. constructor(vrGamepad: any);
  44763. /**
  44764. * Fired when the trigger on this controller is modified
  44765. */
  44766. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44767. /**
  44768. * Fired when the menu button on this controller is modified
  44769. */
  44770. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44771. /**
  44772. * Fired when the grip button on this controller is modified
  44773. */
  44774. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44775. /**
  44776. * Fired when the thumbstick button on this controller is modified
  44777. */
  44778. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44779. /**
  44780. * Fired when the touchpad button on this controller is modified
  44781. */
  44782. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44783. /**
  44784. * Fired when the touchpad values on this controller are modified
  44785. */
  44786. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44787. private _updateTrackpad;
  44788. /**
  44789. * Called once per frame by the engine.
  44790. */
  44791. update(): void;
  44792. /**
  44793. * Called once for each button that changed state since the last frame
  44794. * @param buttonIdx Which button index changed
  44795. * @param state New state of the button
  44796. * @param changes Which properties on the state changed since last frame
  44797. */
  44798. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44799. /**
  44800. * Moves the buttons on the controller mesh based on their current state
  44801. * @param buttonName the name of the button to move
  44802. * @param buttonValue the value of the button which determines the buttons new position
  44803. */
  44804. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44805. /**
  44806. * Moves the axis on the controller mesh based on its current state
  44807. * @param axis the index of the axis
  44808. * @param axisValue the value of the axis which determines the meshes new position
  44809. * @hidden
  44810. */
  44811. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44812. /**
  44813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44814. * @param scene scene in which to add meshes
  44815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44816. */
  44817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44818. /**
  44819. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44820. * can be transformed by button presses and axes values, based on this._mapping.
  44821. *
  44822. * @param scene scene in which the meshes exist
  44823. * @param meshes list of meshes that make up the controller model to process
  44824. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44825. */
  44826. private processModel;
  44827. private createMeshInfo;
  44828. /**
  44829. * Gets the ray of the controller in the direction the controller is pointing
  44830. * @param length the length the resulting ray should be
  44831. * @returns a ray in the direction the controller is pointing
  44832. */
  44833. getForwardRay(length?: number): Ray;
  44834. /**
  44835. * Disposes of the controller
  44836. */
  44837. dispose(): void;
  44838. }
  44839. }
  44840. declare module "babylonjs/Gamepads/Controllers/index" {
  44841. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44842. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44843. export * from "babylonjs/Gamepads/Controllers/genericController";
  44844. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44845. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44846. export * from "babylonjs/Gamepads/Controllers/viveController";
  44847. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44848. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44849. }
  44850. declare module "babylonjs/Gamepads/index" {
  44851. export * from "babylonjs/Gamepads/Controllers/index";
  44852. export * from "babylonjs/Gamepads/gamepad";
  44853. export * from "babylonjs/Gamepads/gamepadManager";
  44854. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44855. export * from "babylonjs/Gamepads/xboxGamepad";
  44856. }
  44857. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44858. import { Scene } from "babylonjs/scene";
  44859. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44860. import { Mesh } from "babylonjs/Meshes/mesh";
  44861. import { Nullable } from "babylonjs/types";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class PolyhedronBuilder {
  44866. /**
  44867. * Creates a polyhedron mesh
  44868. * * 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
  44869. * * The parameter `size` (positive float, default 1) sets the polygon size
  44870. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44871. * * 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`
  44872. * * 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
  44873. * * 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)`)
  44874. * * 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
  44875. * * 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
  44876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44877. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44879. * @param name defines the name of the mesh
  44880. * @param options defines the options used to create the mesh
  44881. * @param scene defines the hosting scene
  44882. * @returns the polyhedron mesh
  44883. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44884. */
  44885. static CreatePolyhedron(name: string, options: {
  44886. type?: number;
  44887. size?: number;
  44888. sizeX?: number;
  44889. sizeY?: number;
  44890. sizeZ?: number;
  44891. custom?: any;
  44892. faceUV?: Vector4[];
  44893. faceColors?: Color4[];
  44894. flat?: boolean;
  44895. updatable?: boolean;
  44896. sideOrientation?: number;
  44897. frontUVs?: Vector4;
  44898. backUVs?: Vector4;
  44899. }, scene?: Nullable<Scene>): Mesh;
  44900. }
  44901. }
  44902. declare module "babylonjs/Gizmos/scaleGizmo" {
  44903. import { Observable } from "babylonjs/Misc/observable";
  44904. import { Nullable } from "babylonjs/types";
  44905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44906. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44907. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44909. /**
  44910. * Gizmo that enables scaling a mesh along 3 axis
  44911. */
  44912. export class ScaleGizmo extends Gizmo {
  44913. /**
  44914. * Internal gizmo used for interactions on the x axis
  44915. */
  44916. xGizmo: AxisScaleGizmo;
  44917. /**
  44918. * Internal gizmo used for interactions on the y axis
  44919. */
  44920. yGizmo: AxisScaleGizmo;
  44921. /**
  44922. * Internal gizmo used for interactions on the z axis
  44923. */
  44924. zGizmo: AxisScaleGizmo;
  44925. /**
  44926. * Internal gizmo used to scale all axis equally
  44927. */
  44928. uniformScaleGizmo: AxisScaleGizmo;
  44929. private _meshAttached;
  44930. private _updateGizmoRotationToMatchAttachedMesh;
  44931. private _snapDistance;
  44932. private _scaleRatio;
  44933. private _uniformScalingMesh;
  44934. private _octahedron;
  44935. /** Fires an event when any of it's sub gizmos are dragged */
  44936. onDragStartObservable: Observable<unknown>;
  44937. /** Fires an event when any of it's sub gizmos are released from dragging */
  44938. onDragEndObservable: Observable<unknown>;
  44939. attachedMesh: Nullable<AbstractMesh>;
  44940. /**
  44941. * Creates a ScaleGizmo
  44942. * @param gizmoLayer The utility layer the gizmo will be added to
  44943. */
  44944. constructor(gizmoLayer?: UtilityLayerRenderer);
  44945. updateGizmoRotationToMatchAttachedMesh: boolean;
  44946. /**
  44947. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44948. */
  44949. snapDistance: number;
  44950. /**
  44951. * Ratio for the scale of the gizmo (Default: 1)
  44952. */
  44953. scaleRatio: number;
  44954. /**
  44955. * Disposes of the gizmo
  44956. */
  44957. dispose(): void;
  44958. }
  44959. }
  44960. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44961. import { Observable } from "babylonjs/Misc/observable";
  44962. import { Nullable } from "babylonjs/types";
  44963. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44965. import { Mesh } from "babylonjs/Meshes/mesh";
  44966. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44967. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44968. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44969. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44970. /**
  44971. * Single axis scale gizmo
  44972. */
  44973. export class AxisScaleGizmo extends Gizmo {
  44974. /**
  44975. * Drag behavior responsible for the gizmos dragging interactions
  44976. */
  44977. dragBehavior: PointerDragBehavior;
  44978. private _pointerObserver;
  44979. /**
  44980. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44981. */
  44982. snapDistance: number;
  44983. /**
  44984. * Event that fires each time the gizmo snaps to a new location.
  44985. * * snapDistance is the the change in distance
  44986. */
  44987. onSnapObservable: Observable<{
  44988. snapDistance: number;
  44989. }>;
  44990. /**
  44991. * If the scaling operation should be done on all axis (default: false)
  44992. */
  44993. uniformScaling: boolean;
  44994. private _isEnabled;
  44995. private _parent;
  44996. private _arrow;
  44997. private _coloredMaterial;
  44998. private _hoverMaterial;
  44999. /**
  45000. * Creates an AxisScaleGizmo
  45001. * @param gizmoLayer The utility layer the gizmo will be added to
  45002. * @param dragAxis The axis which the gizmo will be able to scale on
  45003. * @param color The color of the gizmo
  45004. */
  45005. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45006. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45007. /**
  45008. * If the gizmo is enabled
  45009. */
  45010. isEnabled: boolean;
  45011. /**
  45012. * Disposes of the gizmo
  45013. */
  45014. dispose(): void;
  45015. /**
  45016. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45017. * @param mesh The mesh to replace the default mesh of the gizmo
  45018. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45019. */
  45020. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45021. }
  45022. }
  45023. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45024. import { Observable } from "babylonjs/Misc/observable";
  45025. import { Nullable } from "babylonjs/types";
  45026. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45028. import { Mesh } from "babylonjs/Meshes/mesh";
  45029. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45030. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45031. import "babylonjs/Meshes/Builders/boxBuilder";
  45032. /**
  45033. * Bounding box gizmo
  45034. */
  45035. export class BoundingBoxGizmo extends Gizmo {
  45036. private _lineBoundingBox;
  45037. private _rotateSpheresParent;
  45038. private _scaleBoxesParent;
  45039. private _boundingDimensions;
  45040. private _renderObserver;
  45041. private _pointerObserver;
  45042. private _scaleDragSpeed;
  45043. private _tmpQuaternion;
  45044. private _tmpVector;
  45045. private _tmpRotationMatrix;
  45046. /**
  45047. * 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)
  45048. */
  45049. ignoreChildren: boolean;
  45050. /**
  45051. * 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)
  45052. */
  45053. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45054. /**
  45055. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45056. */
  45057. rotationSphereSize: number;
  45058. /**
  45059. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45060. */
  45061. scaleBoxSize: number;
  45062. /**
  45063. * 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)
  45064. */
  45065. fixedDragMeshScreenSize: boolean;
  45066. /**
  45067. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45068. */
  45069. fixedDragMeshScreenSizeDistanceFactor: number;
  45070. /**
  45071. * Fired when a rotation sphere or scale box is dragged
  45072. */
  45073. onDragStartObservable: Observable<{}>;
  45074. /**
  45075. * Fired when a scale box is dragged
  45076. */
  45077. onScaleBoxDragObservable: Observable<{}>;
  45078. /**
  45079. * Fired when a scale box drag is ended
  45080. */
  45081. onScaleBoxDragEndObservable: Observable<{}>;
  45082. /**
  45083. * Fired when a rotation sphere is dragged
  45084. */
  45085. onRotationSphereDragObservable: Observable<{}>;
  45086. /**
  45087. * Fired when a rotation sphere drag is ended
  45088. */
  45089. onRotationSphereDragEndObservable: Observable<{}>;
  45090. /**
  45091. * 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)
  45092. */
  45093. scalePivot: Nullable<Vector3>;
  45094. /**
  45095. * Mesh used as a pivot to rotate the attached mesh
  45096. */
  45097. private _anchorMesh;
  45098. private _existingMeshScale;
  45099. private _dragMesh;
  45100. private pointerDragBehavior;
  45101. private coloredMaterial;
  45102. private hoverColoredMaterial;
  45103. /**
  45104. * Sets the color of the bounding box gizmo
  45105. * @param color the color to set
  45106. */
  45107. setColor(color: Color3): void;
  45108. /**
  45109. * Creates an BoundingBoxGizmo
  45110. * @param gizmoLayer The utility layer the gizmo will be added to
  45111. * @param color The color of the gizmo
  45112. */
  45113. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45114. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45115. private _selectNode;
  45116. /**
  45117. * Updates the bounding box information for the Gizmo
  45118. */
  45119. updateBoundingBox(): void;
  45120. private _updateRotationSpheres;
  45121. private _updateScaleBoxes;
  45122. /**
  45123. * Enables rotation on the specified axis and disables rotation on the others
  45124. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45125. */
  45126. setEnabledRotationAxis(axis: string): void;
  45127. /**
  45128. * Enables/disables scaling
  45129. * @param enable if scaling should be enabled
  45130. */
  45131. setEnabledScaling(enable: boolean): void;
  45132. private _updateDummy;
  45133. /**
  45134. * Enables a pointer drag behavior on the bounding box of the gizmo
  45135. */
  45136. enableDragBehavior(): void;
  45137. /**
  45138. * Disposes of the gizmo
  45139. */
  45140. dispose(): void;
  45141. /**
  45142. * 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)
  45143. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45144. * @returns the bounding box mesh with the passed in mesh as a child
  45145. */
  45146. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45147. /**
  45148. * CustomMeshes are not supported by this gizmo
  45149. * @param mesh The mesh to replace the default mesh of the gizmo
  45150. */
  45151. setCustomMesh(mesh: Mesh): void;
  45152. }
  45153. }
  45154. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45155. import { Observable } from "babylonjs/Misc/observable";
  45156. import { Nullable } from "babylonjs/types";
  45157. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45159. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45160. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45161. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45162. import "babylonjs/Meshes/Builders/linesBuilder";
  45163. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45164. /**
  45165. * Single plane rotation gizmo
  45166. */
  45167. export class PlaneRotationGizmo extends Gizmo {
  45168. /**
  45169. * Drag behavior responsible for the gizmos dragging interactions
  45170. */
  45171. dragBehavior: PointerDragBehavior;
  45172. private _pointerObserver;
  45173. /**
  45174. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45175. */
  45176. snapDistance: number;
  45177. /**
  45178. * Event that fires each time the gizmo snaps to a new location.
  45179. * * snapDistance is the the change in distance
  45180. */
  45181. onSnapObservable: Observable<{
  45182. snapDistance: number;
  45183. }>;
  45184. private _isEnabled;
  45185. private _parent;
  45186. /**
  45187. * Creates a PlaneRotationGizmo
  45188. * @param gizmoLayer The utility layer the gizmo will be added to
  45189. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45190. * @param color The color of the gizmo
  45191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45192. */
  45193. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45194. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45195. /**
  45196. * If the gizmo is enabled
  45197. */
  45198. isEnabled: boolean;
  45199. /**
  45200. * Disposes of the gizmo
  45201. */
  45202. dispose(): void;
  45203. }
  45204. }
  45205. declare module "babylonjs/Gizmos/rotationGizmo" {
  45206. import { Observable } from "babylonjs/Misc/observable";
  45207. import { Nullable } from "babylonjs/types";
  45208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45209. import { Mesh } from "babylonjs/Meshes/mesh";
  45210. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45211. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45212. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45213. /**
  45214. * Gizmo that enables rotating a mesh along 3 axis
  45215. */
  45216. export class RotationGizmo extends Gizmo {
  45217. /**
  45218. * Internal gizmo used for interactions on the x axis
  45219. */
  45220. xGizmo: PlaneRotationGizmo;
  45221. /**
  45222. * Internal gizmo used for interactions on the y axis
  45223. */
  45224. yGizmo: PlaneRotationGizmo;
  45225. /**
  45226. * Internal gizmo used for interactions on the z axis
  45227. */
  45228. zGizmo: PlaneRotationGizmo;
  45229. /** Fires an event when any of it's sub gizmos are dragged */
  45230. onDragStartObservable: Observable<unknown>;
  45231. /** Fires an event when any of it's sub gizmos are released from dragging */
  45232. onDragEndObservable: Observable<unknown>;
  45233. private _meshAttached;
  45234. attachedMesh: Nullable<AbstractMesh>;
  45235. /**
  45236. * Creates a RotationGizmo
  45237. * @param gizmoLayer The utility layer the gizmo will be added to
  45238. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45239. */
  45240. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45241. updateGizmoRotationToMatchAttachedMesh: boolean;
  45242. /**
  45243. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45244. */
  45245. snapDistance: number;
  45246. /**
  45247. * Ratio for the scale of the gizmo (Default: 1)
  45248. */
  45249. scaleRatio: number;
  45250. /**
  45251. * Disposes of the gizmo
  45252. */
  45253. dispose(): void;
  45254. /**
  45255. * CustomMeshes are not supported by this gizmo
  45256. * @param mesh The mesh to replace the default mesh of the gizmo
  45257. */
  45258. setCustomMesh(mesh: Mesh): void;
  45259. }
  45260. }
  45261. declare module "babylonjs/Gizmos/gizmoManager" {
  45262. import { Observable } from "babylonjs/Misc/observable";
  45263. import { Nullable } from "babylonjs/types";
  45264. import { Scene, IDisposable } from "babylonjs/scene";
  45265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45266. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45267. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45268. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45269. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45270. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45271. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45272. /**
  45273. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45274. */
  45275. export class GizmoManager implements IDisposable {
  45276. private scene;
  45277. /**
  45278. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45279. */
  45280. gizmos: {
  45281. positionGizmo: Nullable<PositionGizmo>;
  45282. rotationGizmo: Nullable<RotationGizmo>;
  45283. scaleGizmo: Nullable<ScaleGizmo>;
  45284. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45285. };
  45286. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45287. clearGizmoOnEmptyPointerEvent: boolean;
  45288. /** Fires an event when the manager is attached to a mesh */
  45289. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45290. private _gizmosEnabled;
  45291. private _pointerObserver;
  45292. private _attachedMesh;
  45293. private _boundingBoxColor;
  45294. private _defaultUtilityLayer;
  45295. private _defaultKeepDepthUtilityLayer;
  45296. /**
  45297. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45298. */
  45299. boundingBoxDragBehavior: SixDofDragBehavior;
  45300. /**
  45301. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45302. */
  45303. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45304. /**
  45305. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45306. */
  45307. usePointerToAttachGizmos: boolean;
  45308. /**
  45309. * Utility layer that the bounding box gizmo belongs to
  45310. */
  45311. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45312. /**
  45313. * Utility layer that all gizmos besides bounding box belong to
  45314. */
  45315. readonly utilityLayer: UtilityLayerRenderer;
  45316. /**
  45317. * Instatiates a gizmo manager
  45318. * @param scene the scene to overlay the gizmos on top of
  45319. */
  45320. constructor(scene: Scene);
  45321. /**
  45322. * Attaches a set of gizmos to the specified mesh
  45323. * @param mesh The mesh the gizmo's should be attached to
  45324. */
  45325. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45326. /**
  45327. * If the position gizmo is enabled
  45328. */
  45329. positionGizmoEnabled: boolean;
  45330. /**
  45331. * If the rotation gizmo is enabled
  45332. */
  45333. rotationGizmoEnabled: boolean;
  45334. /**
  45335. * If the scale gizmo is enabled
  45336. */
  45337. scaleGizmoEnabled: boolean;
  45338. /**
  45339. * If the boundingBox gizmo is enabled
  45340. */
  45341. boundingBoxGizmoEnabled: boolean;
  45342. /**
  45343. * Disposes of the gizmo manager
  45344. */
  45345. dispose(): void;
  45346. }
  45347. }
  45348. declare module "babylonjs/Lights/directionalLight" {
  45349. import { Camera } from "babylonjs/Cameras/camera";
  45350. import { Scene } from "babylonjs/scene";
  45351. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45353. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45354. import { Effect } from "babylonjs/Materials/effect";
  45355. /**
  45356. * A directional light is defined by a direction (what a surprise!).
  45357. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45358. * 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.
  45359. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45360. */
  45361. export class DirectionalLight extends ShadowLight {
  45362. private _shadowFrustumSize;
  45363. /**
  45364. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45365. */
  45366. /**
  45367. * Specifies a fix frustum size for the shadow generation.
  45368. */
  45369. shadowFrustumSize: number;
  45370. private _shadowOrthoScale;
  45371. /**
  45372. * Gets the shadow projection scale against the optimal computed one.
  45373. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45374. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45375. */
  45376. /**
  45377. * Sets the shadow projection scale against the optimal computed one.
  45378. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45379. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45380. */
  45381. shadowOrthoScale: number;
  45382. /**
  45383. * Automatically compute the projection matrix to best fit (including all the casters)
  45384. * on each frame.
  45385. */
  45386. autoUpdateExtends: boolean;
  45387. private _orthoLeft;
  45388. private _orthoRight;
  45389. private _orthoTop;
  45390. private _orthoBottom;
  45391. /**
  45392. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45393. * The directional light is emitted from everywhere in the given direction.
  45394. * It can cast shadows.
  45395. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45396. * @param name The friendly name of the light
  45397. * @param direction The direction of the light
  45398. * @param scene The scene the light belongs to
  45399. */
  45400. constructor(name: string, direction: Vector3, scene: Scene);
  45401. /**
  45402. * Returns the string "DirectionalLight".
  45403. * @return The class name
  45404. */
  45405. getClassName(): string;
  45406. /**
  45407. * Returns the integer 1.
  45408. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45409. */
  45410. getTypeID(): number;
  45411. /**
  45412. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45413. * Returns the DirectionalLight Shadow projection matrix.
  45414. */
  45415. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45416. /**
  45417. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45418. * Returns the DirectionalLight Shadow projection matrix.
  45419. */
  45420. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45421. /**
  45422. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45423. * Returns the DirectionalLight Shadow projection matrix.
  45424. */
  45425. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45426. protected _buildUniformLayout(): void;
  45427. /**
  45428. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45429. * @param effect The effect to update
  45430. * @param lightIndex The index of the light in the effect to update
  45431. * @returns The directional light
  45432. */
  45433. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45434. /**
  45435. * Gets the minZ used for shadow according to both the scene and the light.
  45436. *
  45437. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45438. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45439. * @param activeCamera The camera we are returning the min for
  45440. * @returns the depth min z
  45441. */
  45442. getDepthMinZ(activeCamera: Camera): number;
  45443. /**
  45444. * Gets the maxZ used for shadow according to both the scene and the light.
  45445. *
  45446. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45447. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45448. * @param activeCamera The camera we are returning the max for
  45449. * @returns the depth max z
  45450. */
  45451. getDepthMaxZ(activeCamera: Camera): number;
  45452. /**
  45453. * Prepares the list of defines specific to the light type.
  45454. * @param defines the list of defines
  45455. * @param lightIndex defines the index of the light for the effect
  45456. */
  45457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45458. }
  45459. }
  45460. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45461. import { Mesh } from "babylonjs/Meshes/mesh";
  45462. /**
  45463. * Class containing static functions to help procedurally build meshes
  45464. */
  45465. export class HemisphereBuilder {
  45466. /**
  45467. * Creates a hemisphere mesh
  45468. * @param name defines the name of the mesh
  45469. * @param options defines the options used to create the mesh
  45470. * @param scene defines the hosting scene
  45471. * @returns the hemisphere mesh
  45472. */
  45473. static CreateHemisphere(name: string, options: {
  45474. segments?: number;
  45475. diameter?: number;
  45476. sideOrientation?: number;
  45477. }, scene: any): Mesh;
  45478. }
  45479. }
  45480. declare module "babylonjs/Lights/spotLight" {
  45481. import { Nullable } from "babylonjs/types";
  45482. import { Scene } from "babylonjs/scene";
  45483. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45485. import { Effect } from "babylonjs/Materials/effect";
  45486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45487. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45488. /**
  45489. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45490. * These values define a cone of light starting from the position, emitting toward the direction.
  45491. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45492. * and the exponent defines the speed of the decay of the light with distance (reach).
  45493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45494. */
  45495. export class SpotLight extends ShadowLight {
  45496. private _angle;
  45497. private _innerAngle;
  45498. private _cosHalfAngle;
  45499. private _lightAngleScale;
  45500. private _lightAngleOffset;
  45501. /**
  45502. * Gets the cone angle of the spot light in Radians.
  45503. */
  45504. /**
  45505. * Sets the cone angle of the spot light in Radians.
  45506. */
  45507. angle: number;
  45508. /**
  45509. * Only used in gltf falloff mode, this defines the angle where
  45510. * the directional falloff will start before cutting at angle which could be seen
  45511. * as outer angle.
  45512. */
  45513. /**
  45514. * Only used in gltf falloff mode, this defines the angle where
  45515. * the directional falloff will start before cutting at angle which could be seen
  45516. * as outer angle.
  45517. */
  45518. innerAngle: number;
  45519. private _shadowAngleScale;
  45520. /**
  45521. * Allows scaling the angle of the light for shadow generation only.
  45522. */
  45523. /**
  45524. * Allows scaling the angle of the light for shadow generation only.
  45525. */
  45526. shadowAngleScale: number;
  45527. /**
  45528. * The light decay speed with the distance from the emission spot.
  45529. */
  45530. exponent: number;
  45531. private _projectionTextureMatrix;
  45532. /**
  45533. * Allows reading the projecton texture
  45534. */
  45535. readonly projectionTextureMatrix: Matrix;
  45536. protected _projectionTextureLightNear: number;
  45537. /**
  45538. * Gets the near clip of the Spotlight for texture projection.
  45539. */
  45540. /**
  45541. * Sets the near clip of the Spotlight for texture projection.
  45542. */
  45543. projectionTextureLightNear: number;
  45544. protected _projectionTextureLightFar: number;
  45545. /**
  45546. * Gets the far clip of the Spotlight for texture projection.
  45547. */
  45548. /**
  45549. * Sets the far clip of the Spotlight for texture projection.
  45550. */
  45551. projectionTextureLightFar: number;
  45552. protected _projectionTextureUpDirection: Vector3;
  45553. /**
  45554. * Gets the Up vector of the Spotlight for texture projection.
  45555. */
  45556. /**
  45557. * Sets the Up vector of the Spotlight for texture projection.
  45558. */
  45559. projectionTextureUpDirection: Vector3;
  45560. private _projectionTexture;
  45561. /**
  45562. * Gets the projection texture of the light.
  45563. */
  45564. /**
  45565. * Sets the projection texture of the light.
  45566. */
  45567. projectionTexture: Nullable<BaseTexture>;
  45568. private _projectionTextureViewLightDirty;
  45569. private _projectionTextureProjectionLightDirty;
  45570. private _projectionTextureDirty;
  45571. private _projectionTextureViewTargetVector;
  45572. private _projectionTextureViewLightMatrix;
  45573. private _projectionTextureProjectionLightMatrix;
  45574. private _projectionTextureScalingMatrix;
  45575. /**
  45576. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45577. * It can cast shadows.
  45578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45579. * @param name The light friendly name
  45580. * @param position The position of the spot light in the scene
  45581. * @param direction The direction of the light in the scene
  45582. * @param angle The cone angle of the light in Radians
  45583. * @param exponent The light decay speed with the distance from the emission spot
  45584. * @param scene The scene the lights belongs to
  45585. */
  45586. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45587. /**
  45588. * Returns the string "SpotLight".
  45589. * @returns the class name
  45590. */
  45591. getClassName(): string;
  45592. /**
  45593. * Returns the integer 2.
  45594. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45595. */
  45596. getTypeID(): number;
  45597. /**
  45598. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45599. */
  45600. protected _setDirection(value: Vector3): void;
  45601. /**
  45602. * Overrides the position setter to recompute the projection texture view light Matrix.
  45603. */
  45604. protected _setPosition(value: Vector3): void;
  45605. /**
  45606. * 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.
  45607. * Returns the SpotLight.
  45608. */
  45609. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45610. protected _computeProjectionTextureViewLightMatrix(): void;
  45611. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45612. /**
  45613. * Main function for light texture projection matrix computing.
  45614. */
  45615. protected _computeProjectionTextureMatrix(): void;
  45616. protected _buildUniformLayout(): void;
  45617. private _computeAngleValues;
  45618. /**
  45619. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45620. * @param effect The effect to update
  45621. * @param lightIndex The index of the light in the effect to update
  45622. * @returns The spot light
  45623. */
  45624. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45625. /**
  45626. * Disposes the light and the associated resources.
  45627. */
  45628. dispose(): void;
  45629. /**
  45630. * Prepares the list of defines specific to the light type.
  45631. * @param defines the list of defines
  45632. * @param lightIndex defines the index of the light for the effect
  45633. */
  45634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45635. }
  45636. }
  45637. declare module "babylonjs/Gizmos/lightGizmo" {
  45638. import { Nullable } from "babylonjs/types";
  45639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45640. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45641. import { Light } from "babylonjs/Lights/light";
  45642. /**
  45643. * Gizmo that enables viewing a light
  45644. */
  45645. export class LightGizmo extends Gizmo {
  45646. private _lightMesh;
  45647. private _material;
  45648. private cachedPosition;
  45649. private cachedForward;
  45650. /**
  45651. * Creates a LightGizmo
  45652. * @param gizmoLayer The utility layer the gizmo will be added to
  45653. */
  45654. constructor(gizmoLayer?: UtilityLayerRenderer);
  45655. private _light;
  45656. /**
  45657. * The light that the gizmo is attached to
  45658. */
  45659. light: Nullable<Light>;
  45660. /**
  45661. * @hidden
  45662. * Updates the gizmo to match the attached mesh's position/rotation
  45663. */
  45664. protected _update(): void;
  45665. private static _Scale;
  45666. /**
  45667. * Creates the lines for a light mesh
  45668. */
  45669. private static _createLightLines;
  45670. /**
  45671. * Disposes of the light gizmo
  45672. */
  45673. dispose(): void;
  45674. private static _CreateHemisphericLightMesh;
  45675. private static _CreatePointLightMesh;
  45676. private static _CreateSpotLightMesh;
  45677. private static _CreateDirectionalLightMesh;
  45678. }
  45679. }
  45680. declare module "babylonjs/Gizmos/index" {
  45681. export * from "babylonjs/Gizmos/axisDragGizmo";
  45682. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45683. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45684. export * from "babylonjs/Gizmos/gizmo";
  45685. export * from "babylonjs/Gizmos/gizmoManager";
  45686. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45687. export * from "babylonjs/Gizmos/positionGizmo";
  45688. export * from "babylonjs/Gizmos/rotationGizmo";
  45689. export * from "babylonjs/Gizmos/scaleGizmo";
  45690. export * from "babylonjs/Gizmos/lightGizmo";
  45691. }
  45692. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45693. /** @hidden */
  45694. export var backgroundFragmentDeclaration: {
  45695. name: string;
  45696. shader: string;
  45697. };
  45698. }
  45699. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45700. /** @hidden */
  45701. export var backgroundUboDeclaration: {
  45702. name: string;
  45703. shader: string;
  45704. };
  45705. }
  45706. declare module "babylonjs/Shaders/background.fragment" {
  45707. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45708. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45709. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45710. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45711. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45712. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45713. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45714. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45715. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45718. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45719. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45720. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45721. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45722. /** @hidden */
  45723. export var backgroundPixelShader: {
  45724. name: string;
  45725. shader: string;
  45726. };
  45727. }
  45728. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45729. /** @hidden */
  45730. export var backgroundVertexDeclaration: {
  45731. name: string;
  45732. shader: string;
  45733. };
  45734. }
  45735. declare module "babylonjs/Shaders/background.vertex" {
  45736. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45737. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45739. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45741. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45742. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45743. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45744. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45745. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45746. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45747. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45748. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45749. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45750. /** @hidden */
  45751. export var backgroundVertexShader: {
  45752. name: string;
  45753. shader: string;
  45754. };
  45755. }
  45756. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45757. import { Nullable, int, float } from "babylonjs/types";
  45758. import { Scene } from "babylonjs/scene";
  45759. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45762. import { Mesh } from "babylonjs/Meshes/mesh";
  45763. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45764. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45765. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45767. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45768. import "babylonjs/Shaders/background.fragment";
  45769. import "babylonjs/Shaders/background.vertex";
  45770. /**
  45771. * Background material used to create an efficient environement around your scene.
  45772. */
  45773. export class BackgroundMaterial extends PushMaterial {
  45774. /**
  45775. * Standard reflectance value at parallel view angle.
  45776. */
  45777. static StandardReflectance0: number;
  45778. /**
  45779. * Standard reflectance value at grazing angle.
  45780. */
  45781. static StandardReflectance90: number;
  45782. protected _primaryColor: Color3;
  45783. /**
  45784. * Key light Color (multiply against the environement texture)
  45785. */
  45786. primaryColor: Color3;
  45787. protected __perceptualColor: Nullable<Color3>;
  45788. /**
  45789. * Experimental Internal Use Only.
  45790. *
  45791. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45792. * This acts as a helper to set the primary color to a more "human friendly" value.
  45793. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45794. * output color as close as possible from the chosen value.
  45795. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45796. * part of lighting setup.)
  45797. */
  45798. _perceptualColor: Nullable<Color3>;
  45799. protected _primaryColorShadowLevel: float;
  45800. /**
  45801. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45802. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45803. */
  45804. primaryColorShadowLevel: float;
  45805. protected _primaryColorHighlightLevel: float;
  45806. /**
  45807. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45808. * The primary color is used at the level chosen to define what the white area would look.
  45809. */
  45810. primaryColorHighlightLevel: float;
  45811. protected _reflectionTexture: Nullable<BaseTexture>;
  45812. /**
  45813. * Reflection Texture used in the material.
  45814. * Should be author in a specific way for the best result (refer to the documentation).
  45815. */
  45816. reflectionTexture: Nullable<BaseTexture>;
  45817. protected _reflectionBlur: float;
  45818. /**
  45819. * Reflection Texture level of blur.
  45820. *
  45821. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45822. * texture twice.
  45823. */
  45824. reflectionBlur: float;
  45825. protected _diffuseTexture: Nullable<BaseTexture>;
  45826. /**
  45827. * Diffuse Texture used in the material.
  45828. * Should be author in a specific way for the best result (refer to the documentation).
  45829. */
  45830. diffuseTexture: Nullable<BaseTexture>;
  45831. protected _shadowLights: Nullable<IShadowLight[]>;
  45832. /**
  45833. * Specify the list of lights casting shadow on the material.
  45834. * All scene shadow lights will be included if null.
  45835. */
  45836. shadowLights: Nullable<IShadowLight[]>;
  45837. protected _shadowLevel: float;
  45838. /**
  45839. * Helps adjusting the shadow to a softer level if required.
  45840. * 0 means black shadows and 1 means no shadows.
  45841. */
  45842. shadowLevel: float;
  45843. protected _sceneCenter: Vector3;
  45844. /**
  45845. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45846. * It is usually zero but might be interesting to modify according to your setup.
  45847. */
  45848. sceneCenter: Vector3;
  45849. protected _opacityFresnel: boolean;
  45850. /**
  45851. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45852. * This helps ensuring a nice transition when the camera goes under the ground.
  45853. */
  45854. opacityFresnel: boolean;
  45855. protected _reflectionFresnel: boolean;
  45856. /**
  45857. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45858. * This helps adding a mirror texture on the ground.
  45859. */
  45860. reflectionFresnel: boolean;
  45861. protected _reflectionFalloffDistance: number;
  45862. /**
  45863. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45864. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45865. */
  45866. reflectionFalloffDistance: number;
  45867. protected _reflectionAmount: number;
  45868. /**
  45869. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45870. */
  45871. reflectionAmount: number;
  45872. protected _reflectionReflectance0: number;
  45873. /**
  45874. * This specifies the weight of the reflection at grazing angle.
  45875. */
  45876. reflectionReflectance0: number;
  45877. protected _reflectionReflectance90: number;
  45878. /**
  45879. * This specifies the weight of the reflection at a perpendicular point of view.
  45880. */
  45881. reflectionReflectance90: number;
  45882. /**
  45883. * Sets the reflection reflectance fresnel values according to the default standard
  45884. * empirically know to work well :-)
  45885. */
  45886. reflectionStandardFresnelWeight: number;
  45887. protected _useRGBColor: boolean;
  45888. /**
  45889. * Helps to directly use the maps channels instead of their level.
  45890. */
  45891. useRGBColor: boolean;
  45892. protected _enableNoise: boolean;
  45893. /**
  45894. * This helps reducing the banding effect that could occur on the background.
  45895. */
  45896. enableNoise: boolean;
  45897. /**
  45898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45899. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45900. * Recommended to be keep at 1.0 except for special cases.
  45901. */
  45902. fovMultiplier: number;
  45903. private _fovMultiplier;
  45904. /**
  45905. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45906. */
  45907. useEquirectangularFOV: boolean;
  45908. private _maxSimultaneousLights;
  45909. /**
  45910. * Number of Simultaneous lights allowed on the material.
  45911. */
  45912. maxSimultaneousLights: int;
  45913. /**
  45914. * Default configuration related to image processing available in the Background Material.
  45915. */
  45916. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45917. /**
  45918. * Keep track of the image processing observer to allow dispose and replace.
  45919. */
  45920. private _imageProcessingObserver;
  45921. /**
  45922. * Attaches a new image processing configuration to the PBR Material.
  45923. * @param configuration (if null the scene configuration will be use)
  45924. */
  45925. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45926. /**
  45927. * Gets the image processing configuration used either in this material.
  45928. */
  45929. /**
  45930. * Sets the Default image processing configuration used either in the this material.
  45931. *
  45932. * If sets to null, the scene one is in use.
  45933. */
  45934. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45935. /**
  45936. * Gets wether the color curves effect is enabled.
  45937. */
  45938. /**
  45939. * Sets wether the color curves effect is enabled.
  45940. */
  45941. cameraColorCurvesEnabled: boolean;
  45942. /**
  45943. * Gets wether the color grading effect is enabled.
  45944. */
  45945. /**
  45946. * Gets wether the color grading effect is enabled.
  45947. */
  45948. cameraColorGradingEnabled: boolean;
  45949. /**
  45950. * Gets wether tonemapping is enabled or not.
  45951. */
  45952. /**
  45953. * Sets wether tonemapping is enabled or not
  45954. */
  45955. cameraToneMappingEnabled: boolean;
  45956. /**
  45957. * The camera exposure used on this material.
  45958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45959. * This corresponds to a photographic exposure.
  45960. */
  45961. /**
  45962. * The camera exposure used on this material.
  45963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45964. * This corresponds to a photographic exposure.
  45965. */
  45966. cameraExposure: float;
  45967. /**
  45968. * Gets The camera contrast used on this material.
  45969. */
  45970. /**
  45971. * Sets The camera contrast used on this material.
  45972. */
  45973. cameraContrast: float;
  45974. /**
  45975. * Gets the Color Grading 2D Lookup Texture.
  45976. */
  45977. /**
  45978. * Sets the Color Grading 2D Lookup Texture.
  45979. */
  45980. cameraColorGradingTexture: Nullable<BaseTexture>;
  45981. /**
  45982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45984. * 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;
  45985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45986. */
  45987. /**
  45988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45990. * 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;
  45991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45992. */
  45993. cameraColorCurves: Nullable<ColorCurves>;
  45994. /**
  45995. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45996. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45997. */
  45998. switchToBGR: boolean;
  45999. private _renderTargets;
  46000. private _reflectionControls;
  46001. private _white;
  46002. private _primaryShadowColor;
  46003. private _primaryHighlightColor;
  46004. /**
  46005. * Instantiates a Background Material in the given scene
  46006. * @param name The friendly name of the material
  46007. * @param scene The scene to add the material to
  46008. */
  46009. constructor(name: string, scene: Scene);
  46010. /**
  46011. * Gets a boolean indicating that current material needs to register RTT
  46012. */
  46013. readonly hasRenderTargetTextures: boolean;
  46014. /**
  46015. * The entire material has been created in order to prevent overdraw.
  46016. * @returns false
  46017. */
  46018. needAlphaTesting(): boolean;
  46019. /**
  46020. * The entire material has been created in order to prevent overdraw.
  46021. * @returns true if blending is enable
  46022. */
  46023. needAlphaBlending(): boolean;
  46024. /**
  46025. * Checks wether the material is ready to be rendered for a given mesh.
  46026. * @param mesh The mesh to render
  46027. * @param subMesh The submesh to check against
  46028. * @param useInstances Specify wether or not the material is used with instances
  46029. * @returns true if all the dependencies are ready (Textures, Effects...)
  46030. */
  46031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46032. /**
  46033. * Compute the primary color according to the chosen perceptual color.
  46034. */
  46035. private _computePrimaryColorFromPerceptualColor;
  46036. /**
  46037. * Compute the highlights and shadow colors according to their chosen levels.
  46038. */
  46039. private _computePrimaryColors;
  46040. /**
  46041. * Build the uniform buffer used in the material.
  46042. */
  46043. buildUniformLayout(): void;
  46044. /**
  46045. * Unbind the material.
  46046. */
  46047. unbind(): void;
  46048. /**
  46049. * Bind only the world matrix to the material.
  46050. * @param world The world matrix to bind.
  46051. */
  46052. bindOnlyWorldMatrix(world: Matrix): void;
  46053. /**
  46054. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46055. * @param world The world matrix to bind.
  46056. * @param subMesh The submesh to bind for.
  46057. */
  46058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46059. /**
  46060. * Dispose the material.
  46061. * @param forceDisposeEffect Force disposal of the associated effect.
  46062. * @param forceDisposeTextures Force disposal of the associated textures.
  46063. */
  46064. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46065. /**
  46066. * Clones the material.
  46067. * @param name The cloned name.
  46068. * @returns The cloned material.
  46069. */
  46070. clone(name: string): BackgroundMaterial;
  46071. /**
  46072. * Serializes the current material to its JSON representation.
  46073. * @returns The JSON representation.
  46074. */
  46075. serialize(): any;
  46076. /**
  46077. * Gets the class name of the material
  46078. * @returns "BackgroundMaterial"
  46079. */
  46080. getClassName(): string;
  46081. /**
  46082. * Parse a JSON input to create back a background material.
  46083. * @param source The JSON data to parse
  46084. * @param scene The scene to create the parsed material in
  46085. * @param rootUrl The root url of the assets the material depends upon
  46086. * @returns the instantiated BackgroundMaterial.
  46087. */
  46088. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46089. }
  46090. }
  46091. declare module "babylonjs/Helpers/environmentHelper" {
  46092. import { Observable } from "babylonjs/Misc/observable";
  46093. import { Nullable } from "babylonjs/types";
  46094. import { Scene } from "babylonjs/scene";
  46095. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46097. import { Mesh } from "babylonjs/Meshes/mesh";
  46098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46099. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46100. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46101. import "babylonjs/Meshes/Builders/planeBuilder";
  46102. import "babylonjs/Meshes/Builders/boxBuilder";
  46103. /**
  46104. * Represents the different options available during the creation of
  46105. * a Environment helper.
  46106. *
  46107. * This can control the default ground, skybox and image processing setup of your scene.
  46108. */
  46109. export interface IEnvironmentHelperOptions {
  46110. /**
  46111. * Specifies wether or not to create a ground.
  46112. * True by default.
  46113. */
  46114. createGround: boolean;
  46115. /**
  46116. * Specifies the ground size.
  46117. * 15 by default.
  46118. */
  46119. groundSize: number;
  46120. /**
  46121. * The texture used on the ground for the main color.
  46122. * Comes from the BabylonJS CDN by default.
  46123. *
  46124. * Remarks: Can be either a texture or a url.
  46125. */
  46126. groundTexture: string | BaseTexture;
  46127. /**
  46128. * The color mixed in the ground texture by default.
  46129. * BabylonJS clearColor by default.
  46130. */
  46131. groundColor: Color3;
  46132. /**
  46133. * Specifies the ground opacity.
  46134. * 1 by default.
  46135. */
  46136. groundOpacity: number;
  46137. /**
  46138. * Enables the ground to receive shadows.
  46139. * True by default.
  46140. */
  46141. enableGroundShadow: boolean;
  46142. /**
  46143. * Helps preventing the shadow to be fully black on the ground.
  46144. * 0.5 by default.
  46145. */
  46146. groundShadowLevel: number;
  46147. /**
  46148. * Creates a mirror texture attach to the ground.
  46149. * false by default.
  46150. */
  46151. enableGroundMirror: boolean;
  46152. /**
  46153. * Specifies the ground mirror size ratio.
  46154. * 0.3 by default as the default kernel is 64.
  46155. */
  46156. groundMirrorSizeRatio: number;
  46157. /**
  46158. * Specifies the ground mirror blur kernel size.
  46159. * 64 by default.
  46160. */
  46161. groundMirrorBlurKernel: number;
  46162. /**
  46163. * Specifies the ground mirror visibility amount.
  46164. * 1 by default
  46165. */
  46166. groundMirrorAmount: number;
  46167. /**
  46168. * Specifies the ground mirror reflectance weight.
  46169. * This uses the standard weight of the background material to setup the fresnel effect
  46170. * of the mirror.
  46171. * 1 by default.
  46172. */
  46173. groundMirrorFresnelWeight: number;
  46174. /**
  46175. * Specifies the ground mirror Falloff distance.
  46176. * This can helps reducing the size of the reflection.
  46177. * 0 by Default.
  46178. */
  46179. groundMirrorFallOffDistance: number;
  46180. /**
  46181. * Specifies the ground mirror texture type.
  46182. * Unsigned Int by Default.
  46183. */
  46184. groundMirrorTextureType: number;
  46185. /**
  46186. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46187. * the shown objects.
  46188. */
  46189. groundYBias: number;
  46190. /**
  46191. * Specifies wether or not to create a skybox.
  46192. * True by default.
  46193. */
  46194. createSkybox: boolean;
  46195. /**
  46196. * Specifies the skybox size.
  46197. * 20 by default.
  46198. */
  46199. skyboxSize: number;
  46200. /**
  46201. * The texture used on the skybox for the main color.
  46202. * Comes from the BabylonJS CDN by default.
  46203. *
  46204. * Remarks: Can be either a texture or a url.
  46205. */
  46206. skyboxTexture: string | BaseTexture;
  46207. /**
  46208. * The color mixed in the skybox texture by default.
  46209. * BabylonJS clearColor by default.
  46210. */
  46211. skyboxColor: Color3;
  46212. /**
  46213. * The background rotation around the Y axis of the scene.
  46214. * This helps aligning the key lights of your scene with the background.
  46215. * 0 by default.
  46216. */
  46217. backgroundYRotation: number;
  46218. /**
  46219. * Compute automatically the size of the elements to best fit with the scene.
  46220. */
  46221. sizeAuto: boolean;
  46222. /**
  46223. * Default position of the rootMesh if autoSize is not true.
  46224. */
  46225. rootPosition: Vector3;
  46226. /**
  46227. * Sets up the image processing in the scene.
  46228. * true by default.
  46229. */
  46230. setupImageProcessing: boolean;
  46231. /**
  46232. * The texture used as your environment texture in the scene.
  46233. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46234. *
  46235. * Remarks: Can be either a texture or a url.
  46236. */
  46237. environmentTexture: string | BaseTexture;
  46238. /**
  46239. * The value of the exposure to apply to the scene.
  46240. * 0.6 by default if setupImageProcessing is true.
  46241. */
  46242. cameraExposure: number;
  46243. /**
  46244. * The value of the contrast to apply to the scene.
  46245. * 1.6 by default if setupImageProcessing is true.
  46246. */
  46247. cameraContrast: number;
  46248. /**
  46249. * Specifies wether or not tonemapping should be enabled in the scene.
  46250. * true by default if setupImageProcessing is true.
  46251. */
  46252. toneMappingEnabled: boolean;
  46253. }
  46254. /**
  46255. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46256. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46257. * It also helps with the default setup of your imageProcessing configuration.
  46258. */
  46259. export class EnvironmentHelper {
  46260. /**
  46261. * Default ground texture URL.
  46262. */
  46263. private static _groundTextureCDNUrl;
  46264. /**
  46265. * Default skybox texture URL.
  46266. */
  46267. private static _skyboxTextureCDNUrl;
  46268. /**
  46269. * Default environment texture URL.
  46270. */
  46271. private static _environmentTextureCDNUrl;
  46272. /**
  46273. * Creates the default options for the helper.
  46274. */
  46275. private static _getDefaultOptions;
  46276. private _rootMesh;
  46277. /**
  46278. * Gets the root mesh created by the helper.
  46279. */
  46280. readonly rootMesh: Mesh;
  46281. private _skybox;
  46282. /**
  46283. * Gets the skybox created by the helper.
  46284. */
  46285. readonly skybox: Nullable<Mesh>;
  46286. private _skyboxTexture;
  46287. /**
  46288. * Gets the skybox texture created by the helper.
  46289. */
  46290. readonly skyboxTexture: Nullable<BaseTexture>;
  46291. private _skyboxMaterial;
  46292. /**
  46293. * Gets the skybox material created by the helper.
  46294. */
  46295. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46296. private _ground;
  46297. /**
  46298. * Gets the ground mesh created by the helper.
  46299. */
  46300. readonly ground: Nullable<Mesh>;
  46301. private _groundTexture;
  46302. /**
  46303. * Gets the ground texture created by the helper.
  46304. */
  46305. readonly groundTexture: Nullable<BaseTexture>;
  46306. private _groundMirror;
  46307. /**
  46308. * Gets the ground mirror created by the helper.
  46309. */
  46310. readonly groundMirror: Nullable<MirrorTexture>;
  46311. /**
  46312. * Gets the ground mirror render list to helps pushing the meshes
  46313. * you wish in the ground reflection.
  46314. */
  46315. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46316. private _groundMaterial;
  46317. /**
  46318. * Gets the ground material created by the helper.
  46319. */
  46320. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46321. /**
  46322. * Stores the creation options.
  46323. */
  46324. private readonly _scene;
  46325. private _options;
  46326. /**
  46327. * This observable will be notified with any error during the creation of the environment,
  46328. * mainly texture creation errors.
  46329. */
  46330. onErrorObservable: Observable<{
  46331. message?: string;
  46332. exception?: any;
  46333. }>;
  46334. /**
  46335. * constructor
  46336. * @param options Defines the options we want to customize the helper
  46337. * @param scene The scene to add the material to
  46338. */
  46339. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46340. /**
  46341. * Updates the background according to the new options
  46342. * @param options
  46343. */
  46344. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46345. /**
  46346. * Sets the primary color of all the available elements.
  46347. * @param color the main color to affect to the ground and the background
  46348. */
  46349. setMainColor(color: Color3): void;
  46350. /**
  46351. * Setup the image processing according to the specified options.
  46352. */
  46353. private _setupImageProcessing;
  46354. /**
  46355. * Setup the environment texture according to the specified options.
  46356. */
  46357. private _setupEnvironmentTexture;
  46358. /**
  46359. * Setup the background according to the specified options.
  46360. */
  46361. private _setupBackground;
  46362. /**
  46363. * Get the scene sizes according to the setup.
  46364. */
  46365. private _getSceneSize;
  46366. /**
  46367. * Setup the ground according to the specified options.
  46368. */
  46369. private _setupGround;
  46370. /**
  46371. * Setup the ground material according to the specified options.
  46372. */
  46373. private _setupGroundMaterial;
  46374. /**
  46375. * Setup the ground diffuse texture according to the specified options.
  46376. */
  46377. private _setupGroundDiffuseTexture;
  46378. /**
  46379. * Setup the ground mirror texture according to the specified options.
  46380. */
  46381. private _setupGroundMirrorTexture;
  46382. /**
  46383. * Setup the ground to receive the mirror texture.
  46384. */
  46385. private _setupMirrorInGroundMaterial;
  46386. /**
  46387. * Setup the skybox according to the specified options.
  46388. */
  46389. private _setupSkybox;
  46390. /**
  46391. * Setup the skybox material according to the specified options.
  46392. */
  46393. private _setupSkyboxMaterial;
  46394. /**
  46395. * Setup the skybox reflection texture according to the specified options.
  46396. */
  46397. private _setupSkyboxReflectionTexture;
  46398. private _errorHandler;
  46399. /**
  46400. * Dispose all the elements created by the Helper.
  46401. */
  46402. dispose(): void;
  46403. }
  46404. }
  46405. declare module "babylonjs/Helpers/photoDome" {
  46406. import { Observable } from "babylonjs/Misc/observable";
  46407. import { Nullable } from "babylonjs/types";
  46408. import { Scene } from "babylonjs/scene";
  46409. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46410. import { Mesh } from "babylonjs/Meshes/mesh";
  46411. import { Texture } from "babylonjs/Materials/Textures/texture";
  46412. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46413. import "babylonjs/Meshes/Builders/sphereBuilder";
  46414. /**
  46415. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46416. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46417. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46418. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46419. */
  46420. export class PhotoDome extends TransformNode {
  46421. /**
  46422. * Define the image as a Monoscopic panoramic 360 image.
  46423. */
  46424. static readonly MODE_MONOSCOPIC: number;
  46425. /**
  46426. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46427. */
  46428. static readonly MODE_TOPBOTTOM: number;
  46429. /**
  46430. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46431. */
  46432. static readonly MODE_SIDEBYSIDE: number;
  46433. private _useDirectMapping;
  46434. /**
  46435. * The texture being displayed on the sphere
  46436. */
  46437. protected _photoTexture: Texture;
  46438. /**
  46439. * Gets or sets the texture being displayed on the sphere
  46440. */
  46441. photoTexture: Texture;
  46442. /**
  46443. * Observable raised when an error occured while loading the 360 image
  46444. */
  46445. onLoadErrorObservable: Observable<string>;
  46446. /**
  46447. * The skybox material
  46448. */
  46449. protected _material: BackgroundMaterial;
  46450. /**
  46451. * The surface used for the skybox
  46452. */
  46453. protected _mesh: Mesh;
  46454. /**
  46455. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46456. * Also see the options.resolution property.
  46457. */
  46458. fovMultiplier: number;
  46459. private _imageMode;
  46460. /**
  46461. * Gets or set the current video mode for the video. It can be:
  46462. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46463. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46464. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46465. */
  46466. imageMode: number;
  46467. /**
  46468. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46469. * @param name Element's name, child elements will append suffixes for their own names.
  46470. * @param urlsOfPhoto defines the url of the photo to display
  46471. * @param options defines an object containing optional or exposed sub element properties
  46472. * @param onError defines a callback called when an error occured while loading the texture
  46473. */
  46474. constructor(name: string, urlOfPhoto: string, options: {
  46475. resolution?: number;
  46476. size?: number;
  46477. useDirectMapping?: boolean;
  46478. faceForward?: boolean;
  46479. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46480. private _onBeforeCameraRenderObserver;
  46481. private _changeImageMode;
  46482. /**
  46483. * Releases resources associated with this node.
  46484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46486. */
  46487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46488. }
  46489. }
  46490. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46492. /** @hidden */
  46493. export var rgbdDecodePixelShader: {
  46494. name: string;
  46495. shader: string;
  46496. };
  46497. }
  46498. declare module "babylonjs/Misc/brdfTextureTools" {
  46499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46500. import { Scene } from "babylonjs/scene";
  46501. import "babylonjs/Shaders/rgbdDecode.fragment";
  46502. /**
  46503. * Class used to host texture specific utilities
  46504. */
  46505. export class BRDFTextureTools {
  46506. /**
  46507. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46508. * @param texture the texture to expand.
  46509. */
  46510. private static _ExpandDefaultBRDFTexture;
  46511. /**
  46512. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46513. * @param scene defines the hosting scene
  46514. * @returns the environment BRDF texture
  46515. */
  46516. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46517. private static _environmentBRDFBase64Texture;
  46518. }
  46519. }
  46520. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46521. import { Nullable } from "babylonjs/types";
  46522. import { IAnimatable } from "babylonjs/Misc/tools";
  46523. import { Color3 } from "babylonjs/Maths/math";
  46524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46525. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46526. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46527. import { Engine } from "babylonjs/Engines/engine";
  46528. import { Scene } from "babylonjs/scene";
  46529. /**
  46530. * @hidden
  46531. */
  46532. export interface IMaterialClearCoatDefines {
  46533. CLEARCOAT: boolean;
  46534. CLEARCOAT_DEFAULTIOR: boolean;
  46535. CLEARCOAT_TEXTURE: boolean;
  46536. CLEARCOAT_TEXTUREDIRECTUV: number;
  46537. CLEARCOAT_BUMP: boolean;
  46538. CLEARCOAT_BUMPDIRECTUV: number;
  46539. CLEARCOAT_TINT: boolean;
  46540. CLEARCOAT_TINT_TEXTURE: boolean;
  46541. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46542. /** @hidden */
  46543. _areTexturesDirty: boolean;
  46544. }
  46545. /**
  46546. * Define the code related to the clear coat parameters of the pbr material.
  46547. */
  46548. export class PBRClearCoatConfiguration {
  46549. /**
  46550. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46551. * The default fits with a polyurethane material.
  46552. */
  46553. private static readonly _DefaultIndexOfRefraction;
  46554. private _isEnabled;
  46555. /**
  46556. * Defines if the clear coat is enabled in the material.
  46557. */
  46558. isEnabled: boolean;
  46559. /**
  46560. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46561. */
  46562. intensity: number;
  46563. /**
  46564. * Defines the clear coat layer roughness.
  46565. */
  46566. roughness: number;
  46567. private _indexOfRefraction;
  46568. /**
  46569. * Defines the index of refraction of the clear coat.
  46570. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46571. * The default fits with a polyurethane material.
  46572. * Changing the default value is more performance intensive.
  46573. */
  46574. indexOfRefraction: number;
  46575. private _texture;
  46576. /**
  46577. * Stores the clear coat values in a texture.
  46578. */
  46579. texture: Nullable<BaseTexture>;
  46580. private _bumpTexture;
  46581. /**
  46582. * Define the clear coat specific bump texture.
  46583. */
  46584. bumpTexture: Nullable<BaseTexture>;
  46585. private _isTintEnabled;
  46586. /**
  46587. * Defines if the clear coat tint is enabled in the material.
  46588. */
  46589. isTintEnabled: boolean;
  46590. /**
  46591. * Defines the clear coat tint of the material.
  46592. * This is only use if tint is enabled
  46593. */
  46594. tintColor: Color3;
  46595. /**
  46596. * Defines the distance at which the tint color should be found in the
  46597. * clear coat media.
  46598. * This is only use if tint is enabled
  46599. */
  46600. tintColorAtDistance: number;
  46601. /**
  46602. * Defines the clear coat layer thickness.
  46603. * This is only use if tint is enabled
  46604. */
  46605. tintThickness: number;
  46606. private _tintTexture;
  46607. /**
  46608. * Stores the clear tint values in a texture.
  46609. * rgb is tint
  46610. * a is a thickness factor
  46611. */
  46612. tintTexture: Nullable<BaseTexture>;
  46613. /** @hidden */
  46614. private _internalMarkAllSubMeshesAsTexturesDirty;
  46615. /** @hidden */
  46616. _markAllSubMeshesAsTexturesDirty(): void;
  46617. /**
  46618. * Instantiate a new istance of clear coat configuration.
  46619. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46620. */
  46621. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46622. /**
  46623. * Gets wehter the submesh is ready to be used or not.
  46624. * @param defines the list of "defines" to update.
  46625. * @param scene defines the scene the material belongs to.
  46626. * @param engine defines the engine the material belongs to.
  46627. * @param disableBumpMap defines wether the material disables bump or not.
  46628. * @returns - boolean indicating that the submesh is ready or not.
  46629. */
  46630. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46631. /**
  46632. * Checks to see if a texture is used in the material.
  46633. * @param defines the list of "defines" to update.
  46634. * @param scene defines the scene to the material belongs to.
  46635. */
  46636. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46637. /**
  46638. * Binds the material data.
  46639. * @param uniformBuffer defines the Uniform buffer to fill in.
  46640. * @param scene defines the scene the material belongs to.
  46641. * @param engine defines the engine the material belongs to.
  46642. * @param disableBumpMap defines wether the material disables bump or not.
  46643. * @param isFrozen defines wether the material is frozen or not.
  46644. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46645. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46646. */
  46647. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46648. /**
  46649. * Checks to see if a texture is used in the material.
  46650. * @param texture - Base texture to use.
  46651. * @returns - Boolean specifying if a texture is used in the material.
  46652. */
  46653. hasTexture(texture: BaseTexture): boolean;
  46654. /**
  46655. * Returns an array of the actively used textures.
  46656. * @param activeTextures Array of BaseTextures
  46657. */
  46658. getActiveTextures(activeTextures: BaseTexture[]): void;
  46659. /**
  46660. * Returns the animatable textures.
  46661. * @param animatables Array of animatable textures.
  46662. */
  46663. getAnimatables(animatables: IAnimatable[]): void;
  46664. /**
  46665. * Disposes the resources of the material.
  46666. * @param forceDisposeTextures - Forces the disposal of all textures.
  46667. */
  46668. dispose(forceDisposeTextures?: boolean): void;
  46669. /**
  46670. * Get the current class name of the texture useful for serialization or dynamic coding.
  46671. * @returns "PBRClearCoatConfiguration"
  46672. */
  46673. getClassName(): string;
  46674. /**
  46675. * Add fallbacks to the effect fallbacks list.
  46676. * @param defines defines the Base texture to use.
  46677. * @param fallbacks defines the current fallback list.
  46678. * @param currentRank defines the current fallback rank.
  46679. * @returns the new fallback rank.
  46680. */
  46681. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46682. /**
  46683. * Add the required uniforms to the current list.
  46684. * @param uniforms defines the current uniform list.
  46685. */
  46686. static AddUniforms(uniforms: string[]): void;
  46687. /**
  46688. * Add the required samplers to the current list.
  46689. * @param samplers defines the current sampler list.
  46690. */
  46691. static AddSamplers(samplers: string[]): void;
  46692. /**
  46693. * Add the required uniforms to the current buffer.
  46694. * @param uniformBuffer defines the current uniform buffer.
  46695. */
  46696. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46697. /**
  46698. * Makes a duplicate of the current configuration into another one.
  46699. * @param clearCoatConfiguration define the config where to copy the info
  46700. */
  46701. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46702. /**
  46703. * Serializes this clear coat configuration.
  46704. * @returns - An object with the serialized config.
  46705. */
  46706. serialize(): any;
  46707. /**
  46708. * Parses a anisotropy Configuration from a serialized object.
  46709. * @param source - Serialized object.
  46710. * @param scene Defines the scene we are parsing for
  46711. * @param rootUrl Defines the rootUrl to load from
  46712. */
  46713. parse(source: any, scene: Scene, rootUrl: string): void;
  46714. }
  46715. }
  46716. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46717. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46718. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46720. import { Vector2 } from "babylonjs/Maths/math";
  46721. import { Scene } from "babylonjs/scene";
  46722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46723. import { IAnimatable } from "babylonjs/Misc/tools";
  46724. import { Nullable } from "babylonjs/types";
  46725. /**
  46726. * @hidden
  46727. */
  46728. export interface IMaterialAnisotropicDefines {
  46729. ANISOTROPIC: boolean;
  46730. ANISOTROPIC_TEXTURE: boolean;
  46731. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46732. MAINUV1: boolean;
  46733. _areTexturesDirty: boolean;
  46734. _needUVs: boolean;
  46735. }
  46736. /**
  46737. * Define the code related to the anisotropic parameters of the pbr material.
  46738. */
  46739. export class PBRAnisotropicConfiguration {
  46740. private _isEnabled;
  46741. /**
  46742. * Defines if the anisotropy is enabled in the material.
  46743. */
  46744. isEnabled: boolean;
  46745. /**
  46746. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46747. */
  46748. intensity: number;
  46749. /**
  46750. * Defines if the effect is along the tangents, bitangents or in between.
  46751. * By default, the effect is "strectching" the highlights along the tangents.
  46752. */
  46753. direction: Vector2;
  46754. private _texture;
  46755. /**
  46756. * Stores the anisotropy values in a texture.
  46757. * rg is direction (like normal from -1 to 1)
  46758. * b is a intensity
  46759. */
  46760. texture: Nullable<BaseTexture>;
  46761. /** @hidden */
  46762. private _internalMarkAllSubMeshesAsTexturesDirty;
  46763. /** @hidden */
  46764. _markAllSubMeshesAsTexturesDirty(): void;
  46765. /**
  46766. * Instantiate a new istance of anisotropy configuration.
  46767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46768. */
  46769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46770. /**
  46771. * Specifies that the submesh is ready to be used.
  46772. * @param defines the list of "defines" to update.
  46773. * @param scene defines the scene the material belongs to.
  46774. * @returns - boolean indicating that the submesh is ready or not.
  46775. */
  46776. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46777. /**
  46778. * Checks to see if a texture is used in the material.
  46779. * @param defines the list of "defines" to update.
  46780. * @param mesh the mesh we are preparing the defines for.
  46781. * @param scene defines the scene the material belongs to.
  46782. */
  46783. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46784. /**
  46785. * Binds the material data.
  46786. * @param uniformBuffer defines the Uniform buffer to fill in.
  46787. * @param scene defines the scene the material belongs to.
  46788. * @param isFrozen defines wether the material is frozen or not.
  46789. */
  46790. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46791. /**
  46792. * Checks to see if a texture is used in the material.
  46793. * @param texture - Base texture to use.
  46794. * @returns - Boolean specifying if a texture is used in the material.
  46795. */
  46796. hasTexture(texture: BaseTexture): boolean;
  46797. /**
  46798. * Returns an array of the actively used textures.
  46799. * @param activeTextures Array of BaseTextures
  46800. */
  46801. getActiveTextures(activeTextures: BaseTexture[]): void;
  46802. /**
  46803. * Returns the animatable textures.
  46804. * @param animatables Array of animatable textures.
  46805. */
  46806. getAnimatables(animatables: IAnimatable[]): void;
  46807. /**
  46808. * Disposes the resources of the material.
  46809. * @param forceDisposeTextures - Forces the disposal of all textures.
  46810. */
  46811. dispose(forceDisposeTextures?: boolean): void;
  46812. /**
  46813. * Get the current class name of the texture useful for serialization or dynamic coding.
  46814. * @returns "PBRAnisotropicConfiguration"
  46815. */
  46816. getClassName(): string;
  46817. /**
  46818. * Add fallbacks to the effect fallbacks list.
  46819. * @param defines defines the Base texture to use.
  46820. * @param fallbacks defines the current fallback list.
  46821. * @param currentRank defines the current fallback rank.
  46822. * @returns the new fallback rank.
  46823. */
  46824. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46825. /**
  46826. * Add the required uniforms to the current list.
  46827. * @param uniforms defines the current uniform list.
  46828. */
  46829. static AddUniforms(uniforms: string[]): void;
  46830. /**
  46831. * Add the required uniforms to the current buffer.
  46832. * @param uniformBuffer defines the current uniform buffer.
  46833. */
  46834. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46835. /**
  46836. * Add the required samplers to the current list.
  46837. * @param samplers defines the current sampler list.
  46838. */
  46839. static AddSamplers(samplers: string[]): void;
  46840. /**
  46841. * Makes a duplicate of the current configuration into another one.
  46842. * @param anisotropicConfiguration define the config where to copy the info
  46843. */
  46844. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46845. /**
  46846. * Serializes this anisotropy configuration.
  46847. * @returns - An object with the serialized config.
  46848. */
  46849. serialize(): any;
  46850. /**
  46851. * Parses a anisotropy Configuration from a serialized object.
  46852. * @param source - Serialized object.
  46853. * @param scene Defines the scene we are parsing for
  46854. * @param rootUrl Defines the rootUrl to load from
  46855. */
  46856. parse(source: any, scene: Scene, rootUrl: string): void;
  46857. }
  46858. }
  46859. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46860. import { Scene } from "babylonjs/scene";
  46861. /**
  46862. * @hidden
  46863. */
  46864. export interface IMaterialBRDFDefines {
  46865. BRDF_V_HEIGHT_CORRELATED: boolean;
  46866. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46867. SPHERICAL_HARMONICS: boolean;
  46868. /** @hidden */
  46869. _areMiscDirty: boolean;
  46870. }
  46871. /**
  46872. * Define the code related to the BRDF parameters of the pbr material.
  46873. */
  46874. export class PBRBRDFConfiguration {
  46875. /**
  46876. * Default value used for the energy conservation.
  46877. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46878. */
  46879. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46880. /**
  46881. * Default value used for the Smith Visibility Height Correlated mode.
  46882. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46883. */
  46884. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46885. /**
  46886. * Default value used for the IBL diffuse part.
  46887. * This can help switching back to the polynomials mode globally which is a tiny bit
  46888. * less GPU intensive at the drawback of a lower quality.
  46889. */
  46890. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46891. private _useEnergyConservation;
  46892. /**
  46893. * Defines if the material uses energy conservation.
  46894. */
  46895. useEnergyConservation: boolean;
  46896. private _useSmithVisibilityHeightCorrelated;
  46897. /**
  46898. * LEGACY Mode set to false
  46899. * Defines if the material uses height smith correlated visibility term.
  46900. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46901. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46902. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46903. * Not relying on height correlated will also disable energy conservation.
  46904. */
  46905. useSmithVisibilityHeightCorrelated: boolean;
  46906. private _useSphericalHarmonics;
  46907. /**
  46908. * LEGACY Mode set to false
  46909. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46910. * diffuse part of the IBL.
  46911. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46912. * to the ground truth.
  46913. */
  46914. useSphericalHarmonics: boolean;
  46915. /** @hidden */
  46916. private _internalMarkAllSubMeshesAsMiscDirty;
  46917. /** @hidden */
  46918. _markAllSubMeshesAsMiscDirty(): void;
  46919. /**
  46920. * Instantiate a new istance of clear coat configuration.
  46921. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46922. */
  46923. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46924. /**
  46925. * Checks to see if a texture is used in the material.
  46926. * @param defines the list of "defines" to update.
  46927. */
  46928. prepareDefines(defines: IMaterialBRDFDefines): void;
  46929. /**
  46930. * Get the current class name of the texture useful for serialization or dynamic coding.
  46931. * @returns "PBRClearCoatConfiguration"
  46932. */
  46933. getClassName(): string;
  46934. /**
  46935. * Makes a duplicate of the current configuration into another one.
  46936. * @param brdfConfiguration define the config where to copy the info
  46937. */
  46938. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46939. /**
  46940. * Serializes this BRDF configuration.
  46941. * @returns - An object with the serialized config.
  46942. */
  46943. serialize(): any;
  46944. /**
  46945. * Parses a anisotropy Configuration from a serialized object.
  46946. * @param source - Serialized object.
  46947. * @param scene Defines the scene we are parsing for
  46948. * @param rootUrl Defines the rootUrl to load from
  46949. */
  46950. parse(source: any, scene: Scene, rootUrl: string): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46954. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46955. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46956. import { Color3 } from "babylonjs/Maths/math";
  46957. import { Scene } from "babylonjs/scene";
  46958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46959. import { IAnimatable } from "babylonjs/Misc/tools";
  46960. import { Nullable } from "babylonjs/types";
  46961. /**
  46962. * @hidden
  46963. */
  46964. export interface IMaterialSheenDefines {
  46965. SHEEN: boolean;
  46966. SHEEN_TEXTURE: boolean;
  46967. SHEEN_TEXTUREDIRECTUV: number;
  46968. SHEEN_LINKWITHALBEDO: boolean;
  46969. /** @hidden */
  46970. _areTexturesDirty: boolean;
  46971. }
  46972. /**
  46973. * Define the code related to the Sheen parameters of the pbr material.
  46974. */
  46975. export class PBRSheenConfiguration {
  46976. private _isEnabled;
  46977. /**
  46978. * Defines if the material uses sheen.
  46979. */
  46980. isEnabled: boolean;
  46981. private _linkSheenWithAlbedo;
  46982. /**
  46983. * Defines if the sheen is linked to the sheen color.
  46984. */
  46985. linkSheenWithAlbedo: boolean;
  46986. /**
  46987. * Defines the sheen intensity.
  46988. */
  46989. intensity: number;
  46990. /**
  46991. * Defines the sheen color.
  46992. */
  46993. color: Color3;
  46994. private _texture;
  46995. /**
  46996. * Stores the sheen tint values in a texture.
  46997. * rgb is tint
  46998. * a is a intensity
  46999. */
  47000. texture: Nullable<BaseTexture>;
  47001. /** @hidden */
  47002. private _internalMarkAllSubMeshesAsTexturesDirty;
  47003. /** @hidden */
  47004. _markAllSubMeshesAsTexturesDirty(): void;
  47005. /**
  47006. * Instantiate a new istance of clear coat configuration.
  47007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47008. */
  47009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47010. /**
  47011. * Specifies that the submesh is ready to be used.
  47012. * @param defines the list of "defines" to update.
  47013. * @param scene defines the scene the material belongs to.
  47014. * @returns - boolean indicating that the submesh is ready or not.
  47015. */
  47016. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47017. /**
  47018. * Checks to see if a texture is used in the material.
  47019. * @param defines the list of "defines" to update.
  47020. * @param scene defines the scene the material belongs to.
  47021. */
  47022. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47023. /**
  47024. * Binds the material data.
  47025. * @param uniformBuffer defines the Uniform buffer to fill in.
  47026. * @param scene defines the scene the material belongs to.
  47027. * @param isFrozen defines wether the material is frozen or not.
  47028. */
  47029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47030. /**
  47031. * Checks to see if a texture is used in the material.
  47032. * @param texture - Base texture to use.
  47033. * @returns - Boolean specifying if a texture is used in the material.
  47034. */
  47035. hasTexture(texture: BaseTexture): boolean;
  47036. /**
  47037. * Returns an array of the actively used textures.
  47038. * @param activeTextures Array of BaseTextures
  47039. */
  47040. getActiveTextures(activeTextures: BaseTexture[]): void;
  47041. /**
  47042. * Returns the animatable textures.
  47043. * @param animatables Array of animatable textures.
  47044. */
  47045. getAnimatables(animatables: IAnimatable[]): void;
  47046. /**
  47047. * Disposes the resources of the material.
  47048. * @param forceDisposeTextures - Forces the disposal of all textures.
  47049. */
  47050. dispose(forceDisposeTextures?: boolean): void;
  47051. /**
  47052. * Get the current class name of the texture useful for serialization or dynamic coding.
  47053. * @returns "PBRSheenConfiguration"
  47054. */
  47055. getClassName(): string;
  47056. /**
  47057. * Add fallbacks to the effect fallbacks list.
  47058. * @param defines defines the Base texture to use.
  47059. * @param fallbacks defines the current fallback list.
  47060. * @param currentRank defines the current fallback rank.
  47061. * @returns the new fallback rank.
  47062. */
  47063. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47064. /**
  47065. * Add the required uniforms to the current list.
  47066. * @param uniforms defines the current uniform list.
  47067. */
  47068. static AddUniforms(uniforms: string[]): void;
  47069. /**
  47070. * Add the required uniforms to the current buffer.
  47071. * @param uniformBuffer defines the current uniform buffer.
  47072. */
  47073. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47074. /**
  47075. * Add the required samplers to the current list.
  47076. * @param samplers defines the current sampler list.
  47077. */
  47078. static AddSamplers(samplers: string[]): void;
  47079. /**
  47080. * Makes a duplicate of the current configuration into another one.
  47081. * @param sheenConfiguration define the config where to copy the info
  47082. */
  47083. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47084. /**
  47085. * Serializes this BRDF configuration.
  47086. * @returns - An object with the serialized config.
  47087. */
  47088. serialize(): any;
  47089. /**
  47090. * Parses a anisotropy Configuration from a serialized object.
  47091. * @param source - Serialized object.
  47092. * @param scene Defines the scene we are parsing for
  47093. * @param rootUrl Defines the rootUrl to load from
  47094. */
  47095. parse(source: any, scene: Scene, rootUrl: string): void;
  47096. }
  47097. }
  47098. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47099. import { Nullable } from "babylonjs/types";
  47100. import { IAnimatable } from "babylonjs/Misc/tools";
  47101. import { Color3 } from "babylonjs/Maths/math";
  47102. import { SmartArray } from "babylonjs/Misc/smartArray";
  47103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47104. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47105. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47106. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47107. import { Engine } from "babylonjs/Engines/engine";
  47108. import { Scene } from "babylonjs/scene";
  47109. /**
  47110. * @hidden
  47111. */
  47112. export interface IMaterialSubSurfaceDefines {
  47113. SUBSURFACE: boolean;
  47114. SS_REFRACTION: boolean;
  47115. SS_TRANSLUCENCY: boolean;
  47116. SS_SCATERRING: boolean;
  47117. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47118. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47119. SS_REFRACTIONMAP_3D: boolean;
  47120. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47121. SS_LODINREFRACTIONALPHA: boolean;
  47122. SS_GAMMAREFRACTION: boolean;
  47123. SS_RGBDREFRACTION: boolean;
  47124. SS_LINEARSPECULARREFRACTION: boolean;
  47125. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47126. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47127. /** @hidden */
  47128. _areTexturesDirty: boolean;
  47129. }
  47130. /**
  47131. * Define the code related to the sub surface parameters of the pbr material.
  47132. */
  47133. export class PBRSubSurfaceConfiguration {
  47134. private _isRefractionEnabled;
  47135. /**
  47136. * Defines if the refraction is enabled in the material.
  47137. */
  47138. isRefractionEnabled: boolean;
  47139. private _isTranslucencyEnabled;
  47140. /**
  47141. * Defines if the translucency is enabled in the material.
  47142. */
  47143. isTranslucencyEnabled: boolean;
  47144. private _isScatteringEnabled;
  47145. /**
  47146. * Defines the refraction intensity of the material.
  47147. * The refraction when enabled replaces the Diffuse part of the material.
  47148. * The intensity helps transitionning between diffuse and refraction.
  47149. */
  47150. refractionIntensity: number;
  47151. /**
  47152. * Defines the translucency intensity of the material.
  47153. * When translucency has been enabled, this defines how much of the "translucency"
  47154. * is addded to the diffuse part of the material.
  47155. */
  47156. translucencyIntensity: number;
  47157. /**
  47158. * Defines the scattering intensity of the material.
  47159. * When scattering has been enabled, this defines how much of the "scattered light"
  47160. * is addded to the diffuse part of the material.
  47161. */
  47162. scatteringIntensity: number;
  47163. private _thicknessTexture;
  47164. /**
  47165. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47166. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47167. * 0 would mean minimumThickness
  47168. * 1 would mean maximumThickness
  47169. * The other channels might be use as a mask to vary the different effects intensity.
  47170. */
  47171. thicknessTexture: Nullable<BaseTexture>;
  47172. private _refractionTexture;
  47173. /**
  47174. * Defines the texture to use for refraction.
  47175. */
  47176. refractionTexture: Nullable<BaseTexture>;
  47177. private _indexOfRefraction;
  47178. /**
  47179. * Defines the index of refraction used in the material.
  47180. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47181. */
  47182. indexOfRefraction: number;
  47183. private _invertRefractionY;
  47184. /**
  47185. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47186. */
  47187. invertRefractionY: boolean;
  47188. private _linkRefractionWithTransparency;
  47189. /**
  47190. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47191. * Materials half opaque for instance using refraction could benefit from this control.
  47192. */
  47193. linkRefractionWithTransparency: boolean;
  47194. /**
  47195. * Defines the minimum thickness stored in the thickness map.
  47196. * If no thickness map is defined, this value will be used to simulate thickness.
  47197. */
  47198. minimumThickness: number;
  47199. /**
  47200. * Defines the maximum thickness stored in the thickness map.
  47201. */
  47202. maximumThickness: number;
  47203. /**
  47204. * Defines the volume tint of the material.
  47205. * This is used for both translucency and scattering.
  47206. */
  47207. tintColor: Color3;
  47208. /**
  47209. * Defines the distance at which the tint color should be found in the media.
  47210. * This is used for refraction only.
  47211. */
  47212. tintColorAtDistance: number;
  47213. /**
  47214. * Defines how far each channel transmit through the media.
  47215. * It is defined as a color to simplify it selection.
  47216. */
  47217. diffusionDistance: Color3;
  47218. private _useMaskFromThicknessTexture;
  47219. /**
  47220. * Stores the intensity of the different subsurface effects in the thickness texture.
  47221. * * the green channel is the translucency intensity.
  47222. * * the blue channel is the scattering intensity.
  47223. * * the alpha channel is the refraction intensity.
  47224. */
  47225. useMaskFromThicknessTexture: boolean;
  47226. /** @hidden */
  47227. private _internalMarkAllSubMeshesAsTexturesDirty;
  47228. /** @hidden */
  47229. _markAllSubMeshesAsTexturesDirty(): void;
  47230. /**
  47231. * Instantiate a new istance of sub surface configuration.
  47232. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47233. */
  47234. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47235. /**
  47236. * Gets wehter the submesh is ready to be used or not.
  47237. * @param defines the list of "defines" to update.
  47238. * @param scene defines the scene the material belongs to.
  47239. * @returns - boolean indicating that the submesh is ready or not.
  47240. */
  47241. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47242. /**
  47243. * Checks to see if a texture is used in the material.
  47244. * @param defines the list of "defines" to update.
  47245. * @param scene defines the scene to the material belongs to.
  47246. */
  47247. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47248. /**
  47249. * Binds the material data.
  47250. * @param uniformBuffer defines the Uniform buffer to fill in.
  47251. * @param scene defines the scene the material belongs to.
  47252. * @param engine defines the engine the material belongs to.
  47253. * @param isFrozen defines wether the material is frozen or not.
  47254. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47255. */
  47256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47257. /**
  47258. * Unbinds the material from the mesh.
  47259. * @param activeEffect defines the effect that should be unbound from.
  47260. * @returns true if unbound, otherwise false
  47261. */
  47262. unbind(activeEffect: Effect): boolean;
  47263. /**
  47264. * Returns the texture used for refraction or null if none is used.
  47265. * @param scene defines the scene the material belongs to.
  47266. * @returns - Refraction texture if present. If no refraction texture and refraction
  47267. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47268. */
  47269. private _getRefractionTexture;
  47270. /**
  47271. * Returns true if alpha blending should be disabled.
  47272. */
  47273. readonly disableAlphaBlending: boolean;
  47274. /**
  47275. * Fills the list of render target textures.
  47276. * @param renderTargets the list of render targets to update
  47277. */
  47278. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47279. /**
  47280. * Checks to see if a texture is used in the material.
  47281. * @param texture - Base texture to use.
  47282. * @returns - Boolean specifying if a texture is used in the material.
  47283. */
  47284. hasTexture(texture: BaseTexture): boolean;
  47285. /**
  47286. * Gets a boolean indicating that current material needs to register RTT
  47287. * @returns true if this uses a render target otherwise false.
  47288. */
  47289. hasRenderTargetTextures(): boolean;
  47290. /**
  47291. * Returns an array of the actively used textures.
  47292. * @param activeTextures Array of BaseTextures
  47293. */
  47294. getActiveTextures(activeTextures: BaseTexture[]): void;
  47295. /**
  47296. * Returns the animatable textures.
  47297. * @param animatables Array of animatable textures.
  47298. */
  47299. getAnimatables(animatables: IAnimatable[]): void;
  47300. /**
  47301. * Disposes the resources of the material.
  47302. * @param forceDisposeTextures - Forces the disposal of all textures.
  47303. */
  47304. dispose(forceDisposeTextures?: boolean): void;
  47305. /**
  47306. * Get the current class name of the texture useful for serialization or dynamic coding.
  47307. * @returns "PBRSubSurfaceConfiguration"
  47308. */
  47309. getClassName(): string;
  47310. /**
  47311. * Add fallbacks to the effect fallbacks list.
  47312. * @param defines defines the Base texture to use.
  47313. * @param fallbacks defines the current fallback list.
  47314. * @param currentRank defines the current fallback rank.
  47315. * @returns the new fallback rank.
  47316. */
  47317. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47318. /**
  47319. * Add the required uniforms to the current list.
  47320. * @param uniforms defines the current uniform list.
  47321. */
  47322. static AddUniforms(uniforms: string[]): void;
  47323. /**
  47324. * Add the required samplers to the current list.
  47325. * @param samplers defines the current sampler list.
  47326. */
  47327. static AddSamplers(samplers: string[]): void;
  47328. /**
  47329. * Add the required uniforms to the current buffer.
  47330. * @param uniformBuffer defines the current uniform buffer.
  47331. */
  47332. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47333. /**
  47334. * Makes a duplicate of the current configuration into another one.
  47335. * @param configuration define the config where to copy the info
  47336. */
  47337. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47338. /**
  47339. * Serializes this Sub Surface configuration.
  47340. * @returns - An object with the serialized config.
  47341. */
  47342. serialize(): any;
  47343. /**
  47344. * Parses a anisotropy Configuration from a serialized object.
  47345. * @param source - Serialized object.
  47346. * @param scene Defines the scene we are parsing for
  47347. * @param rootUrl Defines the rootUrl to load from
  47348. */
  47349. parse(source: any, scene: Scene, rootUrl: string): void;
  47350. }
  47351. }
  47352. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47353. /** @hidden */
  47354. export var pbrFragmentDeclaration: {
  47355. name: string;
  47356. shader: string;
  47357. };
  47358. }
  47359. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47360. /** @hidden */
  47361. export var pbrUboDeclaration: {
  47362. name: string;
  47363. shader: string;
  47364. };
  47365. }
  47366. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47367. /** @hidden */
  47368. export var pbrFragmentExtraDeclaration: {
  47369. name: string;
  47370. shader: string;
  47371. };
  47372. }
  47373. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47374. /** @hidden */
  47375. export var pbrFragmentSamplersDeclaration: {
  47376. name: string;
  47377. shader: string;
  47378. };
  47379. }
  47380. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47381. /** @hidden */
  47382. export var pbrHelperFunctions: {
  47383. name: string;
  47384. shader: string;
  47385. };
  47386. }
  47387. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47388. /** @hidden */
  47389. export var harmonicsFunctions: {
  47390. name: string;
  47391. shader: string;
  47392. };
  47393. }
  47394. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47395. /** @hidden */
  47396. export var pbrDirectLightingSetupFunctions: {
  47397. name: string;
  47398. shader: string;
  47399. };
  47400. }
  47401. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47402. /** @hidden */
  47403. export var pbrDirectLightingFalloffFunctions: {
  47404. name: string;
  47405. shader: string;
  47406. };
  47407. }
  47408. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47409. /** @hidden */
  47410. export var pbrBRDFFunctions: {
  47411. name: string;
  47412. shader: string;
  47413. };
  47414. }
  47415. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47416. /** @hidden */
  47417. export var pbrDirectLightingFunctions: {
  47418. name: string;
  47419. shader: string;
  47420. };
  47421. }
  47422. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47423. /** @hidden */
  47424. export var pbrIBLFunctions: {
  47425. name: string;
  47426. shader: string;
  47427. };
  47428. }
  47429. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47430. /** @hidden */
  47431. export var pbrDebug: {
  47432. name: string;
  47433. shader: string;
  47434. };
  47435. }
  47436. declare module "babylonjs/Shaders/pbr.fragment" {
  47437. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47438. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47439. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47440. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47441. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47442. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47443. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47444. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47445. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47446. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47448. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47449. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47450. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47451. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47452. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47453. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47454. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47455. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47456. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47457. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47458. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47459. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47460. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47461. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47462. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47463. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47464. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47465. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47466. /** @hidden */
  47467. export var pbrPixelShader: {
  47468. name: string;
  47469. shader: string;
  47470. };
  47471. }
  47472. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47473. /** @hidden */
  47474. export var pbrVertexDeclaration: {
  47475. name: string;
  47476. shader: string;
  47477. };
  47478. }
  47479. declare module "babylonjs/Shaders/pbr.vertex" {
  47480. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47481. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47482. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47484. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47485. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47486. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47487. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47488. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47489. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47490. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47493. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47495. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47496. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47497. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47499. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47500. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47501. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47502. /** @hidden */
  47503. export var pbrVertexShader: {
  47504. name: string;
  47505. shader: string;
  47506. };
  47507. }
  47508. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47509. import { IAnimatable } from "babylonjs/Misc/tools";
  47510. import { Nullable } from "babylonjs/types";
  47511. import { Scene } from "babylonjs/scene";
  47512. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47513. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47515. import { Mesh } from "babylonjs/Meshes/mesh";
  47516. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47517. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47518. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47519. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47520. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47521. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47522. import { Material } from "babylonjs/Materials/material";
  47523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47524. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47526. import "babylonjs/Shaders/pbr.fragment";
  47527. import "babylonjs/Shaders/pbr.vertex";
  47528. /**
  47529. * Manages the defines for the PBR Material.
  47530. * @hidden
  47531. */
  47532. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47533. PBR: boolean;
  47534. MAINUV1: boolean;
  47535. MAINUV2: boolean;
  47536. UV1: boolean;
  47537. UV2: boolean;
  47538. ALBEDO: boolean;
  47539. ALBEDODIRECTUV: number;
  47540. VERTEXCOLOR: boolean;
  47541. AMBIENT: boolean;
  47542. AMBIENTDIRECTUV: number;
  47543. AMBIENTINGRAYSCALE: boolean;
  47544. OPACITY: boolean;
  47545. VERTEXALPHA: boolean;
  47546. OPACITYDIRECTUV: number;
  47547. OPACITYRGB: boolean;
  47548. ALPHATEST: boolean;
  47549. DEPTHPREPASS: boolean;
  47550. ALPHABLEND: boolean;
  47551. ALPHAFROMALBEDO: boolean;
  47552. ALPHATESTVALUE: string;
  47553. SPECULAROVERALPHA: boolean;
  47554. RADIANCEOVERALPHA: boolean;
  47555. ALPHAFRESNEL: boolean;
  47556. LINEARALPHAFRESNEL: boolean;
  47557. PREMULTIPLYALPHA: boolean;
  47558. EMISSIVE: boolean;
  47559. EMISSIVEDIRECTUV: number;
  47560. REFLECTIVITY: boolean;
  47561. REFLECTIVITYDIRECTUV: number;
  47562. SPECULARTERM: boolean;
  47563. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47564. MICROSURFACEAUTOMATIC: boolean;
  47565. LODBASEDMICROSFURACE: boolean;
  47566. MICROSURFACEMAP: boolean;
  47567. MICROSURFACEMAPDIRECTUV: number;
  47568. METALLICWORKFLOW: boolean;
  47569. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47570. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47571. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47572. AOSTOREINMETALMAPRED: boolean;
  47573. ENVIRONMENTBRDF: boolean;
  47574. ENVIRONMENTBRDF_RGBD: boolean;
  47575. NORMAL: boolean;
  47576. TANGENT: boolean;
  47577. BUMP: boolean;
  47578. BUMPDIRECTUV: number;
  47579. OBJECTSPACE_NORMALMAP: boolean;
  47580. PARALLAX: boolean;
  47581. PARALLAXOCCLUSION: boolean;
  47582. NORMALXYSCALE: boolean;
  47583. LIGHTMAP: boolean;
  47584. LIGHTMAPDIRECTUV: number;
  47585. USELIGHTMAPASSHADOWMAP: boolean;
  47586. GAMMALIGHTMAP: boolean;
  47587. REFLECTION: boolean;
  47588. REFLECTIONMAP_3D: boolean;
  47589. REFLECTIONMAP_SPHERICAL: boolean;
  47590. REFLECTIONMAP_PLANAR: boolean;
  47591. REFLECTIONMAP_CUBIC: boolean;
  47592. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47593. REFLECTIONMAP_PROJECTION: boolean;
  47594. REFLECTIONMAP_SKYBOX: boolean;
  47595. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47596. REFLECTIONMAP_EXPLICIT: boolean;
  47597. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47598. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47599. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47600. INVERTCUBICMAP: boolean;
  47601. USESPHERICALFROMREFLECTIONMAP: boolean;
  47602. USEIRRADIANCEMAP: boolean;
  47603. SPHERICAL_HARMONICS: boolean;
  47604. USESPHERICALINVERTEX: boolean;
  47605. REFLECTIONMAP_OPPOSITEZ: boolean;
  47606. LODINREFLECTIONALPHA: boolean;
  47607. GAMMAREFLECTION: boolean;
  47608. RGBDREFLECTION: boolean;
  47609. LINEARSPECULARREFLECTION: boolean;
  47610. RADIANCEOCCLUSION: boolean;
  47611. HORIZONOCCLUSION: boolean;
  47612. INSTANCES: boolean;
  47613. NUM_BONE_INFLUENCERS: number;
  47614. BonesPerMesh: number;
  47615. BONETEXTURE: boolean;
  47616. NONUNIFORMSCALING: boolean;
  47617. MORPHTARGETS: boolean;
  47618. MORPHTARGETS_NORMAL: boolean;
  47619. MORPHTARGETS_TANGENT: boolean;
  47620. MORPHTARGETS_UV: boolean;
  47621. NUM_MORPH_INFLUENCERS: number;
  47622. IMAGEPROCESSING: boolean;
  47623. VIGNETTE: boolean;
  47624. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47625. VIGNETTEBLENDMODEOPAQUE: boolean;
  47626. TONEMAPPING: boolean;
  47627. TONEMAPPING_ACES: boolean;
  47628. CONTRAST: boolean;
  47629. COLORCURVES: boolean;
  47630. COLORGRADING: boolean;
  47631. COLORGRADING3D: boolean;
  47632. SAMPLER3DGREENDEPTH: boolean;
  47633. SAMPLER3DBGRMAP: boolean;
  47634. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47635. EXPOSURE: boolean;
  47636. MULTIVIEW: boolean;
  47637. USEPHYSICALLIGHTFALLOFF: boolean;
  47638. USEGLTFLIGHTFALLOFF: boolean;
  47639. TWOSIDEDLIGHTING: boolean;
  47640. SHADOWFLOAT: boolean;
  47641. CLIPPLANE: boolean;
  47642. CLIPPLANE2: boolean;
  47643. CLIPPLANE3: boolean;
  47644. CLIPPLANE4: boolean;
  47645. POINTSIZE: boolean;
  47646. FOG: boolean;
  47647. LOGARITHMICDEPTH: boolean;
  47648. FORCENORMALFORWARD: boolean;
  47649. SPECULARAA: boolean;
  47650. CLEARCOAT: boolean;
  47651. CLEARCOAT_DEFAULTIOR: boolean;
  47652. CLEARCOAT_TEXTURE: boolean;
  47653. CLEARCOAT_TEXTUREDIRECTUV: number;
  47654. CLEARCOAT_BUMP: boolean;
  47655. CLEARCOAT_BUMPDIRECTUV: number;
  47656. CLEARCOAT_TINT: boolean;
  47657. CLEARCOAT_TINT_TEXTURE: boolean;
  47658. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47659. ANISOTROPIC: boolean;
  47660. ANISOTROPIC_TEXTURE: boolean;
  47661. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47662. BRDF_V_HEIGHT_CORRELATED: boolean;
  47663. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47664. SHEEN: boolean;
  47665. SHEEN_TEXTURE: boolean;
  47666. SHEEN_TEXTUREDIRECTUV: number;
  47667. SHEEN_LINKWITHALBEDO: boolean;
  47668. SUBSURFACE: boolean;
  47669. SS_REFRACTION: boolean;
  47670. SS_TRANSLUCENCY: boolean;
  47671. SS_SCATERRING: boolean;
  47672. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47673. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47674. SS_REFRACTIONMAP_3D: boolean;
  47675. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47676. SS_LODINREFRACTIONALPHA: boolean;
  47677. SS_GAMMAREFRACTION: boolean;
  47678. SS_RGBDREFRACTION: boolean;
  47679. SS_LINEARSPECULARREFRACTION: boolean;
  47680. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47681. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47682. UNLIT: boolean;
  47683. DEBUGMODE: number;
  47684. /**
  47685. * Initializes the PBR Material defines.
  47686. */
  47687. constructor();
  47688. /**
  47689. * Resets the PBR Material defines.
  47690. */
  47691. reset(): void;
  47692. }
  47693. /**
  47694. * The Physically based material base class of BJS.
  47695. *
  47696. * This offers the main features of a standard PBR material.
  47697. * For more information, please refer to the documentation :
  47698. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47699. */
  47700. export abstract class PBRBaseMaterial extends PushMaterial {
  47701. /**
  47702. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47703. */
  47704. static readonly PBRMATERIAL_OPAQUE: number;
  47705. /**
  47706. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47707. */
  47708. static readonly PBRMATERIAL_ALPHATEST: number;
  47709. /**
  47710. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47711. */
  47712. static readonly PBRMATERIAL_ALPHABLEND: number;
  47713. /**
  47714. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47715. * They are also discarded below the alpha cutoff threshold to improve performances.
  47716. */
  47717. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47718. /**
  47719. * Defines the default value of how much AO map is occluding the analytical lights
  47720. * (point spot...).
  47721. */
  47722. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47723. /**
  47724. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47725. */
  47726. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47727. /**
  47728. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47729. * to enhance interoperability with other engines.
  47730. */
  47731. static readonly LIGHTFALLOFF_GLTF: number;
  47732. /**
  47733. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47734. * to enhance interoperability with other materials.
  47735. */
  47736. static readonly LIGHTFALLOFF_STANDARD: number;
  47737. /**
  47738. * Intensity of the direct lights e.g. the four lights available in your scene.
  47739. * This impacts both the direct diffuse and specular highlights.
  47740. */
  47741. protected _directIntensity: number;
  47742. /**
  47743. * Intensity of the emissive part of the material.
  47744. * This helps controlling the emissive effect without modifying the emissive color.
  47745. */
  47746. protected _emissiveIntensity: number;
  47747. /**
  47748. * Intensity of the environment e.g. how much the environment will light the object
  47749. * either through harmonics for rough material or through the refelction for shiny ones.
  47750. */
  47751. protected _environmentIntensity: number;
  47752. /**
  47753. * This is a special control allowing the reduction of the specular highlights coming from the
  47754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47755. */
  47756. protected _specularIntensity: number;
  47757. /**
  47758. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47759. */
  47760. private _lightingInfos;
  47761. /**
  47762. * Debug Control allowing disabling the bump map on this material.
  47763. */
  47764. protected _disableBumpMap: boolean;
  47765. /**
  47766. * AKA Diffuse Texture in standard nomenclature.
  47767. */
  47768. protected _albedoTexture: Nullable<BaseTexture>;
  47769. /**
  47770. * AKA Occlusion Texture in other nomenclature.
  47771. */
  47772. protected _ambientTexture: Nullable<BaseTexture>;
  47773. /**
  47774. * AKA Occlusion Texture Intensity in other nomenclature.
  47775. */
  47776. protected _ambientTextureStrength: number;
  47777. /**
  47778. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47779. * 1 means it completely occludes it
  47780. * 0 mean it has no impact
  47781. */
  47782. protected _ambientTextureImpactOnAnalyticalLights: number;
  47783. /**
  47784. * Stores the alpha values in a texture.
  47785. */
  47786. protected _opacityTexture: Nullable<BaseTexture>;
  47787. /**
  47788. * Stores the reflection values in a texture.
  47789. */
  47790. protected _reflectionTexture: Nullable<BaseTexture>;
  47791. /**
  47792. * Stores the emissive values in a texture.
  47793. */
  47794. protected _emissiveTexture: Nullable<BaseTexture>;
  47795. /**
  47796. * AKA Specular texture in other nomenclature.
  47797. */
  47798. protected _reflectivityTexture: Nullable<BaseTexture>;
  47799. /**
  47800. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47801. */
  47802. protected _metallicTexture: Nullable<BaseTexture>;
  47803. /**
  47804. * Specifies the metallic scalar of the metallic/roughness workflow.
  47805. * Can also be used to scale the metalness values of the metallic texture.
  47806. */
  47807. protected _metallic: Nullable<number>;
  47808. /**
  47809. * Specifies the roughness scalar of the metallic/roughness workflow.
  47810. * Can also be used to scale the roughness values of the metallic texture.
  47811. */
  47812. protected _roughness: Nullable<number>;
  47813. /**
  47814. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47815. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47816. */
  47817. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47818. /**
  47819. * Stores surface normal data used to displace a mesh in a texture.
  47820. */
  47821. protected _bumpTexture: Nullable<BaseTexture>;
  47822. /**
  47823. * Stores the pre-calculated light information of a mesh in a texture.
  47824. */
  47825. protected _lightmapTexture: Nullable<BaseTexture>;
  47826. /**
  47827. * The color of a material in ambient lighting.
  47828. */
  47829. protected _ambientColor: Color3;
  47830. /**
  47831. * AKA Diffuse Color in other nomenclature.
  47832. */
  47833. protected _albedoColor: Color3;
  47834. /**
  47835. * AKA Specular Color in other nomenclature.
  47836. */
  47837. protected _reflectivityColor: Color3;
  47838. /**
  47839. * The color applied when light is reflected from a material.
  47840. */
  47841. protected _reflectionColor: Color3;
  47842. /**
  47843. * The color applied when light is emitted from a material.
  47844. */
  47845. protected _emissiveColor: Color3;
  47846. /**
  47847. * AKA Glossiness in other nomenclature.
  47848. */
  47849. protected _microSurface: number;
  47850. /**
  47851. * Specifies that the material will use the light map as a show map.
  47852. */
  47853. protected _useLightmapAsShadowmap: boolean;
  47854. /**
  47855. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47856. * makes the reflect vector face the model (under horizon).
  47857. */
  47858. protected _useHorizonOcclusion: boolean;
  47859. /**
  47860. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47861. * too much the area relying on ambient texture to define their ambient occlusion.
  47862. */
  47863. protected _useRadianceOcclusion: boolean;
  47864. /**
  47865. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47866. */
  47867. protected _useAlphaFromAlbedoTexture: boolean;
  47868. /**
  47869. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47871. */
  47872. protected _useSpecularOverAlpha: boolean;
  47873. /**
  47874. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47875. */
  47876. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47877. /**
  47878. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47879. */
  47880. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47881. /**
  47882. * Specifies if the metallic texture contains the roughness information in its green channel.
  47883. */
  47884. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47885. /**
  47886. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47887. */
  47888. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47889. /**
  47890. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47891. */
  47892. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47893. /**
  47894. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47895. */
  47896. protected _useAmbientInGrayScale: boolean;
  47897. /**
  47898. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47899. * The material will try to infer what glossiness each pixel should be.
  47900. */
  47901. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47902. /**
  47903. * Defines the falloff type used in this material.
  47904. * It by default is Physical.
  47905. */
  47906. protected _lightFalloff: number;
  47907. /**
  47908. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47909. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47910. */
  47911. protected _useRadianceOverAlpha: boolean;
  47912. /**
  47913. * Allows using an object space normal map (instead of tangent space).
  47914. */
  47915. protected _useObjectSpaceNormalMap: boolean;
  47916. /**
  47917. * Allows using the bump map in parallax mode.
  47918. */
  47919. protected _useParallax: boolean;
  47920. /**
  47921. * Allows using the bump map in parallax occlusion mode.
  47922. */
  47923. protected _useParallaxOcclusion: boolean;
  47924. /**
  47925. * Controls the scale bias of the parallax mode.
  47926. */
  47927. protected _parallaxScaleBias: number;
  47928. /**
  47929. * If sets to true, disables all the lights affecting the material.
  47930. */
  47931. protected _disableLighting: boolean;
  47932. /**
  47933. * Number of Simultaneous lights allowed on the material.
  47934. */
  47935. protected _maxSimultaneousLights: number;
  47936. /**
  47937. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47938. */
  47939. protected _invertNormalMapX: boolean;
  47940. /**
  47941. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47942. */
  47943. protected _invertNormalMapY: boolean;
  47944. /**
  47945. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47946. */
  47947. protected _twoSidedLighting: boolean;
  47948. /**
  47949. * Defines the alpha limits in alpha test mode.
  47950. */
  47951. protected _alphaCutOff: number;
  47952. /**
  47953. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47954. */
  47955. protected _forceAlphaTest: boolean;
  47956. /**
  47957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47958. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47959. */
  47960. protected _useAlphaFresnel: boolean;
  47961. /**
  47962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47963. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47964. */
  47965. protected _useLinearAlphaFresnel: boolean;
  47966. /**
  47967. * The transparency mode of the material.
  47968. */
  47969. protected _transparencyMode: Nullable<number>;
  47970. /**
  47971. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47972. * from cos thetav and roughness:
  47973. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47974. */
  47975. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47976. /**
  47977. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47978. */
  47979. protected _forceIrradianceInFragment: boolean;
  47980. /**
  47981. * Force normal to face away from face.
  47982. */
  47983. protected _forceNormalForward: boolean;
  47984. /**
  47985. * Enables specular anti aliasing in the PBR shader.
  47986. * It will both interacts on the Geometry for analytical and IBL lighting.
  47987. * It also prefilter the roughness map based on the bump values.
  47988. */
  47989. protected _enableSpecularAntiAliasing: boolean;
  47990. /**
  47991. * Default configuration related to image processing available in the PBR Material.
  47992. */
  47993. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47994. /**
  47995. * Keep track of the image processing observer to allow dispose and replace.
  47996. */
  47997. private _imageProcessingObserver;
  47998. /**
  47999. * Attaches a new image processing configuration to the PBR Material.
  48000. * @param configuration
  48001. */
  48002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48003. /**
  48004. * Stores the available render targets.
  48005. */
  48006. private _renderTargets;
  48007. /**
  48008. * Sets the global ambient color for the material used in lighting calculations.
  48009. */
  48010. private _globalAmbientColor;
  48011. /**
  48012. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48013. */
  48014. private _useLogarithmicDepth;
  48015. /**
  48016. * If set to true, no lighting calculations will be applied.
  48017. */
  48018. private _unlit;
  48019. private _debugMode;
  48020. /**
  48021. * @hidden
  48022. * This is reserved for the inspector.
  48023. * Defines the material debug mode.
  48024. * It helps seeing only some components of the material while troubleshooting.
  48025. */
  48026. debugMode: number;
  48027. /**
  48028. * @hidden
  48029. * This is reserved for the inspector.
  48030. * Specify from where on screen the debug mode should start.
  48031. * The value goes from -1 (full screen) to 1 (not visible)
  48032. * It helps with side by side comparison against the final render
  48033. * This defaults to -1
  48034. */
  48035. private debugLimit;
  48036. /**
  48037. * @hidden
  48038. * This is reserved for the inspector.
  48039. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48040. * You can use the factor to better multiply the final value.
  48041. */
  48042. private debugFactor;
  48043. /**
  48044. * Defines the clear coat layer parameters for the material.
  48045. */
  48046. readonly clearCoat: PBRClearCoatConfiguration;
  48047. /**
  48048. * Defines the anisotropic parameters for the material.
  48049. */
  48050. readonly anisotropy: PBRAnisotropicConfiguration;
  48051. /**
  48052. * Defines the BRDF parameters for the material.
  48053. */
  48054. readonly brdf: PBRBRDFConfiguration;
  48055. /**
  48056. * Defines the Sheen parameters for the material.
  48057. */
  48058. readonly sheen: PBRSheenConfiguration;
  48059. /**
  48060. * Defines the SubSurface parameters for the material.
  48061. */
  48062. readonly subSurface: PBRSubSurfaceConfiguration;
  48063. /**
  48064. * Custom callback helping to override the default shader used in the material.
  48065. */
  48066. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48067. /**
  48068. * Instantiates a new PBRMaterial instance.
  48069. *
  48070. * @param name The material name
  48071. * @param scene The scene the material will be use in.
  48072. */
  48073. constructor(name: string, scene: Scene);
  48074. /**
  48075. * Gets a boolean indicating that current material needs to register RTT
  48076. */
  48077. readonly hasRenderTargetTextures: boolean;
  48078. /**
  48079. * Gets the name of the material class.
  48080. */
  48081. getClassName(): string;
  48082. /**
  48083. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48084. */
  48085. /**
  48086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48087. */
  48088. useLogarithmicDepth: boolean;
  48089. /**
  48090. * Gets the current transparency mode.
  48091. */
  48092. /**
  48093. * Sets the transparency mode of the material.
  48094. *
  48095. * | Value | Type | Description |
  48096. * | ----- | ----------------------------------- | ----------- |
  48097. * | 0 | OPAQUE | |
  48098. * | 1 | ALPHATEST | |
  48099. * | 2 | ALPHABLEND | |
  48100. * | 3 | ALPHATESTANDBLEND | |
  48101. *
  48102. */
  48103. transparencyMode: Nullable<number>;
  48104. /**
  48105. * Returns true if alpha blending should be disabled.
  48106. */
  48107. private readonly _disableAlphaBlending;
  48108. /**
  48109. * Specifies whether or not this material should be rendered in alpha blend mode.
  48110. */
  48111. needAlphaBlending(): boolean;
  48112. /**
  48113. * Specifies if the mesh will require alpha blending.
  48114. * @param mesh - BJS mesh.
  48115. */
  48116. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48117. /**
  48118. * Specifies whether or not this material should be rendered in alpha test mode.
  48119. */
  48120. needAlphaTesting(): boolean;
  48121. /**
  48122. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48123. */
  48124. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48125. /**
  48126. * Gets the texture used for the alpha test.
  48127. */
  48128. getAlphaTestTexture(): Nullable<BaseTexture>;
  48129. /**
  48130. * Specifies that the submesh is ready to be used.
  48131. * @param mesh - BJS mesh.
  48132. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48133. * @param useInstances - Specifies that instances should be used.
  48134. * @returns - boolean indicating that the submesh is ready or not.
  48135. */
  48136. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48137. /**
  48138. * Specifies if the material uses metallic roughness workflow.
  48139. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48140. */
  48141. isMetallicWorkflow(): boolean;
  48142. private _prepareEffect;
  48143. private _prepareDefines;
  48144. /**
  48145. * Force shader compilation
  48146. */
  48147. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48148. clipPlane: boolean;
  48149. }>): void;
  48150. /**
  48151. * Initializes the uniform buffer layout for the shader.
  48152. */
  48153. buildUniformLayout(): void;
  48154. /**
  48155. * Unbinds the material from the mesh
  48156. */
  48157. unbind(): void;
  48158. /**
  48159. * Binds the submesh data.
  48160. * @param world - The world matrix.
  48161. * @param mesh - The BJS mesh.
  48162. * @param subMesh - A submesh of the BJS mesh.
  48163. */
  48164. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48165. /**
  48166. * Returns the animatable textures.
  48167. * @returns - Array of animatable textures.
  48168. */
  48169. getAnimatables(): IAnimatable[];
  48170. /**
  48171. * Returns the texture used for reflections.
  48172. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48173. */
  48174. private _getReflectionTexture;
  48175. /**
  48176. * Returns an array of the actively used textures.
  48177. * @returns - Array of BaseTextures
  48178. */
  48179. getActiveTextures(): BaseTexture[];
  48180. /**
  48181. * Checks to see if a texture is used in the material.
  48182. * @param texture - Base texture to use.
  48183. * @returns - Boolean specifying if a texture is used in the material.
  48184. */
  48185. hasTexture(texture: BaseTexture): boolean;
  48186. /**
  48187. * Disposes the resources of the material.
  48188. * @param forceDisposeEffect - Forces the disposal of effects.
  48189. * @param forceDisposeTextures - Forces the disposal of all textures.
  48190. */
  48191. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48192. }
  48193. }
  48194. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48195. import { Nullable } from "babylonjs/types";
  48196. import { Scene } from "babylonjs/scene";
  48197. import { Color3 } from "babylonjs/Maths/math";
  48198. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48199. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48201. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48202. /**
  48203. * The Physically based material of BJS.
  48204. *
  48205. * This offers the main features of a standard PBR material.
  48206. * For more information, please refer to the documentation :
  48207. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48208. */
  48209. export class PBRMaterial extends PBRBaseMaterial {
  48210. /**
  48211. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48212. */
  48213. static readonly PBRMATERIAL_OPAQUE: number;
  48214. /**
  48215. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48216. */
  48217. static readonly PBRMATERIAL_ALPHATEST: number;
  48218. /**
  48219. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48220. */
  48221. static readonly PBRMATERIAL_ALPHABLEND: number;
  48222. /**
  48223. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48224. * They are also discarded below the alpha cutoff threshold to improve performances.
  48225. */
  48226. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48227. /**
  48228. * Defines the default value of how much AO map is occluding the analytical lights
  48229. * (point spot...).
  48230. */
  48231. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48232. /**
  48233. * Intensity of the direct lights e.g. the four lights available in your scene.
  48234. * This impacts both the direct diffuse and specular highlights.
  48235. */
  48236. directIntensity: number;
  48237. /**
  48238. * Intensity of the emissive part of the material.
  48239. * This helps controlling the emissive effect without modifying the emissive color.
  48240. */
  48241. emissiveIntensity: number;
  48242. /**
  48243. * Intensity of the environment e.g. how much the environment will light the object
  48244. * either through harmonics for rough material or through the refelction for shiny ones.
  48245. */
  48246. environmentIntensity: number;
  48247. /**
  48248. * This is a special control allowing the reduction of the specular highlights coming from the
  48249. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48250. */
  48251. specularIntensity: number;
  48252. /**
  48253. * Debug Control allowing disabling the bump map on this material.
  48254. */
  48255. disableBumpMap: boolean;
  48256. /**
  48257. * AKA Diffuse Texture in standard nomenclature.
  48258. */
  48259. albedoTexture: BaseTexture;
  48260. /**
  48261. * AKA Occlusion Texture in other nomenclature.
  48262. */
  48263. ambientTexture: BaseTexture;
  48264. /**
  48265. * AKA Occlusion Texture Intensity in other nomenclature.
  48266. */
  48267. ambientTextureStrength: number;
  48268. /**
  48269. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48270. * 1 means it completely occludes it
  48271. * 0 mean it has no impact
  48272. */
  48273. ambientTextureImpactOnAnalyticalLights: number;
  48274. /**
  48275. * Stores the alpha values in a texture.
  48276. */
  48277. opacityTexture: BaseTexture;
  48278. /**
  48279. * Stores the reflection values in a texture.
  48280. */
  48281. reflectionTexture: Nullable<BaseTexture>;
  48282. /**
  48283. * Stores the emissive values in a texture.
  48284. */
  48285. emissiveTexture: BaseTexture;
  48286. /**
  48287. * AKA Specular texture in other nomenclature.
  48288. */
  48289. reflectivityTexture: BaseTexture;
  48290. /**
  48291. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48292. */
  48293. metallicTexture: BaseTexture;
  48294. /**
  48295. * Specifies the metallic scalar of the metallic/roughness workflow.
  48296. * Can also be used to scale the metalness values of the metallic texture.
  48297. */
  48298. metallic: Nullable<number>;
  48299. /**
  48300. * Specifies the roughness scalar of the metallic/roughness workflow.
  48301. * Can also be used to scale the roughness values of the metallic texture.
  48302. */
  48303. roughness: Nullable<number>;
  48304. /**
  48305. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48306. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48307. */
  48308. microSurfaceTexture: BaseTexture;
  48309. /**
  48310. * Stores surface normal data used to displace a mesh in a texture.
  48311. */
  48312. bumpTexture: BaseTexture;
  48313. /**
  48314. * Stores the pre-calculated light information of a mesh in a texture.
  48315. */
  48316. lightmapTexture: BaseTexture;
  48317. /**
  48318. * Stores the refracted light information in a texture.
  48319. */
  48320. refractionTexture: Nullable<BaseTexture>;
  48321. /**
  48322. * The color of a material in ambient lighting.
  48323. */
  48324. ambientColor: Color3;
  48325. /**
  48326. * AKA Diffuse Color in other nomenclature.
  48327. */
  48328. albedoColor: Color3;
  48329. /**
  48330. * AKA Specular Color in other nomenclature.
  48331. */
  48332. reflectivityColor: Color3;
  48333. /**
  48334. * The color reflected from the material.
  48335. */
  48336. reflectionColor: Color3;
  48337. /**
  48338. * The color emitted from the material.
  48339. */
  48340. emissiveColor: Color3;
  48341. /**
  48342. * AKA Glossiness in other nomenclature.
  48343. */
  48344. microSurface: number;
  48345. /**
  48346. * source material index of refraction (IOR)' / 'destination material IOR.
  48347. */
  48348. indexOfRefraction: number;
  48349. /**
  48350. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48351. */
  48352. invertRefractionY: boolean;
  48353. /**
  48354. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48355. * Materials half opaque for instance using refraction could benefit from this control.
  48356. */
  48357. linkRefractionWithTransparency: boolean;
  48358. /**
  48359. * If true, the light map contains occlusion information instead of lighting info.
  48360. */
  48361. useLightmapAsShadowmap: boolean;
  48362. /**
  48363. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48364. */
  48365. useAlphaFromAlbedoTexture: boolean;
  48366. /**
  48367. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48368. */
  48369. forceAlphaTest: boolean;
  48370. /**
  48371. * Defines the alpha limits in alpha test mode.
  48372. */
  48373. alphaCutOff: number;
  48374. /**
  48375. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48376. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48377. */
  48378. useSpecularOverAlpha: boolean;
  48379. /**
  48380. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48381. */
  48382. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48383. /**
  48384. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48385. */
  48386. useRoughnessFromMetallicTextureAlpha: boolean;
  48387. /**
  48388. * Specifies if the metallic texture contains the roughness information in its green channel.
  48389. */
  48390. useRoughnessFromMetallicTextureGreen: boolean;
  48391. /**
  48392. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48393. */
  48394. useMetallnessFromMetallicTextureBlue: boolean;
  48395. /**
  48396. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48397. */
  48398. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48399. /**
  48400. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48401. */
  48402. useAmbientInGrayScale: boolean;
  48403. /**
  48404. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48405. * The material will try to infer what glossiness each pixel should be.
  48406. */
  48407. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48408. /**
  48409. * BJS is using an harcoded light falloff based on a manually sets up range.
  48410. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48411. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48412. */
  48413. /**
  48414. * BJS is using an harcoded light falloff based on a manually sets up range.
  48415. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48416. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48417. */
  48418. usePhysicalLightFalloff: boolean;
  48419. /**
  48420. * In order to support the falloff compatibility with gltf, a special mode has been added
  48421. * to reproduce the gltf light falloff.
  48422. */
  48423. /**
  48424. * In order to support the falloff compatibility with gltf, a special mode has been added
  48425. * to reproduce the gltf light falloff.
  48426. */
  48427. useGLTFLightFalloff: boolean;
  48428. /**
  48429. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48430. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48431. */
  48432. useRadianceOverAlpha: boolean;
  48433. /**
  48434. * Allows using an object space normal map (instead of tangent space).
  48435. */
  48436. useObjectSpaceNormalMap: boolean;
  48437. /**
  48438. * Allows using the bump map in parallax mode.
  48439. */
  48440. useParallax: boolean;
  48441. /**
  48442. * Allows using the bump map in parallax occlusion mode.
  48443. */
  48444. useParallaxOcclusion: boolean;
  48445. /**
  48446. * Controls the scale bias of the parallax mode.
  48447. */
  48448. parallaxScaleBias: number;
  48449. /**
  48450. * If sets to true, disables all the lights affecting the material.
  48451. */
  48452. disableLighting: boolean;
  48453. /**
  48454. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48455. */
  48456. forceIrradianceInFragment: boolean;
  48457. /**
  48458. * Number of Simultaneous lights allowed on the material.
  48459. */
  48460. maxSimultaneousLights: number;
  48461. /**
  48462. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48463. */
  48464. invertNormalMapX: boolean;
  48465. /**
  48466. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48467. */
  48468. invertNormalMapY: boolean;
  48469. /**
  48470. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48471. */
  48472. twoSidedLighting: boolean;
  48473. /**
  48474. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48475. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48476. */
  48477. useAlphaFresnel: boolean;
  48478. /**
  48479. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48480. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48481. */
  48482. useLinearAlphaFresnel: boolean;
  48483. /**
  48484. * Let user defines the brdf lookup texture used for IBL.
  48485. * A default 8bit version is embedded but you could point at :
  48486. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48487. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48488. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48489. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48490. */
  48491. environmentBRDFTexture: Nullable<BaseTexture>;
  48492. /**
  48493. * Force normal to face away from face.
  48494. */
  48495. forceNormalForward: boolean;
  48496. /**
  48497. * Enables specular anti aliasing in the PBR shader.
  48498. * It will both interacts on the Geometry for analytical and IBL lighting.
  48499. * It also prefilter the roughness map based on the bump values.
  48500. */
  48501. enableSpecularAntiAliasing: boolean;
  48502. /**
  48503. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48504. * makes the reflect vector face the model (under horizon).
  48505. */
  48506. useHorizonOcclusion: boolean;
  48507. /**
  48508. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48509. * too much the area relying on ambient texture to define their ambient occlusion.
  48510. */
  48511. useRadianceOcclusion: boolean;
  48512. /**
  48513. * If set to true, no lighting calculations will be applied.
  48514. */
  48515. unlit: boolean;
  48516. /**
  48517. * Gets the image processing configuration used either in this material.
  48518. */
  48519. /**
  48520. * Sets the Default image processing configuration used either in the this material.
  48521. *
  48522. * If sets to null, the scene one is in use.
  48523. */
  48524. imageProcessingConfiguration: ImageProcessingConfiguration;
  48525. /**
  48526. * Gets wether the color curves effect is enabled.
  48527. */
  48528. /**
  48529. * Sets wether the color curves effect is enabled.
  48530. */
  48531. cameraColorCurvesEnabled: boolean;
  48532. /**
  48533. * Gets wether the color grading effect is enabled.
  48534. */
  48535. /**
  48536. * Gets wether the color grading effect is enabled.
  48537. */
  48538. cameraColorGradingEnabled: boolean;
  48539. /**
  48540. * Gets wether tonemapping is enabled or not.
  48541. */
  48542. /**
  48543. * Sets wether tonemapping is enabled or not
  48544. */
  48545. cameraToneMappingEnabled: boolean;
  48546. /**
  48547. * The camera exposure used on this material.
  48548. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48549. * This corresponds to a photographic exposure.
  48550. */
  48551. /**
  48552. * The camera exposure used on this material.
  48553. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48554. * This corresponds to a photographic exposure.
  48555. */
  48556. cameraExposure: number;
  48557. /**
  48558. * Gets The camera contrast used on this material.
  48559. */
  48560. /**
  48561. * Sets The camera contrast used on this material.
  48562. */
  48563. cameraContrast: number;
  48564. /**
  48565. * Gets the Color Grading 2D Lookup Texture.
  48566. */
  48567. /**
  48568. * Sets the Color Grading 2D Lookup Texture.
  48569. */
  48570. cameraColorGradingTexture: Nullable<BaseTexture>;
  48571. /**
  48572. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48573. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48574. * 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;
  48575. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48576. */
  48577. /**
  48578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48580. * 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;
  48581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48582. */
  48583. cameraColorCurves: Nullable<ColorCurves>;
  48584. /**
  48585. * Instantiates a new PBRMaterial instance.
  48586. *
  48587. * @param name The material name
  48588. * @param scene The scene the material will be use in.
  48589. */
  48590. constructor(name: string, scene: Scene);
  48591. /**
  48592. * Returns the name of this material class.
  48593. */
  48594. getClassName(): string;
  48595. /**
  48596. * Makes a duplicate of the current material.
  48597. * @param name - name to use for the new material.
  48598. */
  48599. clone(name: string): PBRMaterial;
  48600. /**
  48601. * Serializes this PBR Material.
  48602. * @returns - An object with the serialized material.
  48603. */
  48604. serialize(): any;
  48605. /**
  48606. * Parses a PBR Material from a serialized object.
  48607. * @param source - Serialized object.
  48608. * @param scene - BJS scene instance.
  48609. * @param rootUrl - url for the scene object
  48610. * @returns - PBRMaterial
  48611. */
  48612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48613. }
  48614. }
  48615. declare module "babylonjs/Misc/dds" {
  48616. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48617. import { Engine } from "babylonjs/Engines/engine";
  48618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48619. import { Nullable } from "babylonjs/types";
  48620. import { Scene } from "babylonjs/scene";
  48621. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48622. /**
  48623. * Direct draw surface info
  48624. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48625. */
  48626. export interface DDSInfo {
  48627. /**
  48628. * Width of the texture
  48629. */
  48630. width: number;
  48631. /**
  48632. * Width of the texture
  48633. */
  48634. height: number;
  48635. /**
  48636. * Number of Mipmaps for the texture
  48637. * @see https://en.wikipedia.org/wiki/Mipmap
  48638. */
  48639. mipmapCount: number;
  48640. /**
  48641. * If the textures format is a known fourCC format
  48642. * @see https://www.fourcc.org/
  48643. */
  48644. isFourCC: boolean;
  48645. /**
  48646. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48647. */
  48648. isRGB: boolean;
  48649. /**
  48650. * If the texture is a lumincance format
  48651. */
  48652. isLuminance: boolean;
  48653. /**
  48654. * If this is a cube texture
  48655. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48656. */
  48657. isCube: boolean;
  48658. /**
  48659. * If the texture is a compressed format eg. FOURCC_DXT1
  48660. */
  48661. isCompressed: boolean;
  48662. /**
  48663. * The dxgiFormat of the texture
  48664. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48665. */
  48666. dxgiFormat: number;
  48667. /**
  48668. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48669. */
  48670. textureType: number;
  48671. /**
  48672. * Sphericle polynomial created for the dds texture
  48673. */
  48674. sphericalPolynomial?: SphericalPolynomial;
  48675. }
  48676. /**
  48677. * Class used to provide DDS decompression tools
  48678. */
  48679. export class DDSTools {
  48680. /**
  48681. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48682. */
  48683. static StoreLODInAlphaChannel: boolean;
  48684. /**
  48685. * Gets DDS information from an array buffer
  48686. * @param arrayBuffer defines the array buffer to read data from
  48687. * @returns the DDS information
  48688. */
  48689. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48690. private static _FloatView;
  48691. private static _Int32View;
  48692. private static _ToHalfFloat;
  48693. private static _FromHalfFloat;
  48694. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48695. private static _GetHalfFloatRGBAArrayBuffer;
  48696. private static _GetFloatRGBAArrayBuffer;
  48697. private static _GetFloatAsUIntRGBAArrayBuffer;
  48698. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48699. private static _GetRGBAArrayBuffer;
  48700. private static _ExtractLongWordOrder;
  48701. private static _GetRGBArrayBuffer;
  48702. private static _GetLuminanceArrayBuffer;
  48703. /**
  48704. * Uploads DDS Levels to a Babylon Texture
  48705. * @hidden
  48706. */
  48707. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48708. }
  48709. module "babylonjs/Engines/engine" {
  48710. interface Engine {
  48711. /**
  48712. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48713. * @param rootUrl defines the url where the file to load is located
  48714. * @param scene defines the current scene
  48715. * @param lodScale defines scale to apply to the mip map selection
  48716. * @param lodOffset defines offset to apply to the mip map selection
  48717. * @param onLoad defines an optional callback raised when the texture is loaded
  48718. * @param onError defines an optional callback raised if there is an issue to load the texture
  48719. * @param format defines the format of the data
  48720. * @param forcedExtension defines the extension to use to pick the right loader
  48721. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48722. * @returns the cube texture as an InternalTexture
  48723. */
  48724. 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;
  48725. }
  48726. }
  48727. }
  48728. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48729. import { Nullable } from "babylonjs/types";
  48730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48731. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48732. /**
  48733. * Implementation of the DDS Texture Loader.
  48734. * @hidden
  48735. */
  48736. export class _DDSTextureLoader implements IInternalTextureLoader {
  48737. /**
  48738. * Defines wether the loader supports cascade loading the different faces.
  48739. */
  48740. readonly supportCascades: boolean;
  48741. /**
  48742. * This returns if the loader support the current file information.
  48743. * @param extension defines the file extension of the file being loaded
  48744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48745. * @param fallback defines the fallback internal texture if any
  48746. * @param isBase64 defines whether the texture is encoded as a base64
  48747. * @param isBuffer defines whether the texture data are stored as a buffer
  48748. * @returns true if the loader can load the specified file
  48749. */
  48750. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48751. /**
  48752. * Transform the url before loading if required.
  48753. * @param rootUrl the url of the texture
  48754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48755. * @returns the transformed texture
  48756. */
  48757. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48758. /**
  48759. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48760. * @param rootUrl the url of the texture
  48761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48762. * @returns the fallback texture
  48763. */
  48764. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48765. /**
  48766. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48767. * @param data contains the texture data
  48768. * @param texture defines the BabylonJS internal texture
  48769. * @param createPolynomials will be true if polynomials have been requested
  48770. * @param onLoad defines the callback to trigger once the texture is ready
  48771. * @param onError defines the callback to trigger in case of error
  48772. */
  48773. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48774. /**
  48775. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48776. * @param data contains the texture data
  48777. * @param texture defines the BabylonJS internal texture
  48778. * @param callback defines the method to call once ready to upload
  48779. */
  48780. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48781. }
  48782. }
  48783. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48785. /** @hidden */
  48786. export var rgbdEncodePixelShader: {
  48787. name: string;
  48788. shader: string;
  48789. };
  48790. }
  48791. declare module "babylonjs/Misc/environmentTextureTools" {
  48792. import { Nullable } from "babylonjs/types";
  48793. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48795. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48796. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48797. import "babylonjs/Shaders/rgbdEncode.fragment";
  48798. import "babylonjs/Shaders/rgbdDecode.fragment";
  48799. /**
  48800. * Raw texture data and descriptor sufficient for WebGL texture upload
  48801. */
  48802. export interface EnvironmentTextureInfo {
  48803. /**
  48804. * Version of the environment map
  48805. */
  48806. version: number;
  48807. /**
  48808. * Width of image
  48809. */
  48810. width: number;
  48811. /**
  48812. * Irradiance information stored in the file.
  48813. */
  48814. irradiance: any;
  48815. /**
  48816. * Specular information stored in the file.
  48817. */
  48818. specular: any;
  48819. }
  48820. /**
  48821. * Sets of helpers addressing the serialization and deserialization of environment texture
  48822. * stored in a BabylonJS env file.
  48823. * Those files are usually stored as .env files.
  48824. */
  48825. export class EnvironmentTextureTools {
  48826. /**
  48827. * Magic number identifying the env file.
  48828. */
  48829. private static _MagicBytes;
  48830. /**
  48831. * Gets the environment info from an env file.
  48832. * @param data The array buffer containing the .env bytes.
  48833. * @returns the environment file info (the json header) if successfully parsed.
  48834. */
  48835. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48836. /**
  48837. * Creates an environment texture from a loaded cube texture.
  48838. * @param texture defines the cube texture to convert in env file
  48839. * @return a promise containing the environment data if succesfull.
  48840. */
  48841. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48842. /**
  48843. * Creates a JSON representation of the spherical data.
  48844. * @param texture defines the texture containing the polynomials
  48845. * @return the JSON representation of the spherical info
  48846. */
  48847. private static _CreateEnvTextureIrradiance;
  48848. /**
  48849. * Uploads the texture info contained in the env file to the GPU.
  48850. * @param texture defines the internal texture to upload to
  48851. * @param arrayBuffer defines the buffer cotaining the data to load
  48852. * @param info defines the texture info retrieved through the GetEnvInfo method
  48853. * @returns a promise
  48854. */
  48855. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48856. /**
  48857. * Uploads the levels of image data to the GPU.
  48858. * @param texture defines the internal texture to upload to
  48859. * @param imageData defines the array buffer views of image data [mipmap][face]
  48860. * @returns a promise
  48861. */
  48862. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48863. /**
  48864. * Uploads spherical polynomials information to the texture.
  48865. * @param texture defines the texture we are trying to upload the information to
  48866. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48867. */
  48868. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48869. /** @hidden */
  48870. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48871. }
  48872. }
  48873. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48874. import { Nullable } from "babylonjs/types";
  48875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48876. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48877. /**
  48878. * Implementation of the ENV Texture Loader.
  48879. * @hidden
  48880. */
  48881. export class _ENVTextureLoader implements IInternalTextureLoader {
  48882. /**
  48883. * Defines wether the loader supports cascade loading the different faces.
  48884. */
  48885. readonly supportCascades: boolean;
  48886. /**
  48887. * This returns if the loader support the current file information.
  48888. * @param extension defines the file extension of the file being loaded
  48889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48890. * @param fallback defines the fallback internal texture if any
  48891. * @param isBase64 defines whether the texture is encoded as a base64
  48892. * @param isBuffer defines whether the texture data are stored as a buffer
  48893. * @returns true if the loader can load the specified file
  48894. */
  48895. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48896. /**
  48897. * Transform the url before loading if required.
  48898. * @param rootUrl the url of the texture
  48899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48900. * @returns the transformed texture
  48901. */
  48902. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48903. /**
  48904. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48905. * @param rootUrl the url of the texture
  48906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48907. * @returns the fallback texture
  48908. */
  48909. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48910. /**
  48911. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48912. * @param data contains the texture data
  48913. * @param texture defines the BabylonJS internal texture
  48914. * @param createPolynomials will be true if polynomials have been requested
  48915. * @param onLoad defines the callback to trigger once the texture is ready
  48916. * @param onError defines the callback to trigger in case of error
  48917. */
  48918. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48919. /**
  48920. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48921. * @param data contains the texture data
  48922. * @param texture defines the BabylonJS internal texture
  48923. * @param callback defines the method to call once ready to upload
  48924. */
  48925. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48926. }
  48927. }
  48928. declare module "babylonjs/Misc/khronosTextureContainer" {
  48929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48930. /**
  48931. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48932. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48933. */
  48934. export class KhronosTextureContainer {
  48935. /** contents of the KTX container file */
  48936. arrayBuffer: any;
  48937. private static HEADER_LEN;
  48938. private static COMPRESSED_2D;
  48939. private static COMPRESSED_3D;
  48940. private static TEX_2D;
  48941. private static TEX_3D;
  48942. /**
  48943. * Gets the openGL type
  48944. */
  48945. glType: number;
  48946. /**
  48947. * Gets the openGL type size
  48948. */
  48949. glTypeSize: number;
  48950. /**
  48951. * Gets the openGL format
  48952. */
  48953. glFormat: number;
  48954. /**
  48955. * Gets the openGL internal format
  48956. */
  48957. glInternalFormat: number;
  48958. /**
  48959. * Gets the base internal format
  48960. */
  48961. glBaseInternalFormat: number;
  48962. /**
  48963. * Gets image width in pixel
  48964. */
  48965. pixelWidth: number;
  48966. /**
  48967. * Gets image height in pixel
  48968. */
  48969. pixelHeight: number;
  48970. /**
  48971. * Gets image depth in pixels
  48972. */
  48973. pixelDepth: number;
  48974. /**
  48975. * Gets the number of array elements
  48976. */
  48977. numberOfArrayElements: number;
  48978. /**
  48979. * Gets the number of faces
  48980. */
  48981. numberOfFaces: number;
  48982. /**
  48983. * Gets the number of mipmap levels
  48984. */
  48985. numberOfMipmapLevels: number;
  48986. /**
  48987. * Gets the bytes of key value data
  48988. */
  48989. bytesOfKeyValueData: number;
  48990. /**
  48991. * Gets the load type
  48992. */
  48993. loadType: number;
  48994. /**
  48995. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48996. */
  48997. isInvalid: boolean;
  48998. /**
  48999. * Creates a new KhronosTextureContainer
  49000. * @param arrayBuffer contents of the KTX container file
  49001. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49002. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49003. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49004. */
  49005. constructor(
  49006. /** contents of the KTX container file */
  49007. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49008. /**
  49009. * Uploads KTX content to a Babylon Texture.
  49010. * It is assumed that the texture has already been created & is currently bound
  49011. * @hidden
  49012. */
  49013. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49014. private _upload2DCompressedLevels;
  49015. }
  49016. }
  49017. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49018. import { Nullable } from "babylonjs/types";
  49019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49020. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49021. /**
  49022. * Implementation of the KTX Texture Loader.
  49023. * @hidden
  49024. */
  49025. export class _KTXTextureLoader implements IInternalTextureLoader {
  49026. /**
  49027. * Defines wether the loader supports cascade loading the different faces.
  49028. */
  49029. readonly supportCascades: boolean;
  49030. /**
  49031. * This returns if the loader support the current file information.
  49032. * @param extension defines the file extension of the file being loaded
  49033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49034. * @param fallback defines the fallback internal texture if any
  49035. * @param isBase64 defines whether the texture is encoded as a base64
  49036. * @param isBuffer defines whether the texture data are stored as a buffer
  49037. * @returns true if the loader can load the specified file
  49038. */
  49039. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49040. /**
  49041. * Transform the url before loading if required.
  49042. * @param rootUrl the url of the texture
  49043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49044. * @returns the transformed texture
  49045. */
  49046. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49047. /**
  49048. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49049. * @param rootUrl the url of the texture
  49050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49051. * @returns the fallback texture
  49052. */
  49053. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49054. /**
  49055. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49056. * @param data contains the texture data
  49057. * @param texture defines the BabylonJS internal texture
  49058. * @param createPolynomials will be true if polynomials have been requested
  49059. * @param onLoad defines the callback to trigger once the texture is ready
  49060. * @param onError defines the callback to trigger in case of error
  49061. */
  49062. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49063. /**
  49064. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49065. * @param data contains the texture data
  49066. * @param texture defines the BabylonJS internal texture
  49067. * @param callback defines the method to call once ready to upload
  49068. */
  49069. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49070. }
  49071. }
  49072. declare module "babylonjs/Helpers/sceneHelpers" {
  49073. import { Nullable } from "babylonjs/types";
  49074. import { Mesh } from "babylonjs/Meshes/mesh";
  49075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49076. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49077. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49078. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49079. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49080. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49081. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49082. import "babylonjs/Meshes/Builders/boxBuilder";
  49083. /** @hidden */
  49084. export var _forceSceneHelpersToBundle: boolean;
  49085. module "babylonjs/scene" {
  49086. interface Scene {
  49087. /**
  49088. * Creates a default light for the scene.
  49089. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49090. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49091. */
  49092. createDefaultLight(replace?: boolean): void;
  49093. /**
  49094. * Creates a default camera for the scene.
  49095. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49096. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49097. * @param replace has default false, when true replaces the active camera in the scene
  49098. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49099. */
  49100. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49101. /**
  49102. * Creates a default camera and a default light.
  49103. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49104. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49105. * @param replace has the default false, when true replaces the active camera/light in the scene
  49106. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49107. */
  49108. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49109. /**
  49110. * Creates a new sky box
  49111. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49112. * @param environmentTexture defines the texture to use as environment texture
  49113. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49114. * @param scale defines the overall scale of the skybox
  49115. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49116. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49117. * @returns a new mesh holding the sky box
  49118. */
  49119. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49120. /**
  49121. * Creates a new environment
  49122. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49123. * @param options defines the options you can use to configure the environment
  49124. * @returns the new EnvironmentHelper
  49125. */
  49126. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49127. /**
  49128. * Creates a new VREXperienceHelper
  49129. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49130. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49131. * @returns a new VREXperienceHelper
  49132. */
  49133. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49134. /**
  49135. * Creates a new XREXperienceHelper
  49136. * @see http://doc.babylonjs.com/how_to/webxr
  49137. * @returns a promise for a new XREXperienceHelper
  49138. */
  49139. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49140. }
  49141. }
  49142. }
  49143. declare module "babylonjs/Helpers/videoDome" {
  49144. import { Scene } from "babylonjs/scene";
  49145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49146. import { Mesh } from "babylonjs/Meshes/mesh";
  49147. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49148. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49149. import "babylonjs/Meshes/Builders/sphereBuilder";
  49150. /**
  49151. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49152. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49153. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49154. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49155. */
  49156. export class VideoDome extends TransformNode {
  49157. /**
  49158. * Define the video source as a Monoscopic panoramic 360 video.
  49159. */
  49160. static readonly MODE_MONOSCOPIC: number;
  49161. /**
  49162. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49163. */
  49164. static readonly MODE_TOPBOTTOM: number;
  49165. /**
  49166. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49167. */
  49168. static readonly MODE_SIDEBYSIDE: number;
  49169. private _useDirectMapping;
  49170. /**
  49171. * The video texture being displayed on the sphere
  49172. */
  49173. protected _videoTexture: VideoTexture;
  49174. /**
  49175. * Gets the video texture being displayed on the sphere
  49176. */
  49177. readonly videoTexture: VideoTexture;
  49178. /**
  49179. * The skybox material
  49180. */
  49181. protected _material: BackgroundMaterial;
  49182. /**
  49183. * The surface used for the skybox
  49184. */
  49185. protected _mesh: Mesh;
  49186. /**
  49187. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49188. * Also see the options.resolution property.
  49189. */
  49190. fovMultiplier: number;
  49191. private _videoMode;
  49192. /**
  49193. * Gets or set the current video mode for the video. It can be:
  49194. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49195. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49196. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49197. */
  49198. videoMode: number;
  49199. /**
  49200. * Oberserver used in Stereoscopic VR Mode.
  49201. */
  49202. private _onBeforeCameraRenderObserver;
  49203. /**
  49204. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49205. * @param name Element's name, child elements will append suffixes for their own names.
  49206. * @param urlsOrVideo defines the url(s) or the video element to use
  49207. * @param options An object containing optional or exposed sub element properties
  49208. */
  49209. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49210. resolution?: number;
  49211. clickToPlay?: boolean;
  49212. autoPlay?: boolean;
  49213. loop?: boolean;
  49214. size?: number;
  49215. poster?: string;
  49216. faceForward?: boolean;
  49217. useDirectMapping?: boolean;
  49218. }, scene: Scene);
  49219. private _changeVideoMode;
  49220. /**
  49221. * Releases resources associated with this node.
  49222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49224. */
  49225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49226. }
  49227. }
  49228. declare module "babylonjs/Helpers/index" {
  49229. export * from "babylonjs/Helpers/environmentHelper";
  49230. export * from "babylonjs/Helpers/photoDome";
  49231. export * from "babylonjs/Helpers/sceneHelpers";
  49232. export * from "babylonjs/Helpers/videoDome";
  49233. }
  49234. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49235. import { PerfCounter } from "babylonjs/Misc/tools";
  49236. import { IDisposable } from "babylonjs/scene";
  49237. import { Engine } from "babylonjs/Engines/engine";
  49238. /**
  49239. * This class can be used to get instrumentation data from a Babylon engine
  49240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49241. */
  49242. export class EngineInstrumentation implements IDisposable {
  49243. /**
  49244. * Define the instrumented engine.
  49245. */
  49246. engine: Engine;
  49247. private _captureGPUFrameTime;
  49248. private _gpuFrameTimeToken;
  49249. private _gpuFrameTime;
  49250. private _captureShaderCompilationTime;
  49251. private _shaderCompilationTime;
  49252. private _onBeginFrameObserver;
  49253. private _onEndFrameObserver;
  49254. private _onBeforeShaderCompilationObserver;
  49255. private _onAfterShaderCompilationObserver;
  49256. /**
  49257. * Gets the perf counter used for GPU frame time
  49258. */
  49259. readonly gpuFrameTimeCounter: PerfCounter;
  49260. /**
  49261. * Gets the GPU frame time capture status
  49262. */
  49263. /**
  49264. * Enable or disable the GPU frame time capture
  49265. */
  49266. captureGPUFrameTime: boolean;
  49267. /**
  49268. * Gets the perf counter used for shader compilation time
  49269. */
  49270. readonly shaderCompilationTimeCounter: PerfCounter;
  49271. /**
  49272. * Gets the shader compilation time capture status
  49273. */
  49274. /**
  49275. * Enable or disable the shader compilation time capture
  49276. */
  49277. captureShaderCompilationTime: boolean;
  49278. /**
  49279. * Instantiates a new engine instrumentation.
  49280. * This class can be used to get instrumentation data from a Babylon engine
  49281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49282. * @param engine Defines the engine to instrument
  49283. */
  49284. constructor(
  49285. /**
  49286. * Define the instrumented engine.
  49287. */
  49288. engine: Engine);
  49289. /**
  49290. * Dispose and release associated resources.
  49291. */
  49292. dispose(): void;
  49293. }
  49294. }
  49295. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49296. import { PerfCounter } from "babylonjs/Misc/tools";
  49297. import { Scene, IDisposable } from "babylonjs/scene";
  49298. /**
  49299. * This class can be used to get instrumentation data from a Babylon engine
  49300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49301. */
  49302. export class SceneInstrumentation implements IDisposable {
  49303. /**
  49304. * Defines the scene to instrument
  49305. */
  49306. scene: Scene;
  49307. private _captureActiveMeshesEvaluationTime;
  49308. private _activeMeshesEvaluationTime;
  49309. private _captureRenderTargetsRenderTime;
  49310. private _renderTargetsRenderTime;
  49311. private _captureFrameTime;
  49312. private _frameTime;
  49313. private _captureRenderTime;
  49314. private _renderTime;
  49315. private _captureInterFrameTime;
  49316. private _interFrameTime;
  49317. private _captureParticlesRenderTime;
  49318. private _particlesRenderTime;
  49319. private _captureSpritesRenderTime;
  49320. private _spritesRenderTime;
  49321. private _capturePhysicsTime;
  49322. private _physicsTime;
  49323. private _captureAnimationsTime;
  49324. private _animationsTime;
  49325. private _captureCameraRenderTime;
  49326. private _cameraRenderTime;
  49327. private _onBeforeActiveMeshesEvaluationObserver;
  49328. private _onAfterActiveMeshesEvaluationObserver;
  49329. private _onBeforeRenderTargetsRenderObserver;
  49330. private _onAfterRenderTargetsRenderObserver;
  49331. private _onAfterRenderObserver;
  49332. private _onBeforeDrawPhaseObserver;
  49333. private _onAfterDrawPhaseObserver;
  49334. private _onBeforeAnimationsObserver;
  49335. private _onBeforeParticlesRenderingObserver;
  49336. private _onAfterParticlesRenderingObserver;
  49337. private _onBeforeSpritesRenderingObserver;
  49338. private _onAfterSpritesRenderingObserver;
  49339. private _onBeforePhysicsObserver;
  49340. private _onAfterPhysicsObserver;
  49341. private _onAfterAnimationsObserver;
  49342. private _onBeforeCameraRenderObserver;
  49343. private _onAfterCameraRenderObserver;
  49344. /**
  49345. * Gets the perf counter used for active meshes evaluation time
  49346. */
  49347. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49348. /**
  49349. * Gets the active meshes evaluation time capture status
  49350. */
  49351. /**
  49352. * Enable or disable the active meshes evaluation time capture
  49353. */
  49354. captureActiveMeshesEvaluationTime: boolean;
  49355. /**
  49356. * Gets the perf counter used for render targets render time
  49357. */
  49358. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49359. /**
  49360. * Gets the render targets render time capture status
  49361. */
  49362. /**
  49363. * Enable or disable the render targets render time capture
  49364. */
  49365. captureRenderTargetsRenderTime: boolean;
  49366. /**
  49367. * Gets the perf counter used for particles render time
  49368. */
  49369. readonly particlesRenderTimeCounter: PerfCounter;
  49370. /**
  49371. * Gets the particles render time capture status
  49372. */
  49373. /**
  49374. * Enable or disable the particles render time capture
  49375. */
  49376. captureParticlesRenderTime: boolean;
  49377. /**
  49378. * Gets the perf counter used for sprites render time
  49379. */
  49380. readonly spritesRenderTimeCounter: PerfCounter;
  49381. /**
  49382. * Gets the sprites render time capture status
  49383. */
  49384. /**
  49385. * Enable or disable the sprites render time capture
  49386. */
  49387. captureSpritesRenderTime: boolean;
  49388. /**
  49389. * Gets the perf counter used for physics time
  49390. */
  49391. readonly physicsTimeCounter: PerfCounter;
  49392. /**
  49393. * Gets the physics time capture status
  49394. */
  49395. /**
  49396. * Enable or disable the physics time capture
  49397. */
  49398. capturePhysicsTime: boolean;
  49399. /**
  49400. * Gets the perf counter used for animations time
  49401. */
  49402. readonly animationsTimeCounter: PerfCounter;
  49403. /**
  49404. * Gets the animations time capture status
  49405. */
  49406. /**
  49407. * Enable or disable the animations time capture
  49408. */
  49409. captureAnimationsTime: boolean;
  49410. /**
  49411. * Gets the perf counter used for frame time capture
  49412. */
  49413. readonly frameTimeCounter: PerfCounter;
  49414. /**
  49415. * Gets the frame time capture status
  49416. */
  49417. /**
  49418. * Enable or disable the frame time capture
  49419. */
  49420. captureFrameTime: boolean;
  49421. /**
  49422. * Gets the perf counter used for inter-frames time capture
  49423. */
  49424. readonly interFrameTimeCounter: PerfCounter;
  49425. /**
  49426. * Gets the inter-frames time capture status
  49427. */
  49428. /**
  49429. * Enable or disable the inter-frames time capture
  49430. */
  49431. captureInterFrameTime: boolean;
  49432. /**
  49433. * Gets the perf counter used for render time capture
  49434. */
  49435. readonly renderTimeCounter: PerfCounter;
  49436. /**
  49437. * Gets the render time capture status
  49438. */
  49439. /**
  49440. * Enable or disable the render time capture
  49441. */
  49442. captureRenderTime: boolean;
  49443. /**
  49444. * Gets the perf counter used for camera render time capture
  49445. */
  49446. readonly cameraRenderTimeCounter: PerfCounter;
  49447. /**
  49448. * Gets the camera render time capture status
  49449. */
  49450. /**
  49451. * Enable or disable the camera render time capture
  49452. */
  49453. captureCameraRenderTime: boolean;
  49454. /**
  49455. * Gets the perf counter used for draw calls
  49456. */
  49457. readonly drawCallsCounter: PerfCounter;
  49458. /**
  49459. * Instantiates a new scene instrumentation.
  49460. * This class can be used to get instrumentation data from a Babylon engine
  49461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49462. * @param scene Defines the scene to instrument
  49463. */
  49464. constructor(
  49465. /**
  49466. * Defines the scene to instrument
  49467. */
  49468. scene: Scene);
  49469. /**
  49470. * Dispose and release associated resources.
  49471. */
  49472. dispose(): void;
  49473. }
  49474. }
  49475. declare module "babylonjs/Instrumentation/index" {
  49476. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49477. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49478. export * from "babylonjs/Instrumentation/timeToken";
  49479. }
  49480. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49481. /** @hidden */
  49482. export var glowMapGenerationPixelShader: {
  49483. name: string;
  49484. shader: string;
  49485. };
  49486. }
  49487. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49488. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49491. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49493. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49494. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49495. /** @hidden */
  49496. export var glowMapGenerationVertexShader: {
  49497. name: string;
  49498. shader: string;
  49499. };
  49500. }
  49501. declare module "babylonjs/Layers/effectLayer" {
  49502. import { Observable } from "babylonjs/Misc/observable";
  49503. import { Nullable } from "babylonjs/types";
  49504. import { Camera } from "babylonjs/Cameras/camera";
  49505. import { Scene } from "babylonjs/scene";
  49506. import { Color4, ISize } from "babylonjs/Maths/math";
  49507. import { Engine } from "babylonjs/Engines/engine";
  49508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49510. import { Mesh } from "babylonjs/Meshes/mesh";
  49511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49512. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49513. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49514. import { Effect } from "babylonjs/Materials/effect";
  49515. import { Material } from "babylonjs/Materials/material";
  49516. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49517. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49518. /**
  49519. * Effect layer options. This helps customizing the behaviour
  49520. * of the effect layer.
  49521. */
  49522. export interface IEffectLayerOptions {
  49523. /**
  49524. * Multiplication factor apply to the canvas size to compute the render target size
  49525. * used to generated the objects (the smaller the faster).
  49526. */
  49527. mainTextureRatio: number;
  49528. /**
  49529. * Enforces a fixed size texture to ensure effect stability across devices.
  49530. */
  49531. mainTextureFixedSize?: number;
  49532. /**
  49533. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49534. */
  49535. alphaBlendingMode: number;
  49536. /**
  49537. * The camera attached to the layer.
  49538. */
  49539. camera: Nullable<Camera>;
  49540. /**
  49541. * The rendering group to draw the layer in.
  49542. */
  49543. renderingGroupId: number;
  49544. }
  49545. /**
  49546. * The effect layer Helps adding post process effect blended with the main pass.
  49547. *
  49548. * This can be for instance use to generate glow or higlight effects on the scene.
  49549. *
  49550. * The effect layer class can not be used directly and is intented to inherited from to be
  49551. * customized per effects.
  49552. */
  49553. export abstract class EffectLayer {
  49554. private _vertexBuffers;
  49555. private _indexBuffer;
  49556. private _cachedDefines;
  49557. private _effectLayerMapGenerationEffect;
  49558. private _effectLayerOptions;
  49559. private _mergeEffect;
  49560. protected _scene: Scene;
  49561. protected _engine: Engine;
  49562. protected _maxSize: number;
  49563. protected _mainTextureDesiredSize: ISize;
  49564. protected _mainTexture: RenderTargetTexture;
  49565. protected _shouldRender: boolean;
  49566. protected _postProcesses: PostProcess[];
  49567. protected _textures: BaseTexture[];
  49568. protected _emissiveTextureAndColor: {
  49569. texture: Nullable<BaseTexture>;
  49570. color: Color4;
  49571. };
  49572. /**
  49573. * The name of the layer
  49574. */
  49575. name: string;
  49576. /**
  49577. * The clear color of the texture used to generate the glow map.
  49578. */
  49579. neutralColor: Color4;
  49580. /**
  49581. * Specifies wether the highlight layer is enabled or not.
  49582. */
  49583. isEnabled: boolean;
  49584. /**
  49585. * Gets the camera attached to the layer.
  49586. */
  49587. readonly camera: Nullable<Camera>;
  49588. /**
  49589. * Gets the rendering group id the layer should render in.
  49590. */
  49591. renderingGroupId: number;
  49592. /**
  49593. * An event triggered when the effect layer has been disposed.
  49594. */
  49595. onDisposeObservable: Observable<EffectLayer>;
  49596. /**
  49597. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49598. */
  49599. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49600. /**
  49601. * An event triggered when the generated texture is being merged in the scene.
  49602. */
  49603. onBeforeComposeObservable: Observable<EffectLayer>;
  49604. /**
  49605. * An event triggered when the generated texture has been merged in the scene.
  49606. */
  49607. onAfterComposeObservable: Observable<EffectLayer>;
  49608. /**
  49609. * An event triggered when the efffect layer changes its size.
  49610. */
  49611. onSizeChangedObservable: Observable<EffectLayer>;
  49612. /** @hidden */
  49613. static _SceneComponentInitialization: (scene: Scene) => void;
  49614. /**
  49615. * Instantiates a new effect Layer and references it in the scene.
  49616. * @param name The name of the layer
  49617. * @param scene The scene to use the layer in
  49618. */
  49619. constructor(
  49620. /** The Friendly of the effect in the scene */
  49621. name: string, scene: Scene);
  49622. /**
  49623. * Get the effect name of the layer.
  49624. * @return The effect name
  49625. */
  49626. abstract getEffectName(): string;
  49627. /**
  49628. * Checks for the readiness of the element composing the layer.
  49629. * @param subMesh the mesh to check for
  49630. * @param useInstances specify wether or not to use instances to render the mesh
  49631. * @return true if ready otherwise, false
  49632. */
  49633. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49634. /**
  49635. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49636. * @returns true if the effect requires stencil during the main canvas render pass.
  49637. */
  49638. abstract needStencil(): boolean;
  49639. /**
  49640. * Create the merge effect. This is the shader use to blit the information back
  49641. * to the main canvas at the end of the scene rendering.
  49642. * @returns The effect containing the shader used to merge the effect on the main canvas
  49643. */
  49644. protected abstract _createMergeEffect(): Effect;
  49645. /**
  49646. * Creates the render target textures and post processes used in the effect layer.
  49647. */
  49648. protected abstract _createTextureAndPostProcesses(): void;
  49649. /**
  49650. * Implementation specific of rendering the generating effect on the main canvas.
  49651. * @param effect The effect used to render through
  49652. */
  49653. protected abstract _internalRender(effect: Effect): void;
  49654. /**
  49655. * Sets the required values for both the emissive texture and and the main color.
  49656. */
  49657. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49658. /**
  49659. * Free any resources and references associated to a mesh.
  49660. * Internal use
  49661. * @param mesh The mesh to free.
  49662. */
  49663. abstract _disposeMesh(mesh: Mesh): void;
  49664. /**
  49665. * Serializes this layer (Glow or Highlight for example)
  49666. * @returns a serialized layer object
  49667. */
  49668. abstract serialize?(): any;
  49669. /**
  49670. * Initializes the effect layer with the required options.
  49671. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49672. */
  49673. protected _init(options: Partial<IEffectLayerOptions>): void;
  49674. /**
  49675. * Generates the index buffer of the full screen quad blending to the main canvas.
  49676. */
  49677. private _generateIndexBuffer;
  49678. /**
  49679. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49680. */
  49681. private _generateVertexBuffer;
  49682. /**
  49683. * Sets the main texture desired size which is the closest power of two
  49684. * of the engine canvas size.
  49685. */
  49686. private _setMainTextureSize;
  49687. /**
  49688. * Creates the main texture for the effect layer.
  49689. */
  49690. protected _createMainTexture(): void;
  49691. /**
  49692. * Adds specific effects defines.
  49693. * @param defines The defines to add specifics to.
  49694. */
  49695. protected _addCustomEffectDefines(defines: string[]): void;
  49696. /**
  49697. * Checks for the readiness of the element composing the layer.
  49698. * @param subMesh the mesh to check for
  49699. * @param useInstances specify wether or not to use instances to render the mesh
  49700. * @param emissiveTexture the associated emissive texture used to generate the glow
  49701. * @return true if ready otherwise, false
  49702. */
  49703. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49704. /**
  49705. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49706. */
  49707. render(): void;
  49708. /**
  49709. * Determine if a given mesh will be used in the current effect.
  49710. * @param mesh mesh to test
  49711. * @returns true if the mesh will be used
  49712. */
  49713. hasMesh(mesh: AbstractMesh): boolean;
  49714. /**
  49715. * Returns true if the layer contains information to display, otherwise false.
  49716. * @returns true if the glow layer should be rendered
  49717. */
  49718. shouldRender(): boolean;
  49719. /**
  49720. * Returns true if the mesh should render, otherwise false.
  49721. * @param mesh The mesh to render
  49722. * @returns true if it should render otherwise false
  49723. */
  49724. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49725. /**
  49726. * Returns true if the mesh can be rendered, otherwise false.
  49727. * @param mesh The mesh to render
  49728. * @param material The material used on the mesh
  49729. * @returns true if it can be rendered otherwise false
  49730. */
  49731. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49732. /**
  49733. * Returns true if the mesh should render, otherwise false.
  49734. * @param mesh The mesh to render
  49735. * @returns true if it should render otherwise false
  49736. */
  49737. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49738. /**
  49739. * Renders the submesh passed in parameter to the generation map.
  49740. */
  49741. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49742. /**
  49743. * Rebuild the required buffers.
  49744. * @hidden Internal use only.
  49745. */
  49746. _rebuild(): void;
  49747. /**
  49748. * Dispose only the render target textures and post process.
  49749. */
  49750. private _disposeTextureAndPostProcesses;
  49751. /**
  49752. * Dispose the highlight layer and free resources.
  49753. */
  49754. dispose(): void;
  49755. /**
  49756. * Gets the class name of the effect layer
  49757. * @returns the string with the class name of the effect layer
  49758. */
  49759. getClassName(): string;
  49760. /**
  49761. * Creates an effect layer from parsed effect layer data
  49762. * @param parsedEffectLayer defines effect layer data
  49763. * @param scene defines the current scene
  49764. * @param rootUrl defines the root URL containing the effect layer information
  49765. * @returns a parsed effect Layer
  49766. */
  49767. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49768. }
  49769. }
  49770. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49771. import { Scene } from "babylonjs/scene";
  49772. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49773. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49774. import { AbstractScene } from "babylonjs/abstractScene";
  49775. module "babylonjs/abstractScene" {
  49776. interface AbstractScene {
  49777. /**
  49778. * The list of effect layers (highlights/glow) added to the scene
  49779. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49780. * @see http://doc.babylonjs.com/how_to/glow_layer
  49781. */
  49782. effectLayers: Array<EffectLayer>;
  49783. /**
  49784. * Removes the given effect layer from this scene.
  49785. * @param toRemove defines the effect layer to remove
  49786. * @returns the index of the removed effect layer
  49787. */
  49788. removeEffectLayer(toRemove: EffectLayer): number;
  49789. /**
  49790. * Adds the given effect layer to this scene
  49791. * @param newEffectLayer defines the effect layer to add
  49792. */
  49793. addEffectLayer(newEffectLayer: EffectLayer): void;
  49794. }
  49795. }
  49796. /**
  49797. * Defines the layer scene component responsible to manage any effect layers
  49798. * in a given scene.
  49799. */
  49800. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49801. /**
  49802. * The component name helpfull to identify the component in the list of scene components.
  49803. */
  49804. readonly name: string;
  49805. /**
  49806. * The scene the component belongs to.
  49807. */
  49808. scene: Scene;
  49809. private _engine;
  49810. private _renderEffects;
  49811. private _needStencil;
  49812. private _previousStencilState;
  49813. /**
  49814. * Creates a new instance of the component for the given scene
  49815. * @param scene Defines the scene to register the component in
  49816. */
  49817. constructor(scene: Scene);
  49818. /**
  49819. * Registers the component in a given scene
  49820. */
  49821. register(): void;
  49822. /**
  49823. * Rebuilds the elements related to this component in case of
  49824. * context lost for instance.
  49825. */
  49826. rebuild(): void;
  49827. /**
  49828. * Serializes the component data to the specified json object
  49829. * @param serializationObject The object to serialize to
  49830. */
  49831. serialize(serializationObject: any): void;
  49832. /**
  49833. * Adds all the elements from the container to the scene
  49834. * @param container the container holding the elements
  49835. */
  49836. addFromContainer(container: AbstractScene): void;
  49837. /**
  49838. * Removes all the elements in the container from the scene
  49839. * @param container contains the elements to remove
  49840. * @param dispose if the removed element should be disposed (default: false)
  49841. */
  49842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49843. /**
  49844. * Disposes the component and the associated ressources.
  49845. */
  49846. dispose(): void;
  49847. private _isReadyForMesh;
  49848. private _renderMainTexture;
  49849. private _setStencil;
  49850. private _setStencilBack;
  49851. private _draw;
  49852. private _drawCamera;
  49853. private _drawRenderingGroup;
  49854. }
  49855. }
  49856. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49857. /** @hidden */
  49858. export var glowMapMergePixelShader: {
  49859. name: string;
  49860. shader: string;
  49861. };
  49862. }
  49863. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49864. /** @hidden */
  49865. export var glowMapMergeVertexShader: {
  49866. name: string;
  49867. shader: string;
  49868. };
  49869. }
  49870. declare module "babylonjs/Layers/glowLayer" {
  49871. import { Nullable } from "babylonjs/types";
  49872. import { Camera } from "babylonjs/Cameras/camera";
  49873. import { Scene } from "babylonjs/scene";
  49874. import { Color4 } from "babylonjs/Maths/math";
  49875. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49877. import { Mesh } from "babylonjs/Meshes/mesh";
  49878. import { Texture } from "babylonjs/Materials/Textures/texture";
  49879. import { Effect } from "babylonjs/Materials/effect";
  49880. import { Material } from "babylonjs/Materials/material";
  49881. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49882. import "babylonjs/Shaders/glowMapMerge.fragment";
  49883. import "babylonjs/Shaders/glowMapMerge.vertex";
  49884. import "babylonjs/Layers/effectLayerSceneComponent";
  49885. module "babylonjs/abstractScene" {
  49886. interface AbstractScene {
  49887. /**
  49888. * Return a the first highlight layer of the scene with a given name.
  49889. * @param name The name of the highlight layer to look for.
  49890. * @return The highlight layer if found otherwise null.
  49891. */
  49892. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49893. }
  49894. }
  49895. /**
  49896. * Glow layer options. This helps customizing the behaviour
  49897. * of the glow layer.
  49898. */
  49899. export interface IGlowLayerOptions {
  49900. /**
  49901. * Multiplication factor apply to the canvas size to compute the render target size
  49902. * used to generated the glowing objects (the smaller the faster).
  49903. */
  49904. mainTextureRatio: number;
  49905. /**
  49906. * Enforces a fixed size texture to ensure resize independant blur.
  49907. */
  49908. mainTextureFixedSize?: number;
  49909. /**
  49910. * How big is the kernel of the blur texture.
  49911. */
  49912. blurKernelSize: number;
  49913. /**
  49914. * The camera attached to the layer.
  49915. */
  49916. camera: Nullable<Camera>;
  49917. /**
  49918. * Enable MSAA by chosing the number of samples.
  49919. */
  49920. mainTextureSamples?: number;
  49921. /**
  49922. * The rendering group to draw the layer in.
  49923. */
  49924. renderingGroupId: number;
  49925. }
  49926. /**
  49927. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49928. *
  49929. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49930. * glowy meshes to your scene.
  49931. *
  49932. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49933. */
  49934. export class GlowLayer extends EffectLayer {
  49935. /**
  49936. * Effect Name of the layer.
  49937. */
  49938. static readonly EffectName: string;
  49939. /**
  49940. * The default blur kernel size used for the glow.
  49941. */
  49942. static DefaultBlurKernelSize: number;
  49943. /**
  49944. * The default texture size ratio used for the glow.
  49945. */
  49946. static DefaultTextureRatio: number;
  49947. /**
  49948. * Sets the kernel size of the blur.
  49949. */
  49950. /**
  49951. * Gets the kernel size of the blur.
  49952. */
  49953. blurKernelSize: number;
  49954. /**
  49955. * Sets the glow intensity.
  49956. */
  49957. /**
  49958. * Gets the glow intensity.
  49959. */
  49960. intensity: number;
  49961. private _options;
  49962. private _intensity;
  49963. private _horizontalBlurPostprocess1;
  49964. private _verticalBlurPostprocess1;
  49965. private _horizontalBlurPostprocess2;
  49966. private _verticalBlurPostprocess2;
  49967. private _blurTexture1;
  49968. private _blurTexture2;
  49969. private _postProcesses1;
  49970. private _postProcesses2;
  49971. private _includedOnlyMeshes;
  49972. private _excludedMeshes;
  49973. /**
  49974. * Callback used to let the user override the color selection on a per mesh basis
  49975. */
  49976. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49977. /**
  49978. * Callback used to let the user override the texture selection on a per mesh basis
  49979. */
  49980. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49981. /**
  49982. * Instantiates a new glow Layer and references it to the scene.
  49983. * @param name The name of the layer
  49984. * @param scene The scene to use the layer in
  49985. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49986. */
  49987. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49988. /**
  49989. * Get the effect name of the layer.
  49990. * @return The effect name
  49991. */
  49992. getEffectName(): string;
  49993. /**
  49994. * Create the merge effect. This is the shader use to blit the information back
  49995. * to the main canvas at the end of the scene rendering.
  49996. */
  49997. protected _createMergeEffect(): Effect;
  49998. /**
  49999. * Creates the render target textures and post processes used in the glow layer.
  50000. */
  50001. protected _createTextureAndPostProcesses(): void;
  50002. /**
  50003. * Checks for the readiness of the element composing the layer.
  50004. * @param subMesh the mesh to check for
  50005. * @param useInstances specify wether or not to use instances to render the mesh
  50006. * @param emissiveTexture the associated emissive texture used to generate the glow
  50007. * @return true if ready otherwise, false
  50008. */
  50009. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50010. /**
  50011. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50012. */
  50013. needStencil(): boolean;
  50014. /**
  50015. * Returns true if the mesh can be rendered, otherwise false.
  50016. * @param mesh The mesh to render
  50017. * @param material The material used on the mesh
  50018. * @returns true if it can be rendered otherwise false
  50019. */
  50020. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50021. /**
  50022. * Implementation specific of rendering the generating effect on the main canvas.
  50023. * @param effect The effect used to render through
  50024. */
  50025. protected _internalRender(effect: Effect): void;
  50026. /**
  50027. * Sets the required values for both the emissive texture and and the main color.
  50028. */
  50029. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50030. /**
  50031. * Returns true if the mesh should render, otherwise false.
  50032. * @param mesh The mesh to render
  50033. * @returns true if it should render otherwise false
  50034. */
  50035. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50036. /**
  50037. * Adds specific effects defines.
  50038. * @param defines The defines to add specifics to.
  50039. */
  50040. protected _addCustomEffectDefines(defines: string[]): void;
  50041. /**
  50042. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50043. * @param mesh The mesh to exclude from the glow layer
  50044. */
  50045. addExcludedMesh(mesh: Mesh): void;
  50046. /**
  50047. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50048. * @param mesh The mesh to remove
  50049. */
  50050. removeExcludedMesh(mesh: Mesh): void;
  50051. /**
  50052. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50053. * @param mesh The mesh to include in the glow layer
  50054. */
  50055. addIncludedOnlyMesh(mesh: Mesh): void;
  50056. /**
  50057. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50058. * @param mesh The mesh to remove
  50059. */
  50060. removeIncludedOnlyMesh(mesh: Mesh): void;
  50061. /**
  50062. * Determine if a given mesh will be used in the glow layer
  50063. * @param mesh The mesh to test
  50064. * @returns true if the mesh will be highlighted by the current glow layer
  50065. */
  50066. hasMesh(mesh: AbstractMesh): boolean;
  50067. /**
  50068. * Free any resources and references associated to a mesh.
  50069. * Internal use
  50070. * @param mesh The mesh to free.
  50071. * @hidden
  50072. */
  50073. _disposeMesh(mesh: Mesh): void;
  50074. /**
  50075. * Gets the class name of the effect layer
  50076. * @returns the string with the class name of the effect layer
  50077. */
  50078. getClassName(): string;
  50079. /**
  50080. * Serializes this glow layer
  50081. * @returns a serialized glow layer object
  50082. */
  50083. serialize(): any;
  50084. /**
  50085. * Creates a Glow Layer from parsed glow layer data
  50086. * @param parsedGlowLayer defines glow layer data
  50087. * @param scene defines the current scene
  50088. * @param rootUrl defines the root URL containing the glow layer information
  50089. * @returns a parsed Glow Layer
  50090. */
  50091. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50092. }
  50093. }
  50094. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50095. /** @hidden */
  50096. export var glowBlurPostProcessPixelShader: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module "babylonjs/Layers/highlightLayer" {
  50102. import { Observable } from "babylonjs/Misc/observable";
  50103. import { Nullable } from "babylonjs/types";
  50104. import { Camera } from "babylonjs/Cameras/camera";
  50105. import { Scene } from "babylonjs/scene";
  50106. import { Color3, Color4 } from "babylonjs/Maths/math";
  50107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50109. import { Mesh } from "babylonjs/Meshes/mesh";
  50110. import { Effect } from "babylonjs/Materials/effect";
  50111. import { Material } from "babylonjs/Materials/material";
  50112. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50113. import "babylonjs/Shaders/glowMapMerge.fragment";
  50114. import "babylonjs/Shaders/glowMapMerge.vertex";
  50115. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50116. module "babylonjs/abstractScene" {
  50117. interface AbstractScene {
  50118. /**
  50119. * Return a the first highlight layer of the scene with a given name.
  50120. * @param name The name of the highlight layer to look for.
  50121. * @return The highlight layer if found otherwise null.
  50122. */
  50123. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50124. }
  50125. }
  50126. /**
  50127. * Highlight layer options. This helps customizing the behaviour
  50128. * of the highlight layer.
  50129. */
  50130. export interface IHighlightLayerOptions {
  50131. /**
  50132. * Multiplication factor apply to the canvas size to compute the render target size
  50133. * used to generated the glowing objects (the smaller the faster).
  50134. */
  50135. mainTextureRatio: number;
  50136. /**
  50137. * Enforces a fixed size texture to ensure resize independant blur.
  50138. */
  50139. mainTextureFixedSize?: number;
  50140. /**
  50141. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50142. * of the picture to blur (the smaller the faster).
  50143. */
  50144. blurTextureSizeRatio: number;
  50145. /**
  50146. * How big in texel of the blur texture is the vertical blur.
  50147. */
  50148. blurVerticalSize: number;
  50149. /**
  50150. * How big in texel of the blur texture is the horizontal blur.
  50151. */
  50152. blurHorizontalSize: number;
  50153. /**
  50154. * Alpha blending mode used to apply the blur. Default is combine.
  50155. */
  50156. alphaBlendingMode: number;
  50157. /**
  50158. * The camera attached to the layer.
  50159. */
  50160. camera: Nullable<Camera>;
  50161. /**
  50162. * Should we display highlight as a solid stroke?
  50163. */
  50164. isStroke?: boolean;
  50165. /**
  50166. * The rendering group to draw the layer in.
  50167. */
  50168. renderingGroupId: number;
  50169. }
  50170. /**
  50171. * The highlight layer Helps adding a glow effect around a mesh.
  50172. *
  50173. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50174. * glowy meshes to your scene.
  50175. *
  50176. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50177. */
  50178. export class HighlightLayer extends EffectLayer {
  50179. name: string;
  50180. /**
  50181. * Effect Name of the highlight layer.
  50182. */
  50183. static readonly EffectName: string;
  50184. /**
  50185. * The neutral color used during the preparation of the glow effect.
  50186. * This is black by default as the blend operation is a blend operation.
  50187. */
  50188. static NeutralColor: Color4;
  50189. /**
  50190. * Stencil value used for glowing meshes.
  50191. */
  50192. static GlowingMeshStencilReference: number;
  50193. /**
  50194. * Stencil value used for the other meshes in the scene.
  50195. */
  50196. static NormalMeshStencilReference: number;
  50197. /**
  50198. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50199. */
  50200. innerGlow: boolean;
  50201. /**
  50202. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50203. */
  50204. outerGlow: boolean;
  50205. /**
  50206. * Specifies the horizontal size of the blur.
  50207. */
  50208. /**
  50209. * Gets the horizontal size of the blur.
  50210. */
  50211. blurHorizontalSize: number;
  50212. /**
  50213. * Specifies the vertical size of the blur.
  50214. */
  50215. /**
  50216. * Gets the vertical size of the blur.
  50217. */
  50218. blurVerticalSize: number;
  50219. /**
  50220. * An event triggered when the highlight layer is being blurred.
  50221. */
  50222. onBeforeBlurObservable: Observable<HighlightLayer>;
  50223. /**
  50224. * An event triggered when the highlight layer has been blurred.
  50225. */
  50226. onAfterBlurObservable: Observable<HighlightLayer>;
  50227. private _instanceGlowingMeshStencilReference;
  50228. private _options;
  50229. private _downSamplePostprocess;
  50230. private _horizontalBlurPostprocess;
  50231. private _verticalBlurPostprocess;
  50232. private _blurTexture;
  50233. private _meshes;
  50234. private _excludedMeshes;
  50235. /**
  50236. * Instantiates a new highlight Layer and references it to the scene..
  50237. * @param name The name of the layer
  50238. * @param scene The scene to use the layer in
  50239. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50240. */
  50241. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50242. /**
  50243. * Get the effect name of the layer.
  50244. * @return The effect name
  50245. */
  50246. getEffectName(): string;
  50247. /**
  50248. * Create the merge effect. This is the shader use to blit the information back
  50249. * to the main canvas at the end of the scene rendering.
  50250. */
  50251. protected _createMergeEffect(): Effect;
  50252. /**
  50253. * Creates the render target textures and post processes used in the highlight layer.
  50254. */
  50255. protected _createTextureAndPostProcesses(): void;
  50256. /**
  50257. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50258. */
  50259. needStencil(): boolean;
  50260. /**
  50261. * Checks for the readiness of the element composing the layer.
  50262. * @param subMesh the mesh to check for
  50263. * @param useInstances specify wether or not to use instances to render the mesh
  50264. * @param emissiveTexture the associated emissive texture used to generate the glow
  50265. * @return true if ready otherwise, false
  50266. */
  50267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50268. /**
  50269. * Implementation specific of rendering the generating effect on the main canvas.
  50270. * @param effect The effect used to render through
  50271. */
  50272. protected _internalRender(effect: Effect): void;
  50273. /**
  50274. * Returns true if the layer contains information to display, otherwise false.
  50275. */
  50276. shouldRender(): boolean;
  50277. /**
  50278. * Returns true if the mesh should render, otherwise false.
  50279. * @param mesh The mesh to render
  50280. * @returns true if it should render otherwise false
  50281. */
  50282. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50283. /**
  50284. * Sets the required values for both the emissive texture and and the main color.
  50285. */
  50286. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50287. /**
  50288. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50289. * @param mesh The mesh to exclude from the highlight layer
  50290. */
  50291. addExcludedMesh(mesh: Mesh): void;
  50292. /**
  50293. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50294. * @param mesh The mesh to highlight
  50295. */
  50296. removeExcludedMesh(mesh: Mesh): void;
  50297. /**
  50298. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50299. * @param mesh mesh to test
  50300. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50301. */
  50302. hasMesh(mesh: AbstractMesh): boolean;
  50303. /**
  50304. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50305. * @param mesh The mesh to highlight
  50306. * @param color The color of the highlight
  50307. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50308. */
  50309. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50310. /**
  50311. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50312. * @param mesh The mesh to highlight
  50313. */
  50314. removeMesh(mesh: Mesh): void;
  50315. /**
  50316. * Force the stencil to the normal expected value for none glowing parts
  50317. */
  50318. private _defaultStencilReference;
  50319. /**
  50320. * Free any resources and references associated to a mesh.
  50321. * Internal use
  50322. * @param mesh The mesh to free.
  50323. * @hidden
  50324. */
  50325. _disposeMesh(mesh: Mesh): void;
  50326. /**
  50327. * Dispose the highlight layer and free resources.
  50328. */
  50329. dispose(): void;
  50330. /**
  50331. * Gets the class name of the effect layer
  50332. * @returns the string with the class name of the effect layer
  50333. */
  50334. getClassName(): string;
  50335. /**
  50336. * Serializes this Highlight layer
  50337. * @returns a serialized Highlight layer object
  50338. */
  50339. serialize(): any;
  50340. /**
  50341. * Creates a Highlight layer from parsed Highlight layer data
  50342. * @param parsedHightlightLayer defines the Highlight layer data
  50343. * @param scene defines the current scene
  50344. * @param rootUrl defines the root URL containing the Highlight layer information
  50345. * @returns a parsed Highlight layer
  50346. */
  50347. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50348. }
  50349. }
  50350. declare module "babylonjs/Layers/layerSceneComponent" {
  50351. import { Scene } from "babylonjs/scene";
  50352. import { ISceneComponent } from "babylonjs/sceneComponent";
  50353. import { Layer } from "babylonjs/Layers/layer";
  50354. import { AbstractScene } from "babylonjs/abstractScene";
  50355. module "babylonjs/abstractScene" {
  50356. interface AbstractScene {
  50357. /**
  50358. * The list of layers (background and foreground) of the scene
  50359. */
  50360. layers: Array<Layer>;
  50361. }
  50362. }
  50363. /**
  50364. * Defines the layer scene component responsible to manage any layers
  50365. * in a given scene.
  50366. */
  50367. export class LayerSceneComponent implements ISceneComponent {
  50368. /**
  50369. * The component name helpfull to identify the component in the list of scene components.
  50370. */
  50371. readonly name: string;
  50372. /**
  50373. * The scene the component belongs to.
  50374. */
  50375. scene: Scene;
  50376. private _engine;
  50377. /**
  50378. * Creates a new instance of the component for the given scene
  50379. * @param scene Defines the scene to register the component in
  50380. */
  50381. constructor(scene: Scene);
  50382. /**
  50383. * Registers the component in a given scene
  50384. */
  50385. register(): void;
  50386. /**
  50387. * Rebuilds the elements related to this component in case of
  50388. * context lost for instance.
  50389. */
  50390. rebuild(): void;
  50391. /**
  50392. * Disposes the component and the associated ressources.
  50393. */
  50394. dispose(): void;
  50395. private _draw;
  50396. private _drawCameraPredicate;
  50397. private _drawCameraBackground;
  50398. private _drawCameraForeground;
  50399. private _drawRenderTargetPredicate;
  50400. private _drawRenderTargetBackground;
  50401. private _drawRenderTargetForeground;
  50402. /**
  50403. * Adds all the elements from the container to the scene
  50404. * @param container the container holding the elements
  50405. */
  50406. addFromContainer(container: AbstractScene): void;
  50407. /**
  50408. * Removes all the elements in the container from the scene
  50409. * @param container contains the elements to remove
  50410. * @param dispose if the removed element should be disposed (default: false)
  50411. */
  50412. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50413. }
  50414. }
  50415. declare module "babylonjs/Shaders/layer.fragment" {
  50416. /** @hidden */
  50417. export var layerPixelShader: {
  50418. name: string;
  50419. shader: string;
  50420. };
  50421. }
  50422. declare module "babylonjs/Shaders/layer.vertex" {
  50423. /** @hidden */
  50424. export var layerVertexShader: {
  50425. name: string;
  50426. shader: string;
  50427. };
  50428. }
  50429. declare module "babylonjs/Layers/layer" {
  50430. import { Observable } from "babylonjs/Misc/observable";
  50431. import { Nullable } from "babylonjs/types";
  50432. import { Scene } from "babylonjs/scene";
  50433. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50434. import { Texture } from "babylonjs/Materials/Textures/texture";
  50435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50436. import "babylonjs/Shaders/layer.fragment";
  50437. import "babylonjs/Shaders/layer.vertex";
  50438. /**
  50439. * This represents a full screen 2d layer.
  50440. * This can be useful to display a picture in the background of your scene for instance.
  50441. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50442. */
  50443. export class Layer {
  50444. /**
  50445. * Define the name of the layer.
  50446. */
  50447. name: string;
  50448. /**
  50449. * Define the texture the layer should display.
  50450. */
  50451. texture: Nullable<Texture>;
  50452. /**
  50453. * Is the layer in background or foreground.
  50454. */
  50455. isBackground: boolean;
  50456. /**
  50457. * Define the color of the layer (instead of texture).
  50458. */
  50459. color: Color4;
  50460. /**
  50461. * Define the scale of the layer in order to zoom in out of the texture.
  50462. */
  50463. scale: Vector2;
  50464. /**
  50465. * Define an offset for the layer in order to shift the texture.
  50466. */
  50467. offset: Vector2;
  50468. /**
  50469. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50470. */
  50471. alphaBlendingMode: number;
  50472. /**
  50473. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50474. * Alpha test will not mix with the background color in case of transparency.
  50475. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50476. */
  50477. alphaTest: boolean;
  50478. /**
  50479. * Define a mask to restrict the layer to only some of the scene cameras.
  50480. */
  50481. layerMask: number;
  50482. /**
  50483. * Define the list of render target the layer is visible into.
  50484. */
  50485. renderTargetTextures: RenderTargetTexture[];
  50486. /**
  50487. * Define if the layer is only used in renderTarget or if it also
  50488. * renders in the main frame buffer of the canvas.
  50489. */
  50490. renderOnlyInRenderTargetTextures: boolean;
  50491. private _scene;
  50492. private _vertexBuffers;
  50493. private _indexBuffer;
  50494. private _effect;
  50495. private _alphaTestEffect;
  50496. /**
  50497. * An event triggered when the layer is disposed.
  50498. */
  50499. onDisposeObservable: Observable<Layer>;
  50500. private _onDisposeObserver;
  50501. /**
  50502. * Back compatibility with callback before the onDisposeObservable existed.
  50503. * The set callback will be triggered when the layer has been disposed.
  50504. */
  50505. onDispose: () => void;
  50506. /**
  50507. * An event triggered before rendering the scene
  50508. */
  50509. onBeforeRenderObservable: Observable<Layer>;
  50510. private _onBeforeRenderObserver;
  50511. /**
  50512. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50513. * The set callback will be triggered just before rendering the layer.
  50514. */
  50515. onBeforeRender: () => void;
  50516. /**
  50517. * An event triggered after rendering the scene
  50518. */
  50519. onAfterRenderObservable: Observable<Layer>;
  50520. private _onAfterRenderObserver;
  50521. /**
  50522. * Back compatibility with callback before the onAfterRenderObservable existed.
  50523. * The set callback will be triggered just after rendering the layer.
  50524. */
  50525. onAfterRender: () => void;
  50526. /**
  50527. * Instantiates a new layer.
  50528. * This represents a full screen 2d layer.
  50529. * This can be useful to display a picture in the background of your scene for instance.
  50530. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50531. * @param name Define the name of the layer in the scene
  50532. * @param imgUrl Define the url of the texture to display in the layer
  50533. * @param scene Define the scene the layer belongs to
  50534. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50535. * @param color Defines a color for the layer
  50536. */
  50537. constructor(
  50538. /**
  50539. * Define the name of the layer.
  50540. */
  50541. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50542. private _createIndexBuffer;
  50543. /** @hidden */
  50544. _rebuild(): void;
  50545. /**
  50546. * Renders the layer in the scene.
  50547. */
  50548. render(): void;
  50549. /**
  50550. * Disposes and releases the associated ressources.
  50551. */
  50552. dispose(): void;
  50553. }
  50554. }
  50555. declare module "babylonjs/Layers/index" {
  50556. export * from "babylonjs/Layers/effectLayer";
  50557. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50558. export * from "babylonjs/Layers/glowLayer";
  50559. export * from "babylonjs/Layers/highlightLayer";
  50560. export * from "babylonjs/Layers/layer";
  50561. export * from "babylonjs/Layers/layerSceneComponent";
  50562. }
  50563. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50564. /** @hidden */
  50565. export var lensFlarePixelShader: {
  50566. name: string;
  50567. shader: string;
  50568. };
  50569. }
  50570. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50571. /** @hidden */
  50572. export var lensFlareVertexShader: {
  50573. name: string;
  50574. shader: string;
  50575. };
  50576. }
  50577. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50578. import { Scene } from "babylonjs/scene";
  50579. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50581. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50582. import "babylonjs/Shaders/lensFlare.fragment";
  50583. import "babylonjs/Shaders/lensFlare.vertex";
  50584. /**
  50585. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50586. * It is usually composed of several `lensFlare`.
  50587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50588. */
  50589. export class LensFlareSystem {
  50590. /**
  50591. * Define the name of the lens flare system
  50592. */
  50593. name: string;
  50594. /**
  50595. * List of lens flares used in this system.
  50596. */
  50597. lensFlares: LensFlare[];
  50598. /**
  50599. * Define a limit from the border the lens flare can be visible.
  50600. */
  50601. borderLimit: number;
  50602. /**
  50603. * Define a viewport border we do not want to see the lens flare in.
  50604. */
  50605. viewportBorder: number;
  50606. /**
  50607. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50608. */
  50609. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50610. /**
  50611. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50612. */
  50613. layerMask: number;
  50614. /**
  50615. * Define the id of the lens flare system in the scene.
  50616. * (equal to name by default)
  50617. */
  50618. id: string;
  50619. private _scene;
  50620. private _emitter;
  50621. private _vertexBuffers;
  50622. private _indexBuffer;
  50623. private _effect;
  50624. private _positionX;
  50625. private _positionY;
  50626. private _isEnabled;
  50627. /** @hidden */
  50628. static _SceneComponentInitialization: (scene: Scene) => void;
  50629. /**
  50630. * Instantiates a lens flare system.
  50631. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50632. * It is usually composed of several `lensFlare`.
  50633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50634. * @param name Define the name of the lens flare system in the scene
  50635. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50636. * @param scene Define the scene the lens flare system belongs to
  50637. */
  50638. constructor(
  50639. /**
  50640. * Define the name of the lens flare system
  50641. */
  50642. name: string, emitter: any, scene: Scene);
  50643. /**
  50644. * Define if the lens flare system is enabled.
  50645. */
  50646. isEnabled: boolean;
  50647. /**
  50648. * Get the scene the effects belongs to.
  50649. * @returns the scene holding the lens flare system
  50650. */
  50651. getScene(): Scene;
  50652. /**
  50653. * Get the emitter of the lens flare system.
  50654. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50655. * @returns the emitter of the lens flare system
  50656. */
  50657. getEmitter(): any;
  50658. /**
  50659. * Set the emitter of the lens flare system.
  50660. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50661. * @param newEmitter Define the new emitter of the system
  50662. */
  50663. setEmitter(newEmitter: any): void;
  50664. /**
  50665. * Get the lens flare system emitter position.
  50666. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50667. * @returns the position
  50668. */
  50669. getEmitterPosition(): Vector3;
  50670. /**
  50671. * @hidden
  50672. */
  50673. computeEffectivePosition(globalViewport: Viewport): boolean;
  50674. /** @hidden */
  50675. _isVisible(): boolean;
  50676. /**
  50677. * @hidden
  50678. */
  50679. render(): boolean;
  50680. /**
  50681. * Dispose and release the lens flare with its associated resources.
  50682. */
  50683. dispose(): void;
  50684. /**
  50685. * Parse a lens flare system from a JSON repressentation
  50686. * @param parsedLensFlareSystem Define the JSON to parse
  50687. * @param scene Define the scene the parsed system should be instantiated in
  50688. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50689. * @returns the parsed system
  50690. */
  50691. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50692. /**
  50693. * Serialize the current Lens Flare System into a JSON representation.
  50694. * @returns the serialized JSON
  50695. */
  50696. serialize(): any;
  50697. }
  50698. }
  50699. declare module "babylonjs/LensFlares/lensFlare" {
  50700. import { Nullable } from "babylonjs/types";
  50701. import { Color3 } from "babylonjs/Maths/math";
  50702. import { Texture } from "babylonjs/Materials/Textures/texture";
  50703. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50704. /**
  50705. * This represents one of the lens effect in a `lensFlareSystem`.
  50706. * It controls one of the indiviual texture used in the effect.
  50707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50708. */
  50709. export class LensFlare {
  50710. /**
  50711. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50712. */
  50713. size: number;
  50714. /**
  50715. * 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.
  50716. */
  50717. position: number;
  50718. /**
  50719. * Define the lens color.
  50720. */
  50721. color: Color3;
  50722. /**
  50723. * Define the lens texture.
  50724. */
  50725. texture: Nullable<Texture>;
  50726. /**
  50727. * Define the alpha mode to render this particular lens.
  50728. */
  50729. alphaMode: number;
  50730. private _system;
  50731. /**
  50732. * Creates a new Lens Flare.
  50733. * This represents one of the lens effect in a `lensFlareSystem`.
  50734. * It controls one of the indiviual texture used in the effect.
  50735. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50736. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50737. * @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.
  50738. * @param color Define the lens color
  50739. * @param imgUrl Define the lens texture url
  50740. * @param system Define the `lensFlareSystem` this flare is part of
  50741. * @returns The newly created Lens Flare
  50742. */
  50743. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50744. /**
  50745. * Instantiates a new Lens Flare.
  50746. * This represents one of the lens effect in a `lensFlareSystem`.
  50747. * It controls one of the indiviual texture used in the effect.
  50748. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50749. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50750. * @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.
  50751. * @param color Define the lens color
  50752. * @param imgUrl Define the lens texture url
  50753. * @param system Define the `lensFlareSystem` this flare is part of
  50754. */
  50755. constructor(
  50756. /**
  50757. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50758. */
  50759. size: number,
  50760. /**
  50761. * 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.
  50762. */
  50763. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50764. /**
  50765. * Dispose and release the lens flare with its associated resources.
  50766. */
  50767. dispose(): void;
  50768. }
  50769. }
  50770. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50771. import { Nullable } from "babylonjs/types";
  50772. import { Scene } from "babylonjs/scene";
  50773. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50774. import { AbstractScene } from "babylonjs/abstractScene";
  50775. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50776. module "babylonjs/abstractScene" {
  50777. interface AbstractScene {
  50778. /**
  50779. * The list of lens flare system added to the scene
  50780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50781. */
  50782. lensFlareSystems: Array<LensFlareSystem>;
  50783. /**
  50784. * Removes the given lens flare system from this scene.
  50785. * @param toRemove The lens flare system to remove
  50786. * @returns The index of the removed lens flare system
  50787. */
  50788. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50789. /**
  50790. * Adds the given lens flare system to this scene
  50791. * @param newLensFlareSystem The lens flare system to add
  50792. */
  50793. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50794. /**
  50795. * Gets a lens flare system using its name
  50796. * @param name defines the name to look for
  50797. * @returns the lens flare system or null if not found
  50798. */
  50799. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50800. /**
  50801. * Gets a lens flare system using its id
  50802. * @param id defines the id to look for
  50803. * @returns the lens flare system or null if not found
  50804. */
  50805. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50806. }
  50807. }
  50808. /**
  50809. * Defines the lens flare scene component responsible to manage any lens flares
  50810. * in a given scene.
  50811. */
  50812. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50813. /**
  50814. * The component name helpfull to identify the component in the list of scene components.
  50815. */
  50816. readonly name: string;
  50817. /**
  50818. * The scene the component belongs to.
  50819. */
  50820. scene: Scene;
  50821. /**
  50822. * Creates a new instance of the component for the given scene
  50823. * @param scene Defines the scene to register the component in
  50824. */
  50825. constructor(scene: Scene);
  50826. /**
  50827. * Registers the component in a given scene
  50828. */
  50829. register(): void;
  50830. /**
  50831. * Rebuilds the elements related to this component in case of
  50832. * context lost for instance.
  50833. */
  50834. rebuild(): void;
  50835. /**
  50836. * Adds all the elements from the container to the scene
  50837. * @param container the container holding the elements
  50838. */
  50839. addFromContainer(container: AbstractScene): void;
  50840. /**
  50841. * Removes all the elements in the container from the scene
  50842. * @param container contains the elements to remove
  50843. * @param dispose if the removed element should be disposed (default: false)
  50844. */
  50845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50846. /**
  50847. * Serializes the component data to the specified json object
  50848. * @param serializationObject The object to serialize to
  50849. */
  50850. serialize(serializationObject: any): void;
  50851. /**
  50852. * Disposes the component and the associated ressources.
  50853. */
  50854. dispose(): void;
  50855. private _draw;
  50856. }
  50857. }
  50858. declare module "babylonjs/LensFlares/index" {
  50859. export * from "babylonjs/LensFlares/lensFlare";
  50860. export * from "babylonjs/LensFlares/lensFlareSystem";
  50861. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50862. }
  50863. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50864. import { Scene } from "babylonjs/scene";
  50865. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50866. import { AbstractScene } from "babylonjs/abstractScene";
  50867. /**
  50868. * Defines the shadow generator component responsible to manage any shadow generators
  50869. * in a given scene.
  50870. */
  50871. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50872. /**
  50873. * The component name helpfull to identify the component in the list of scene components.
  50874. */
  50875. readonly name: string;
  50876. /**
  50877. * The scene the component belongs to.
  50878. */
  50879. scene: Scene;
  50880. /**
  50881. * Creates a new instance of the component for the given scene
  50882. * @param scene Defines the scene to register the component in
  50883. */
  50884. constructor(scene: Scene);
  50885. /**
  50886. * Registers the component in a given scene
  50887. */
  50888. register(): void;
  50889. /**
  50890. * Rebuilds the elements related to this component in case of
  50891. * context lost for instance.
  50892. */
  50893. rebuild(): void;
  50894. /**
  50895. * Serializes the component data to the specified json object
  50896. * @param serializationObject The object to serialize to
  50897. */
  50898. serialize(serializationObject: any): void;
  50899. /**
  50900. * Adds all the elements from the container to the scene
  50901. * @param container the container holding the elements
  50902. */
  50903. addFromContainer(container: AbstractScene): void;
  50904. /**
  50905. * Removes all the elements in the container from the scene
  50906. * @param container contains the elements to remove
  50907. * @param dispose if the removed element should be disposed (default: false)
  50908. */
  50909. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50910. /**
  50911. * Rebuilds the elements related to this component in case of
  50912. * context lost for instance.
  50913. */
  50914. dispose(): void;
  50915. private _gatherRenderTargets;
  50916. }
  50917. }
  50918. declare module "babylonjs/Lights/Shadows/index" {
  50919. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50920. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50921. }
  50922. declare module "babylonjs/Lights/pointLight" {
  50923. import { Scene } from "babylonjs/scene";
  50924. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50926. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50927. import { Effect } from "babylonjs/Materials/effect";
  50928. /**
  50929. * A point light is a light defined by an unique point in world space.
  50930. * The light is emitted in every direction from this point.
  50931. * A good example of a point light is a standard light bulb.
  50932. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50933. */
  50934. export class PointLight extends ShadowLight {
  50935. private _shadowAngle;
  50936. /**
  50937. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50938. * This specifies what angle the shadow will use to be created.
  50939. *
  50940. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50941. */
  50942. /**
  50943. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50944. * This specifies what angle the shadow will use to be created.
  50945. *
  50946. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50947. */
  50948. shadowAngle: number;
  50949. /**
  50950. * Gets the direction if it has been set.
  50951. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50952. */
  50953. /**
  50954. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50955. */
  50956. direction: Vector3;
  50957. /**
  50958. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50959. * A PointLight emits the light in every direction.
  50960. * It can cast shadows.
  50961. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50962. * ```javascript
  50963. * var pointLight = new PointLight("pl", camera.position, scene);
  50964. * ```
  50965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50966. * @param name The light friendly name
  50967. * @param position The position of the point light in the scene
  50968. * @param scene The scene the lights belongs to
  50969. */
  50970. constructor(name: string, position: Vector3, scene: Scene);
  50971. /**
  50972. * Returns the string "PointLight"
  50973. * @returns the class name
  50974. */
  50975. getClassName(): string;
  50976. /**
  50977. * Returns the integer 0.
  50978. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50979. */
  50980. getTypeID(): number;
  50981. /**
  50982. * Specifies wether or not the shadowmap should be a cube texture.
  50983. * @returns true if the shadowmap needs to be a cube texture.
  50984. */
  50985. needCube(): boolean;
  50986. /**
  50987. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50988. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50989. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50990. */
  50991. getShadowDirection(faceIndex?: number): Vector3;
  50992. /**
  50993. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50994. * - fov = PI / 2
  50995. * - aspect ratio : 1.0
  50996. * - z-near and far equal to the active camera minZ and maxZ.
  50997. * Returns the PointLight.
  50998. */
  50999. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51000. protected _buildUniformLayout(): void;
  51001. /**
  51002. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51003. * @param effect The effect to update
  51004. * @param lightIndex The index of the light in the effect to update
  51005. * @returns The point light
  51006. */
  51007. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51008. /**
  51009. * Prepares the list of defines specific to the light type.
  51010. * @param defines the list of defines
  51011. * @param lightIndex defines the index of the light for the effect
  51012. */
  51013. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51014. }
  51015. }
  51016. declare module "babylonjs/Lights/index" {
  51017. export * from "babylonjs/Lights/light";
  51018. export * from "babylonjs/Lights/shadowLight";
  51019. export * from "babylonjs/Lights/Shadows/index";
  51020. export * from "babylonjs/Lights/directionalLight";
  51021. export * from "babylonjs/Lights/hemisphericLight";
  51022. export * from "babylonjs/Lights/pointLight";
  51023. export * from "babylonjs/Lights/spotLight";
  51024. }
  51025. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51026. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51027. /**
  51028. * Header information of HDR texture files.
  51029. */
  51030. export interface HDRInfo {
  51031. /**
  51032. * The height of the texture in pixels.
  51033. */
  51034. height: number;
  51035. /**
  51036. * The width of the texture in pixels.
  51037. */
  51038. width: number;
  51039. /**
  51040. * The index of the beginning of the data in the binary file.
  51041. */
  51042. dataPosition: number;
  51043. }
  51044. /**
  51045. * This groups tools to convert HDR texture to native colors array.
  51046. */
  51047. export class HDRTools {
  51048. private static Ldexp;
  51049. private static Rgbe2float;
  51050. private static readStringLine;
  51051. /**
  51052. * Reads header information from an RGBE texture stored in a native array.
  51053. * More information on this format are available here:
  51054. * https://en.wikipedia.org/wiki/RGBE_image_format
  51055. *
  51056. * @param uint8array The binary file stored in native array.
  51057. * @return The header information.
  51058. */
  51059. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51060. /**
  51061. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51062. * This RGBE texture needs to store the information as a panorama.
  51063. *
  51064. * More information on this format are available here:
  51065. * https://en.wikipedia.org/wiki/RGBE_image_format
  51066. *
  51067. * @param buffer The binary file stored in an array buffer.
  51068. * @param size The expected size of the extracted cubemap.
  51069. * @return The Cube Map information.
  51070. */
  51071. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51072. /**
  51073. * Returns the pixels data extracted from an RGBE texture.
  51074. * This pixels will be stored left to right up to down in the R G B order in one array.
  51075. *
  51076. * More information on this format are available here:
  51077. * https://en.wikipedia.org/wiki/RGBE_image_format
  51078. *
  51079. * @param uint8array The binary file stored in an array buffer.
  51080. * @param hdrInfo The header information of the file.
  51081. * @return The pixels data in RGB right to left up to down order.
  51082. */
  51083. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51084. private static RGBE_ReadPixels_RLE;
  51085. }
  51086. }
  51087. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51088. import { Nullable } from "babylonjs/types";
  51089. import { Scene } from "babylonjs/scene";
  51090. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51092. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51093. /**
  51094. * This represents a texture coming from an HDR input.
  51095. *
  51096. * The only supported format is currently panorama picture stored in RGBE format.
  51097. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51098. */
  51099. export class HDRCubeTexture extends BaseTexture {
  51100. private static _facesMapping;
  51101. private _generateHarmonics;
  51102. private _noMipmap;
  51103. private _textureMatrix;
  51104. private _size;
  51105. private _onLoad;
  51106. private _onError;
  51107. /**
  51108. * The texture URL.
  51109. */
  51110. url: string;
  51111. /**
  51112. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51113. */
  51114. coordinatesMode: number;
  51115. protected _isBlocking: boolean;
  51116. /**
  51117. * Sets wether or not the texture is blocking during loading.
  51118. */
  51119. /**
  51120. * Gets wether or not the texture is blocking during loading.
  51121. */
  51122. isBlocking: boolean;
  51123. protected _rotationY: number;
  51124. /**
  51125. * Sets texture matrix rotation angle around Y axis in radians.
  51126. */
  51127. /**
  51128. * Gets texture matrix rotation angle around Y axis radians.
  51129. */
  51130. rotationY: number;
  51131. /**
  51132. * Gets or sets the center of the bounding box associated with the cube texture
  51133. * It must define where the camera used to render the texture was set
  51134. */
  51135. boundingBoxPosition: Vector3;
  51136. private _boundingBoxSize;
  51137. /**
  51138. * Gets or sets the size of the bounding box associated with the cube texture
  51139. * When defined, the cubemap will switch to local mode
  51140. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51141. * @example https://www.babylonjs-playground.com/#RNASML
  51142. */
  51143. boundingBoxSize: Vector3;
  51144. /**
  51145. * Instantiates an HDRTexture from the following parameters.
  51146. *
  51147. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51148. * @param scene The scene the texture will be used in
  51149. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51150. * @param noMipmap Forces to not generate the mipmap if true
  51151. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51152. * @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)
  51153. * @param reserved Reserved flag for internal use.
  51154. */
  51155. 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>);
  51156. /**
  51157. * Get the current class name of the texture useful for serialization or dynamic coding.
  51158. * @returns "HDRCubeTexture"
  51159. */
  51160. getClassName(): string;
  51161. /**
  51162. * Occurs when the file is raw .hdr file.
  51163. */
  51164. private loadTexture;
  51165. clone(): HDRCubeTexture;
  51166. delayLoad(): void;
  51167. /**
  51168. * Get the texture reflection matrix used to rotate/transform the reflection.
  51169. * @returns the reflection matrix
  51170. */
  51171. getReflectionTextureMatrix(): Matrix;
  51172. /**
  51173. * Set the texture reflection matrix used to rotate/transform the reflection.
  51174. * @param value Define the reflection matrix to set
  51175. */
  51176. setReflectionTextureMatrix(value: Matrix): void;
  51177. /**
  51178. * Parses a JSON representation of an HDR Texture in order to create the texture
  51179. * @param parsedTexture Define the JSON representation
  51180. * @param scene Define the scene the texture should be created in
  51181. * @param rootUrl Define the root url in case we need to load relative dependencies
  51182. * @returns the newly created texture after parsing
  51183. */
  51184. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51185. serialize(): any;
  51186. }
  51187. }
  51188. declare module "babylonjs/Physics/physicsEngine" {
  51189. import { Nullable } from "babylonjs/types";
  51190. import { Vector3 } from "babylonjs/Maths/math";
  51191. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51192. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51193. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51194. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51195. /**
  51196. * Class used to control physics engine
  51197. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51198. */
  51199. export class PhysicsEngine implements IPhysicsEngine {
  51200. private _physicsPlugin;
  51201. /**
  51202. * Global value used to control the smallest number supported by the simulation
  51203. */
  51204. static Epsilon: number;
  51205. private _impostors;
  51206. private _joints;
  51207. /**
  51208. * Gets the gravity vector used by the simulation
  51209. */
  51210. gravity: Vector3;
  51211. /**
  51212. * Factory used to create the default physics plugin.
  51213. * @returns The default physics plugin
  51214. */
  51215. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51216. /**
  51217. * Creates a new Physics Engine
  51218. * @param gravity defines the gravity vector used by the simulation
  51219. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51220. */
  51221. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51222. /**
  51223. * Sets the gravity vector used by the simulation
  51224. * @param gravity defines the gravity vector to use
  51225. */
  51226. setGravity(gravity: Vector3): void;
  51227. /**
  51228. * Set the time step of the physics engine.
  51229. * Default is 1/60.
  51230. * To slow it down, enter 1/600 for example.
  51231. * To speed it up, 1/30
  51232. * @param newTimeStep defines the new timestep to apply to this world.
  51233. */
  51234. setTimeStep(newTimeStep?: number): void;
  51235. /**
  51236. * Get the time step of the physics engine.
  51237. * @returns the current time step
  51238. */
  51239. getTimeStep(): number;
  51240. /**
  51241. * Release all resources
  51242. */
  51243. dispose(): void;
  51244. /**
  51245. * Gets the name of the current physics plugin
  51246. * @returns the name of the plugin
  51247. */
  51248. getPhysicsPluginName(): string;
  51249. /**
  51250. * Adding a new impostor for the impostor tracking.
  51251. * This will be done by the impostor itself.
  51252. * @param impostor the impostor to add
  51253. */
  51254. addImpostor(impostor: PhysicsImpostor): void;
  51255. /**
  51256. * Remove an impostor from the engine.
  51257. * This impostor and its mesh will not longer be updated by the physics engine.
  51258. * @param impostor the impostor to remove
  51259. */
  51260. removeImpostor(impostor: PhysicsImpostor): void;
  51261. /**
  51262. * Add a joint to the physics engine
  51263. * @param mainImpostor defines the main impostor to which the joint is added.
  51264. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51265. * @param joint defines the joint that will connect both impostors.
  51266. */
  51267. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51268. /**
  51269. * Removes a joint from the simulation
  51270. * @param mainImpostor defines the impostor used with the joint
  51271. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51272. * @param joint defines the joint to remove
  51273. */
  51274. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51275. /**
  51276. * Called by the scene. No need to call it.
  51277. * @param delta defines the timespam between frames
  51278. */
  51279. _step(delta: number): void;
  51280. /**
  51281. * Gets the current plugin used to run the simulation
  51282. * @returns current plugin
  51283. */
  51284. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51285. /**
  51286. * Gets the list of physic impostors
  51287. * @returns an array of PhysicsImpostor
  51288. */
  51289. getImpostors(): Array<PhysicsImpostor>;
  51290. /**
  51291. * Gets the impostor for a physics enabled object
  51292. * @param object defines the object impersonated by the impostor
  51293. * @returns the PhysicsImpostor or null if not found
  51294. */
  51295. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51296. /**
  51297. * Gets the impostor for a physics body object
  51298. * @param body defines physics body used by the impostor
  51299. * @returns the PhysicsImpostor or null if not found
  51300. */
  51301. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51302. /**
  51303. * Does a raycast in the physics world
  51304. * @param from when should the ray start?
  51305. * @param to when should the ray end?
  51306. * @returns PhysicsRaycastResult
  51307. */
  51308. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51309. }
  51310. }
  51311. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51312. import { Nullable } from "babylonjs/types";
  51313. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51315. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51316. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51317. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51318. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51319. /** @hidden */
  51320. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51321. private _useDeltaForWorldStep;
  51322. world: any;
  51323. name: string;
  51324. private _physicsMaterials;
  51325. private _fixedTimeStep;
  51326. private _cannonRaycastResult;
  51327. private _raycastResult;
  51328. private _physicsBodysToRemoveAfterStep;
  51329. BJSCANNON: any;
  51330. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51331. setGravity(gravity: Vector3): void;
  51332. setTimeStep(timeStep: number): void;
  51333. getTimeStep(): number;
  51334. executeStep(delta: number): void;
  51335. private _removeMarkedPhysicsBodiesFromWorld;
  51336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51339. private _processChildMeshes;
  51340. removePhysicsBody(impostor: PhysicsImpostor): void;
  51341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51343. private _addMaterial;
  51344. private _checkWithEpsilon;
  51345. private _createShape;
  51346. private _createHeightmap;
  51347. private _minus90X;
  51348. private _plus90X;
  51349. private _tmpPosition;
  51350. private _tmpDeltaPosition;
  51351. private _tmpUnityRotation;
  51352. private _updatePhysicsBodyTransformation;
  51353. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51354. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51355. isSupported(): boolean;
  51356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51358. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51361. getBodyMass(impostor: PhysicsImpostor): number;
  51362. getBodyFriction(impostor: PhysicsImpostor): number;
  51363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51364. getBodyRestitution(impostor: PhysicsImpostor): number;
  51365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51366. sleepBody(impostor: PhysicsImpostor): void;
  51367. wakeUpBody(impostor: PhysicsImpostor): void;
  51368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51369. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51371. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51372. getRadius(impostor: PhysicsImpostor): number;
  51373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51374. dispose(): void;
  51375. private _extendNamespace;
  51376. /**
  51377. * Does a raycast in the physics world
  51378. * @param from when should the ray start?
  51379. * @param to when should the ray end?
  51380. * @returns PhysicsRaycastResult
  51381. */
  51382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51383. }
  51384. }
  51385. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51386. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51387. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51390. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51391. import { Nullable } from "babylonjs/types";
  51392. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51393. /** @hidden */
  51394. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51395. world: any;
  51396. name: string;
  51397. BJSOIMO: any;
  51398. private _raycastResult;
  51399. constructor(iterations?: number, oimoInjection?: any);
  51400. setGravity(gravity: Vector3): void;
  51401. setTimeStep(timeStep: number): void;
  51402. getTimeStep(): number;
  51403. private _tmpImpostorsArray;
  51404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51408. private _tmpPositionVector;
  51409. removePhysicsBody(impostor: PhysicsImpostor): void;
  51410. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51411. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51412. isSupported(): boolean;
  51413. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51414. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51415. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51416. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51419. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51420. getBodyMass(impostor: PhysicsImpostor): number;
  51421. getBodyFriction(impostor: PhysicsImpostor): number;
  51422. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51423. getBodyRestitution(impostor: PhysicsImpostor): number;
  51424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51425. sleepBody(impostor: PhysicsImpostor): void;
  51426. wakeUpBody(impostor: PhysicsImpostor): void;
  51427. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51428. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51429. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51430. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51431. getRadius(impostor: PhysicsImpostor): number;
  51432. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51433. dispose(): void;
  51434. /**
  51435. * Does a raycast in the physics world
  51436. * @param from when should the ray start?
  51437. * @param to when should the ray end?
  51438. * @returns PhysicsRaycastResult
  51439. */
  51440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51441. }
  51442. }
  51443. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51444. import { Nullable } from "babylonjs/types";
  51445. import { Scene } from "babylonjs/scene";
  51446. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51447. import { Mesh } from "babylonjs/Meshes/mesh";
  51448. /**
  51449. * Class containing static functions to help procedurally build meshes
  51450. */
  51451. export class RibbonBuilder {
  51452. /**
  51453. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51454. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51455. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51456. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51457. * * 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
  51458. * * 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
  51459. * * 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
  51460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51463. * * 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
  51464. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51465. * * 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
  51466. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51468. * @param name defines the name of the mesh
  51469. * @param options defines the options used to create the mesh
  51470. * @param scene defines the hosting scene
  51471. * @returns the ribbon mesh
  51472. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51473. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51474. */
  51475. static CreateRibbon(name: string, options: {
  51476. pathArray: Vector3[][];
  51477. closeArray?: boolean;
  51478. closePath?: boolean;
  51479. offset?: number;
  51480. updatable?: boolean;
  51481. sideOrientation?: number;
  51482. frontUVs?: Vector4;
  51483. backUVs?: Vector4;
  51484. instance?: Mesh;
  51485. invertUV?: boolean;
  51486. uvs?: Vector2[];
  51487. colors?: Color4[];
  51488. }, scene?: Nullable<Scene>): Mesh;
  51489. }
  51490. }
  51491. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51492. import { Nullable } from "babylonjs/types";
  51493. import { Scene } from "babylonjs/scene";
  51494. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51495. import { Mesh } from "babylonjs/Meshes/mesh";
  51496. /**
  51497. * Class containing static functions to help procedurally build meshes
  51498. */
  51499. export class ShapeBuilder {
  51500. /**
  51501. * 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.
  51502. * * 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.
  51503. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51504. * * 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.
  51505. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51506. * * 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
  51507. * * 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
  51508. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51513. * @param name defines the name of the mesh
  51514. * @param options defines the options used to create the mesh
  51515. * @param scene defines the hosting scene
  51516. * @returns the extruded shape mesh
  51517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51519. */
  51520. static ExtrudeShape(name: string, options: {
  51521. shape: Vector3[];
  51522. path: Vector3[];
  51523. scale?: number;
  51524. rotation?: number;
  51525. cap?: number;
  51526. updatable?: boolean;
  51527. sideOrientation?: number;
  51528. frontUVs?: Vector4;
  51529. backUVs?: Vector4;
  51530. instance?: Mesh;
  51531. invertUV?: boolean;
  51532. }, scene?: Nullable<Scene>): Mesh;
  51533. /**
  51534. * Creates an custom extruded shape mesh.
  51535. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51536. * * 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.
  51537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51538. * * 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
  51539. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51540. * * 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
  51541. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51542. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51543. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51544. * * 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
  51545. * * 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
  51546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51551. * @param name defines the name of the mesh
  51552. * @param options defines the options used to create the mesh
  51553. * @param scene defines the hosting scene
  51554. * @returns the custom extruded shape mesh
  51555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51558. */
  51559. static ExtrudeShapeCustom(name: string, options: {
  51560. shape: Vector3[];
  51561. path: Vector3[];
  51562. scaleFunction?: any;
  51563. rotationFunction?: any;
  51564. ribbonCloseArray?: boolean;
  51565. ribbonClosePath?: boolean;
  51566. cap?: number;
  51567. updatable?: boolean;
  51568. sideOrientation?: number;
  51569. frontUVs?: Vector4;
  51570. backUVs?: Vector4;
  51571. instance?: Mesh;
  51572. invertUV?: boolean;
  51573. }, scene?: Nullable<Scene>): Mesh;
  51574. private static _ExtrudeShapeGeneric;
  51575. }
  51576. }
  51577. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51578. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51579. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51580. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51581. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51582. import { Nullable } from "babylonjs/types";
  51583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51584. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51585. /**
  51586. * AmmoJS Physics plugin
  51587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51588. * @see https://github.com/kripken/ammo.js/
  51589. */
  51590. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51591. private _useDeltaForWorldStep;
  51592. /**
  51593. * Reference to the Ammo library
  51594. */
  51595. bjsAMMO: any;
  51596. /**
  51597. * Created ammoJS world which physics bodies are added to
  51598. */
  51599. world: any;
  51600. /**
  51601. * Name of the plugin
  51602. */
  51603. name: string;
  51604. private _timeStep;
  51605. private _fixedTimeStep;
  51606. private _maxSteps;
  51607. private _tmpQuaternion;
  51608. private _tmpAmmoTransform;
  51609. private _tmpAmmoQuaternion;
  51610. private _tmpAmmoConcreteContactResultCallback;
  51611. private _collisionConfiguration;
  51612. private _dispatcher;
  51613. private _overlappingPairCache;
  51614. private _solver;
  51615. private _softBodySolver;
  51616. private _tmpAmmoVectorA;
  51617. private _tmpAmmoVectorB;
  51618. private _tmpAmmoVectorC;
  51619. private _tmpAmmoVectorD;
  51620. private _tmpContactCallbackResult;
  51621. private _tmpAmmoVectorRCA;
  51622. private _tmpAmmoVectorRCB;
  51623. private _raycastResult;
  51624. private static readonly DISABLE_COLLISION_FLAG;
  51625. private static readonly KINEMATIC_FLAG;
  51626. private static readonly DISABLE_DEACTIVATION_FLAG;
  51627. /**
  51628. * Initializes the ammoJS plugin
  51629. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51630. * @param ammoInjection can be used to inject your own ammo reference
  51631. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51632. */
  51633. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51634. /**
  51635. * Sets the gravity of the physics world (m/(s^2))
  51636. * @param gravity Gravity to set
  51637. */
  51638. setGravity(gravity: Vector3): void;
  51639. /**
  51640. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51641. * @param timeStep timestep to use in seconds
  51642. */
  51643. setTimeStep(timeStep: number): void;
  51644. /**
  51645. * 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)
  51646. * @param fixedTimeStep fixedTimeStep to use in seconds
  51647. */
  51648. setFixedTimeStep(fixedTimeStep: number): void;
  51649. /**
  51650. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51651. * @param maxSteps the maximum number of steps by the physics engine per frame
  51652. */
  51653. setMaxSteps(maxSteps: number): void;
  51654. /**
  51655. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51656. * @returns the current timestep in seconds
  51657. */
  51658. getTimeStep(): number;
  51659. private _isImpostorInContact;
  51660. private _isImpostorPairInContact;
  51661. private _stepSimulation;
  51662. /**
  51663. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51664. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51665. * After the step the babylon meshes are set to the position of the physics imposters
  51666. * @param delta amount of time to step forward
  51667. * @param impostors array of imposters to update before/after the step
  51668. */
  51669. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51670. /**
  51671. * Update babylon mesh to match physics world object
  51672. * @param impostor imposter to match
  51673. */
  51674. private _afterSoftStep;
  51675. /**
  51676. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51677. * @param impostor imposter to match
  51678. */
  51679. private _ropeStep;
  51680. /**
  51681. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51682. * @param impostor imposter to match
  51683. */
  51684. private _softbodyOrClothStep;
  51685. private _tmpVector;
  51686. private _tmpMatrix;
  51687. /**
  51688. * Applies an impulse on the imposter
  51689. * @param impostor imposter to apply impulse to
  51690. * @param force amount of force to be applied to the imposter
  51691. * @param contactPoint the location to apply the impulse on the imposter
  51692. */
  51693. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51694. /**
  51695. * Applies a force on the imposter
  51696. * @param impostor imposter to apply force
  51697. * @param force amount of force to be applied to the imposter
  51698. * @param contactPoint the location to apply the force on the imposter
  51699. */
  51700. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51701. /**
  51702. * Creates a physics body using the plugin
  51703. * @param impostor the imposter to create the physics body on
  51704. */
  51705. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51706. /**
  51707. * Removes the physics body from the imposter and disposes of the body's memory
  51708. * @param impostor imposter to remove the physics body from
  51709. */
  51710. removePhysicsBody(impostor: PhysicsImpostor): void;
  51711. /**
  51712. * Generates a joint
  51713. * @param impostorJoint the imposter joint to create the joint with
  51714. */
  51715. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51716. /**
  51717. * Removes a joint
  51718. * @param impostorJoint the imposter joint to remove the joint from
  51719. */
  51720. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51721. private _addMeshVerts;
  51722. /**
  51723. * Initialise the soft body vertices to match its object's (mesh) vertices
  51724. * Softbody vertices (nodes) are in world space and to match this
  51725. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51726. * @param impostor to create the softbody for
  51727. */
  51728. private _softVertexData;
  51729. /**
  51730. * Create an impostor's soft body
  51731. * @param impostor to create the softbody for
  51732. */
  51733. private _createSoftbody;
  51734. /**
  51735. * Create cloth for an impostor
  51736. * @param impostor to create the softbody for
  51737. */
  51738. private _createCloth;
  51739. /**
  51740. * Create rope for an impostor
  51741. * @param impostor to create the softbody for
  51742. */
  51743. private _createRope;
  51744. private _addHullVerts;
  51745. private _createShape;
  51746. /**
  51747. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51748. * @param impostor imposter containing the physics body and babylon object
  51749. */
  51750. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51751. /**
  51752. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51753. * @param impostor imposter containing the physics body and babylon object
  51754. * @param newPosition new position
  51755. * @param newRotation new rotation
  51756. */
  51757. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51758. /**
  51759. * If this plugin is supported
  51760. * @returns true if its supported
  51761. */
  51762. isSupported(): boolean;
  51763. /**
  51764. * Sets the linear velocity of the physics body
  51765. * @param impostor imposter to set the velocity on
  51766. * @param velocity velocity to set
  51767. */
  51768. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51769. /**
  51770. * Sets the angular velocity of the physics body
  51771. * @param impostor imposter to set the velocity on
  51772. * @param velocity velocity to set
  51773. */
  51774. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51775. /**
  51776. * gets the linear velocity
  51777. * @param impostor imposter to get linear velocity from
  51778. * @returns linear velocity
  51779. */
  51780. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51781. /**
  51782. * gets the angular velocity
  51783. * @param impostor imposter to get angular velocity from
  51784. * @returns angular velocity
  51785. */
  51786. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51787. /**
  51788. * Sets the mass of physics body
  51789. * @param impostor imposter to set the mass on
  51790. * @param mass mass to set
  51791. */
  51792. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51793. /**
  51794. * Gets the mass of the physics body
  51795. * @param impostor imposter to get the mass from
  51796. * @returns mass
  51797. */
  51798. getBodyMass(impostor: PhysicsImpostor): number;
  51799. /**
  51800. * Gets friction of the impostor
  51801. * @param impostor impostor to get friction from
  51802. * @returns friction value
  51803. */
  51804. getBodyFriction(impostor: PhysicsImpostor): number;
  51805. /**
  51806. * Sets friction of the impostor
  51807. * @param impostor impostor to set friction on
  51808. * @param friction friction value
  51809. */
  51810. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51811. /**
  51812. * Gets restitution of the impostor
  51813. * @param impostor impostor to get restitution from
  51814. * @returns restitution value
  51815. */
  51816. getBodyRestitution(impostor: PhysicsImpostor): number;
  51817. /**
  51818. * Sets resitution of the impostor
  51819. * @param impostor impostor to set resitution on
  51820. * @param restitution resitution value
  51821. */
  51822. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51823. /**
  51824. * Gets pressure inside the impostor
  51825. * @param impostor impostor to get pressure from
  51826. * @returns pressure value
  51827. */
  51828. getBodyPressure(impostor: PhysicsImpostor): number;
  51829. /**
  51830. * Sets pressure inside a soft body impostor
  51831. * Cloth and rope must remain 0 pressure
  51832. * @param impostor impostor to set pressure on
  51833. * @param pressure pressure value
  51834. */
  51835. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51836. /**
  51837. * Gets stiffness of the impostor
  51838. * @param impostor impostor to get stiffness from
  51839. * @returns pressure value
  51840. */
  51841. getBodyStiffness(impostor: PhysicsImpostor): number;
  51842. /**
  51843. * Sets stiffness of the impostor
  51844. * @param impostor impostor to set stiffness on
  51845. * @param stiffness stiffness value from 0 to 1
  51846. */
  51847. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51848. /**
  51849. * Gets velocityIterations of the impostor
  51850. * @param impostor impostor to get velocity iterations from
  51851. * @returns velocityIterations value
  51852. */
  51853. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51854. /**
  51855. * Sets velocityIterations of the impostor
  51856. * @param impostor impostor to set velocity iterations on
  51857. * @param velocityIterations velocityIterations value
  51858. */
  51859. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51860. /**
  51861. * Gets positionIterations of the impostor
  51862. * @param impostor impostor to get position iterations from
  51863. * @returns positionIterations value
  51864. */
  51865. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51866. /**
  51867. * Sets positionIterations of the impostor
  51868. * @param impostor impostor to set position on
  51869. * @param positionIterations positionIterations value
  51870. */
  51871. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51872. /**
  51873. * Append an anchor to a cloth object
  51874. * @param impostor is the cloth impostor to add anchor to
  51875. * @param otherImpostor is the rigid impostor to anchor to
  51876. * @param width ratio across width from 0 to 1
  51877. * @param height ratio up height from 0 to 1
  51878. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51879. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51880. */
  51881. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51882. /**
  51883. * Append an hook to a rope object
  51884. * @param impostor is the rope impostor to add hook to
  51885. * @param otherImpostor is the rigid impostor to hook to
  51886. * @param length ratio along the rope from 0 to 1
  51887. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51889. */
  51890. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51891. /**
  51892. * Sleeps the physics body and stops it from being active
  51893. * @param impostor impostor to sleep
  51894. */
  51895. sleepBody(impostor: PhysicsImpostor): void;
  51896. /**
  51897. * Activates the physics body
  51898. * @param impostor impostor to activate
  51899. */
  51900. wakeUpBody(impostor: PhysicsImpostor): void;
  51901. /**
  51902. * Updates the distance parameters of the joint
  51903. * @param joint joint to update
  51904. * @param maxDistance maximum distance of the joint
  51905. * @param minDistance minimum distance of the joint
  51906. */
  51907. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51908. /**
  51909. * Sets a motor on the joint
  51910. * @param joint joint to set motor on
  51911. * @param speed speed of the motor
  51912. * @param maxForce maximum force of the motor
  51913. * @param motorIndex index of the motor
  51914. */
  51915. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51916. /**
  51917. * Sets the motors limit
  51918. * @param joint joint to set limit on
  51919. * @param upperLimit upper limit
  51920. * @param lowerLimit lower limit
  51921. */
  51922. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51923. /**
  51924. * Syncs the position and rotation of a mesh with the impostor
  51925. * @param mesh mesh to sync
  51926. * @param impostor impostor to update the mesh with
  51927. */
  51928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51929. /**
  51930. * Gets the radius of the impostor
  51931. * @param impostor impostor to get radius from
  51932. * @returns the radius
  51933. */
  51934. getRadius(impostor: PhysicsImpostor): number;
  51935. /**
  51936. * Gets the box size of the impostor
  51937. * @param impostor impostor to get box size from
  51938. * @param result the resulting box size
  51939. */
  51940. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51941. /**
  51942. * Disposes of the impostor
  51943. */
  51944. dispose(): void;
  51945. /**
  51946. * Does a raycast in the physics world
  51947. * @param from when should the ray start?
  51948. * @param to when should the ray end?
  51949. * @returns PhysicsRaycastResult
  51950. */
  51951. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51952. }
  51953. }
  51954. declare module "babylonjs/Probes/reflectionProbe" {
  51955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51956. import { Vector3 } from "babylonjs/Maths/math";
  51957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51958. import { Nullable } from "babylonjs/types";
  51959. import { Scene } from "babylonjs/scene";
  51960. module "babylonjs/abstractScene" {
  51961. interface AbstractScene {
  51962. /**
  51963. * The list of reflection probes added to the scene
  51964. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51965. */
  51966. reflectionProbes: Array<ReflectionProbe>;
  51967. /**
  51968. * Removes the given reflection probe from this scene.
  51969. * @param toRemove The reflection probe to remove
  51970. * @returns The index of the removed reflection probe
  51971. */
  51972. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51973. /**
  51974. * Adds the given reflection probe to this scene.
  51975. * @param newReflectionProbe The reflection probe to add
  51976. */
  51977. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51978. }
  51979. }
  51980. /**
  51981. * Class used to generate realtime reflection / refraction cube textures
  51982. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51983. */
  51984. export class ReflectionProbe {
  51985. /** defines the name of the probe */
  51986. name: string;
  51987. private _scene;
  51988. private _renderTargetTexture;
  51989. private _projectionMatrix;
  51990. private _viewMatrix;
  51991. private _target;
  51992. private _add;
  51993. private _attachedMesh;
  51994. private _invertYAxis;
  51995. /** Gets or sets probe position (center of the cube map) */
  51996. position: Vector3;
  51997. /**
  51998. * Creates a new reflection probe
  51999. * @param name defines the name of the probe
  52000. * @param size defines the texture resolution (for each face)
  52001. * @param scene defines the hosting scene
  52002. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52003. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52004. */
  52005. constructor(
  52006. /** defines the name of the probe */
  52007. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52008. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52009. samples: number;
  52010. /** Gets or sets the refresh rate to use (on every frame by default) */
  52011. refreshRate: number;
  52012. /**
  52013. * Gets the hosting scene
  52014. * @returns a Scene
  52015. */
  52016. getScene(): Scene;
  52017. /** Gets the internal CubeTexture used to render to */
  52018. readonly cubeTexture: RenderTargetTexture;
  52019. /** Gets the list of meshes to render */
  52020. readonly renderList: Nullable<AbstractMesh[]>;
  52021. /**
  52022. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52023. * @param mesh defines the mesh to attach to
  52024. */
  52025. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52026. /**
  52027. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52028. * @param renderingGroupId The rendering group id corresponding to its index
  52029. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52030. */
  52031. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52032. /**
  52033. * Clean all associated resources
  52034. */
  52035. dispose(): void;
  52036. /**
  52037. * Converts the reflection probe information to a readable string for debug purpose.
  52038. * @param fullDetails Supports for multiple levels of logging within scene loading
  52039. * @returns the human readable reflection probe info
  52040. */
  52041. toString(fullDetails?: boolean): string;
  52042. /**
  52043. * Get the class name of the relfection probe.
  52044. * @returns "ReflectionProbe"
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52049. * @returns The JSON representation of the texture
  52050. */
  52051. serialize(): any;
  52052. /**
  52053. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52054. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52055. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52056. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52057. * @returns The parsed reflection probe if successful
  52058. */
  52059. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52060. }
  52061. }
  52062. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52063. /** @hidden */
  52064. export var _BabylonLoaderRegistered: boolean;
  52065. }
  52066. declare module "babylonjs/Loading/Plugins/index" {
  52067. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52068. }
  52069. declare module "babylonjs/Loading/index" {
  52070. export * from "babylonjs/Loading/loadingScreen";
  52071. export * from "babylonjs/Loading/Plugins/index";
  52072. export * from "babylonjs/Loading/sceneLoader";
  52073. export * from "babylonjs/Loading/sceneLoaderFlags";
  52074. }
  52075. declare module "babylonjs/Materials/Background/index" {
  52076. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52077. }
  52078. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52079. import { Scene } from "babylonjs/scene";
  52080. import { Color3 } from "babylonjs/Maths/math";
  52081. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52083. /**
  52084. * The Physically based simple base material of BJS.
  52085. *
  52086. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52087. * It is used as the base class for both the specGloss and metalRough conventions.
  52088. */
  52089. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52090. /**
  52091. * Number of Simultaneous lights allowed on the material.
  52092. */
  52093. maxSimultaneousLights: number;
  52094. /**
  52095. * If sets to true, disables all the lights affecting the material.
  52096. */
  52097. disableLighting: boolean;
  52098. /**
  52099. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52100. */
  52101. environmentTexture: BaseTexture;
  52102. /**
  52103. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52104. */
  52105. invertNormalMapX: boolean;
  52106. /**
  52107. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52108. */
  52109. invertNormalMapY: boolean;
  52110. /**
  52111. * Normal map used in the model.
  52112. */
  52113. normalTexture: BaseTexture;
  52114. /**
  52115. * Emissivie color used to self-illuminate the model.
  52116. */
  52117. emissiveColor: Color3;
  52118. /**
  52119. * Emissivie texture used to self-illuminate the model.
  52120. */
  52121. emissiveTexture: BaseTexture;
  52122. /**
  52123. * Occlusion Channel Strenght.
  52124. */
  52125. occlusionStrength: number;
  52126. /**
  52127. * Occlusion Texture of the material (adding extra occlusion effects).
  52128. */
  52129. occlusionTexture: BaseTexture;
  52130. /**
  52131. * Defines the alpha limits in alpha test mode.
  52132. */
  52133. alphaCutOff: number;
  52134. /**
  52135. * Gets the current double sided mode.
  52136. */
  52137. /**
  52138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52139. */
  52140. doubleSided: boolean;
  52141. /**
  52142. * Stores the pre-calculated light information of a mesh in a texture.
  52143. */
  52144. lightmapTexture: BaseTexture;
  52145. /**
  52146. * If true, the light map contains occlusion information instead of lighting info.
  52147. */
  52148. useLightmapAsShadowmap: boolean;
  52149. /**
  52150. * Instantiates a new PBRMaterial instance.
  52151. *
  52152. * @param name The material name
  52153. * @param scene The scene the material will be use in.
  52154. */
  52155. constructor(name: string, scene: Scene);
  52156. getClassName(): string;
  52157. }
  52158. }
  52159. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52160. import { Scene } from "babylonjs/scene";
  52161. import { Color3 } from "babylonjs/Maths/math";
  52162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52163. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52164. /**
  52165. * The PBR material of BJS following the metal roughness convention.
  52166. *
  52167. * This fits to the PBR convention in the GLTF definition:
  52168. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52169. */
  52170. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52171. /**
  52172. * The base color has two different interpretations depending on the value of metalness.
  52173. * When the material is a metal, the base color is the specific measured reflectance value
  52174. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52175. * of the material.
  52176. */
  52177. baseColor: Color3;
  52178. /**
  52179. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52180. * well as opacity information in the alpha channel.
  52181. */
  52182. baseTexture: BaseTexture;
  52183. /**
  52184. * Specifies the metallic scalar value of the material.
  52185. * Can also be used to scale the metalness values of the metallic texture.
  52186. */
  52187. metallic: number;
  52188. /**
  52189. * Specifies the roughness scalar value of the material.
  52190. * Can also be used to scale the roughness values of the metallic texture.
  52191. */
  52192. roughness: number;
  52193. /**
  52194. * Texture containing both the metallic value in the B channel and the
  52195. * roughness value in the G channel to keep better precision.
  52196. */
  52197. metallicRoughnessTexture: BaseTexture;
  52198. /**
  52199. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52200. *
  52201. * @param name The material name
  52202. * @param scene The scene the material will be use in.
  52203. */
  52204. constructor(name: string, scene: Scene);
  52205. /**
  52206. * Return the currrent class name of the material.
  52207. */
  52208. getClassName(): string;
  52209. /**
  52210. * Makes a duplicate of the current material.
  52211. * @param name - name to use for the new material.
  52212. */
  52213. clone(name: string): PBRMetallicRoughnessMaterial;
  52214. /**
  52215. * Serialize the material to a parsable JSON object.
  52216. */
  52217. serialize(): any;
  52218. /**
  52219. * Parses a JSON object correponding to the serialize function.
  52220. */
  52221. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52222. }
  52223. }
  52224. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52225. import { Scene } from "babylonjs/scene";
  52226. import { Color3 } from "babylonjs/Maths/math";
  52227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52228. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52229. /**
  52230. * The PBR material of BJS following the specular glossiness convention.
  52231. *
  52232. * This fits to the PBR convention in the GLTF definition:
  52233. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52234. */
  52235. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52236. /**
  52237. * Specifies the diffuse color of the material.
  52238. */
  52239. diffuseColor: Color3;
  52240. /**
  52241. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52242. * channel.
  52243. */
  52244. diffuseTexture: BaseTexture;
  52245. /**
  52246. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52247. */
  52248. specularColor: Color3;
  52249. /**
  52250. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52251. */
  52252. glossiness: number;
  52253. /**
  52254. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52255. */
  52256. specularGlossinessTexture: BaseTexture;
  52257. /**
  52258. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52259. *
  52260. * @param name The material name
  52261. * @param scene The scene the material will be use in.
  52262. */
  52263. constructor(name: string, scene: Scene);
  52264. /**
  52265. * Return the currrent class name of the material.
  52266. */
  52267. getClassName(): string;
  52268. /**
  52269. * Makes a duplicate of the current material.
  52270. * @param name - name to use for the new material.
  52271. */
  52272. clone(name: string): PBRSpecularGlossinessMaterial;
  52273. /**
  52274. * Serialize the material to a parsable JSON object.
  52275. */
  52276. serialize(): any;
  52277. /**
  52278. * Parses a JSON object correponding to the serialize function.
  52279. */
  52280. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52281. }
  52282. }
  52283. declare module "babylonjs/Materials/PBR/index" {
  52284. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52285. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52286. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52287. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52288. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52289. }
  52290. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52291. import { Nullable } from "babylonjs/types";
  52292. import { Scene } from "babylonjs/scene";
  52293. import { Matrix } from "babylonjs/Maths/math";
  52294. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52295. /**
  52296. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52297. * It can help converting any input color in a desired output one. This can then be used to create effects
  52298. * from sepia, black and white to sixties or futuristic rendering...
  52299. *
  52300. * The only supported format is currently 3dl.
  52301. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52302. */
  52303. export class ColorGradingTexture extends BaseTexture {
  52304. /**
  52305. * The current texture matrix. (will always be identity in color grading texture)
  52306. */
  52307. private _textureMatrix;
  52308. /**
  52309. * The texture URL.
  52310. */
  52311. url: string;
  52312. /**
  52313. * Empty line regex stored for GC.
  52314. */
  52315. private static _noneEmptyLineRegex;
  52316. private _engine;
  52317. /**
  52318. * Instantiates a ColorGradingTexture from the following parameters.
  52319. *
  52320. * @param url The location of the color gradind data (currently only supporting 3dl)
  52321. * @param scene The scene the texture will be used in
  52322. */
  52323. constructor(url: string, scene: Scene);
  52324. /**
  52325. * Returns the texture matrix used in most of the material.
  52326. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52327. */
  52328. getTextureMatrix(): Matrix;
  52329. /**
  52330. * Occurs when the file being loaded is a .3dl LUT file.
  52331. */
  52332. private load3dlTexture;
  52333. /**
  52334. * Starts the loading process of the texture.
  52335. */
  52336. private loadTexture;
  52337. /**
  52338. * Clones the color gradind texture.
  52339. */
  52340. clone(): ColorGradingTexture;
  52341. /**
  52342. * Called during delayed load for textures.
  52343. */
  52344. delayLoad(): void;
  52345. /**
  52346. * Parses a color grading texture serialized by Babylon.
  52347. * @param parsedTexture The texture information being parsedTexture
  52348. * @param scene The scene to load the texture in
  52349. * @param rootUrl The root url of the data assets to load
  52350. * @return A color gradind texture
  52351. */
  52352. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52353. /**
  52354. * Serializes the LUT texture to json format.
  52355. */
  52356. serialize(): any;
  52357. }
  52358. }
  52359. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52361. import { Scene } from "babylonjs/scene";
  52362. import { Nullable } from "babylonjs/types";
  52363. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52364. /**
  52365. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52366. */
  52367. export class EquiRectangularCubeTexture extends BaseTexture {
  52368. /** The six faces of the cube. */
  52369. private static _FacesMapping;
  52370. private _noMipmap;
  52371. private _onLoad;
  52372. private _onError;
  52373. /** The size of the cubemap. */
  52374. private _size;
  52375. /** The buffer of the image. */
  52376. private _buffer;
  52377. /** The width of the input image. */
  52378. private _width;
  52379. /** The height of the input image. */
  52380. private _height;
  52381. /** The URL to the image. */
  52382. url: string;
  52383. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52384. coordinatesMode: number;
  52385. /**
  52386. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52387. * @param url The location of the image
  52388. * @param scene The scene the texture will be used in
  52389. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52390. * @param noMipmap Forces to not generate the mipmap if true
  52391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52393. * @param onLoad — defines a callback called when texture is loaded
  52394. * @param onError — defines a callback called if there is an error
  52395. */
  52396. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52397. /**
  52398. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52399. */
  52400. private loadImage;
  52401. /**
  52402. * Convert the image buffer into a cubemap and create a CubeTexture.
  52403. */
  52404. private loadTexture;
  52405. /**
  52406. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52407. * @param buffer The ArrayBuffer that should be converted.
  52408. * @returns The buffer as Float32Array.
  52409. */
  52410. private getFloat32ArrayFromArrayBuffer;
  52411. /**
  52412. * Get the current class name of the texture useful for serialization or dynamic coding.
  52413. * @returns "EquiRectangularCubeTexture"
  52414. */
  52415. getClassName(): string;
  52416. /**
  52417. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52418. * @returns A clone of the current EquiRectangularCubeTexture.
  52419. */
  52420. clone(): EquiRectangularCubeTexture;
  52421. }
  52422. }
  52423. declare module "babylonjs/Misc/tga" {
  52424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52425. /**
  52426. * Based on jsTGALoader - Javascript loader for TGA file
  52427. * By Vincent Thibault
  52428. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52429. */
  52430. export class TGATools {
  52431. private static _TYPE_INDEXED;
  52432. private static _TYPE_RGB;
  52433. private static _TYPE_GREY;
  52434. private static _TYPE_RLE_INDEXED;
  52435. private static _TYPE_RLE_RGB;
  52436. private static _TYPE_RLE_GREY;
  52437. private static _ORIGIN_MASK;
  52438. private static _ORIGIN_SHIFT;
  52439. private static _ORIGIN_BL;
  52440. private static _ORIGIN_BR;
  52441. private static _ORIGIN_UL;
  52442. private static _ORIGIN_UR;
  52443. /**
  52444. * Gets the header of a TGA file
  52445. * @param data defines the TGA data
  52446. * @returns the header
  52447. */
  52448. static GetTGAHeader(data: Uint8Array): any;
  52449. /**
  52450. * Uploads TGA content to a Babylon Texture
  52451. * @hidden
  52452. */
  52453. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52454. /** @hidden */
  52455. 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;
  52456. /** @hidden */
  52457. 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;
  52458. /** @hidden */
  52459. 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;
  52460. /** @hidden */
  52461. 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;
  52462. /** @hidden */
  52463. 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;
  52464. /** @hidden */
  52465. 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;
  52466. }
  52467. }
  52468. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52469. import { Nullable } from "babylonjs/types";
  52470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52471. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52472. /**
  52473. * Implementation of the TGA Texture Loader.
  52474. * @hidden
  52475. */
  52476. export class _TGATextureLoader implements IInternalTextureLoader {
  52477. /**
  52478. * Defines wether the loader supports cascade loading the different faces.
  52479. */
  52480. readonly supportCascades: boolean;
  52481. /**
  52482. * This returns if the loader support the current file information.
  52483. * @param extension defines the file extension of the file being loaded
  52484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52485. * @param fallback defines the fallback internal texture if any
  52486. * @param isBase64 defines whether the texture is encoded as a base64
  52487. * @param isBuffer defines whether the texture data are stored as a buffer
  52488. * @returns true if the loader can load the specified file
  52489. */
  52490. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52491. /**
  52492. * Transform the url before loading if required.
  52493. * @param rootUrl the url of the texture
  52494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52495. * @returns the transformed texture
  52496. */
  52497. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52498. /**
  52499. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52500. * @param rootUrl the url of the texture
  52501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52502. * @returns the fallback texture
  52503. */
  52504. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52505. /**
  52506. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52507. * @param data contains the texture data
  52508. * @param texture defines the BabylonJS internal texture
  52509. * @param createPolynomials will be true if polynomials have been requested
  52510. * @param onLoad defines the callback to trigger once the texture is ready
  52511. * @param onError defines the callback to trigger in case of error
  52512. */
  52513. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52514. /**
  52515. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52516. * @param data contains the texture data
  52517. * @param texture defines the BabylonJS internal texture
  52518. * @param callback defines the method to call once ready to upload
  52519. */
  52520. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52521. }
  52522. }
  52523. declare module "babylonjs/Misc/basis" {
  52524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52525. /**
  52526. * Info about the .basis files
  52527. */
  52528. class BasisFileInfo {
  52529. /**
  52530. * If the file has alpha
  52531. */
  52532. hasAlpha: boolean;
  52533. /**
  52534. * Info about each image of the basis file
  52535. */
  52536. images: Array<{
  52537. levels: Array<{
  52538. width: number;
  52539. height: number;
  52540. transcodedPixels: ArrayBufferView;
  52541. }>;
  52542. }>;
  52543. }
  52544. /**
  52545. * Result of transcoding a basis file
  52546. */
  52547. class TranscodeResult {
  52548. /**
  52549. * Info about the .basis file
  52550. */
  52551. fileInfo: BasisFileInfo;
  52552. /**
  52553. * Format to use when loading the file
  52554. */
  52555. format: number;
  52556. }
  52557. /**
  52558. * Configuration options for the Basis transcoder
  52559. */
  52560. export class BasisTranscodeConfiguration {
  52561. /**
  52562. * Supported compression formats used to determine the supported output format of the transcoder
  52563. */
  52564. supportedCompressionFormats?: {
  52565. /**
  52566. * etc1 compression format
  52567. */
  52568. etc1?: boolean;
  52569. /**
  52570. * s3tc compression format
  52571. */
  52572. s3tc?: boolean;
  52573. /**
  52574. * pvrtc compression format
  52575. */
  52576. pvrtc?: boolean;
  52577. /**
  52578. * etc2 compression format
  52579. */
  52580. etc2?: boolean;
  52581. };
  52582. /**
  52583. * If mipmap levels should be loaded for transcoded images (Default: true)
  52584. */
  52585. loadMipmapLevels?: boolean;
  52586. /**
  52587. * Index of a single image to load (Default: all images)
  52588. */
  52589. loadSingleImage?: number;
  52590. }
  52591. /**
  52592. * Used to load .Basis files
  52593. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52594. */
  52595. export class BasisTools {
  52596. private static _IgnoreSupportedFormats;
  52597. /**
  52598. * URL to use when loading the basis transcoder
  52599. */
  52600. static JSModuleURL: string;
  52601. /**
  52602. * URL to use when loading the wasm module for the transcoder
  52603. */
  52604. static WasmModuleURL: string;
  52605. /**
  52606. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52607. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52608. * @returns internal format corresponding to the Basis format
  52609. */
  52610. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52611. private static _WorkerPromise;
  52612. private static _Worker;
  52613. private static _actionId;
  52614. private static _CreateWorkerAsync;
  52615. /**
  52616. * Transcodes a loaded image file to compressed pixel data
  52617. * @param imageData image data to transcode
  52618. * @param config configuration options for the transcoding
  52619. * @returns a promise resulting in the transcoded image
  52620. */
  52621. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52622. /**
  52623. * Loads a texture from the transcode result
  52624. * @param texture texture load to
  52625. * @param transcodeResult the result of transcoding the basis file to load from
  52626. */
  52627. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52628. }
  52629. }
  52630. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52631. import { Nullable } from "babylonjs/types";
  52632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52633. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52634. /**
  52635. * Loader for .basis file format
  52636. */
  52637. export class _BasisTextureLoader implements IInternalTextureLoader {
  52638. /**
  52639. * Defines whether the loader supports cascade loading the different faces.
  52640. */
  52641. readonly supportCascades: boolean;
  52642. /**
  52643. * This returns if the loader support the current file information.
  52644. * @param extension defines the file extension of the file being loaded
  52645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52646. * @param fallback defines the fallback internal texture if any
  52647. * @param isBase64 defines whether the texture is encoded as a base64
  52648. * @param isBuffer defines whether the texture data are stored as a buffer
  52649. * @returns true if the loader can load the specified file
  52650. */
  52651. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52652. /**
  52653. * Transform the url before loading if required.
  52654. * @param rootUrl the url of the texture
  52655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52656. * @returns the transformed texture
  52657. */
  52658. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52659. /**
  52660. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52661. * @param rootUrl the url of the texture
  52662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52663. * @returns the fallback texture
  52664. */
  52665. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52666. /**
  52667. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52668. * @param data contains the texture data
  52669. * @param texture defines the BabylonJS internal texture
  52670. * @param createPolynomials will be true if polynomials have been requested
  52671. * @param onLoad defines the callback to trigger once the texture is ready
  52672. * @param onError defines the callback to trigger in case of error
  52673. */
  52674. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52675. /**
  52676. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52677. * @param data contains the texture data
  52678. * @param texture defines the BabylonJS internal texture
  52679. * @param callback defines the method to call once ready to upload
  52680. */
  52681. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52682. }
  52683. }
  52684. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52685. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52686. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52687. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52688. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52689. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52690. }
  52691. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52692. import { Scene } from "babylonjs/scene";
  52693. import { Texture } from "babylonjs/Materials/Textures/texture";
  52694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52695. /**
  52696. * 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.
  52697. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52698. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52699. */
  52700. export class CustomProceduralTexture extends ProceduralTexture {
  52701. private _animate;
  52702. private _time;
  52703. private _config;
  52704. private _texturePath;
  52705. /**
  52706. * Instantiates a new Custom Procedural Texture.
  52707. * 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.
  52708. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52709. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52710. * @param name Define the name of the texture
  52711. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52712. * @param size Define the size of the texture to create
  52713. * @param scene Define the scene the texture belongs to
  52714. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52715. * @param generateMipMaps Define if the texture should creates mip maps or not
  52716. */
  52717. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52718. private _loadJson;
  52719. /**
  52720. * Is the texture ready to be used ? (rendered at least once)
  52721. * @returns true if ready, otherwise, false.
  52722. */
  52723. isReady(): boolean;
  52724. /**
  52725. * Render the texture to its associated render target.
  52726. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52727. */
  52728. render(useCameraPostProcess?: boolean): void;
  52729. /**
  52730. * Update the list of dependant textures samplers in the shader.
  52731. */
  52732. updateTextures(): void;
  52733. /**
  52734. * Update the uniform values of the procedural texture in the shader.
  52735. */
  52736. updateShaderUniforms(): void;
  52737. /**
  52738. * Define if the texture animates or not.
  52739. */
  52740. animate: boolean;
  52741. }
  52742. }
  52743. declare module "babylonjs/Shaders/noise.fragment" {
  52744. /** @hidden */
  52745. export var noisePixelShader: {
  52746. name: string;
  52747. shader: string;
  52748. };
  52749. }
  52750. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52751. import { Nullable } from "babylonjs/types";
  52752. import { Scene } from "babylonjs/scene";
  52753. import { Texture } from "babylonjs/Materials/Textures/texture";
  52754. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52755. import "babylonjs/Shaders/noise.fragment";
  52756. /**
  52757. * Class used to generate noise procedural textures
  52758. */
  52759. export class NoiseProceduralTexture extends ProceduralTexture {
  52760. private _time;
  52761. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52762. brightness: number;
  52763. /** Defines the number of octaves to process */
  52764. octaves: number;
  52765. /** Defines the level of persistence (0.8 by default) */
  52766. persistence: number;
  52767. /** Gets or sets animation speed factor (default is 1) */
  52768. animationSpeedFactor: number;
  52769. /**
  52770. * Creates a new NoiseProceduralTexture
  52771. * @param name defines the name fo the texture
  52772. * @param size defines the size of the texture (default is 256)
  52773. * @param scene defines the hosting scene
  52774. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52775. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52776. */
  52777. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52778. private _updateShaderUniforms;
  52779. protected _getDefines(): string;
  52780. /** Generate the current state of the procedural texture */
  52781. render(useCameraPostProcess?: boolean): void;
  52782. /**
  52783. * Serializes this noise procedural texture
  52784. * @returns a serialized noise procedural texture object
  52785. */
  52786. serialize(): any;
  52787. /**
  52788. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52789. * @param parsedTexture defines parsed texture data
  52790. * @param scene defines the current scene
  52791. * @param rootUrl defines the root URL containing noise procedural texture information
  52792. * @returns a parsed NoiseProceduralTexture
  52793. */
  52794. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52795. }
  52796. }
  52797. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52798. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52799. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52800. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52801. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52802. }
  52803. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52804. import { Nullable } from "babylonjs/types";
  52805. import { Scene } from "babylonjs/scene";
  52806. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52808. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52809. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52810. /**
  52811. * Raw cube texture where the raw buffers are passed in
  52812. */
  52813. export class RawCubeTexture extends CubeTexture {
  52814. /**
  52815. * Creates a cube texture where the raw buffers are passed in.
  52816. * @param scene defines the scene the texture is attached to
  52817. * @param data defines the array of data to use to create each face
  52818. * @param size defines the size of the textures
  52819. * @param format defines the format of the data
  52820. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52821. * @param generateMipMaps defines if the engine should generate the mip levels
  52822. * @param invertY defines if data must be stored with Y axis inverted
  52823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52824. * @param compression defines the compression used (null by default)
  52825. */
  52826. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52827. /**
  52828. * Updates the raw cube texture.
  52829. * @param data defines the data to store
  52830. * @param format defines the data format
  52831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52832. * @param invertY defines if data must be stored with Y axis inverted
  52833. * @param compression defines the compression used (null by default)
  52834. * @param level defines which level of the texture to update
  52835. */
  52836. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52837. /**
  52838. * Updates a raw cube texture with RGBD encoded data.
  52839. * @param data defines the array of data [mipmap][face] to use to create each face
  52840. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52843. * @returns a promsie that resolves when the operation is complete
  52844. */
  52845. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52846. /**
  52847. * Clones the raw cube texture.
  52848. * @return a new cube texture
  52849. */
  52850. clone(): CubeTexture;
  52851. /** @hidden */
  52852. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52853. }
  52854. }
  52855. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52856. import { Scene } from "babylonjs/scene";
  52857. import { Texture } from "babylonjs/Materials/Textures/texture";
  52858. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52859. /**
  52860. * Class used to store 3D textures containing user data
  52861. */
  52862. export class RawTexture3D extends Texture {
  52863. /** Gets or sets the texture format to use */
  52864. format: number;
  52865. private _engine;
  52866. /**
  52867. * Create a new RawTexture3D
  52868. * @param data defines the data of the texture
  52869. * @param width defines the width of the texture
  52870. * @param height defines the height of the texture
  52871. * @param depth defines the depth of the texture
  52872. * @param format defines the texture format to use
  52873. * @param scene defines the hosting scene
  52874. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52875. * @param invertY defines if texture must be stored with Y axis inverted
  52876. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52878. */
  52879. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52880. /** Gets or sets the texture format to use */
  52881. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52882. /**
  52883. * Update the texture with new data
  52884. * @param data defines the data to store in the texture
  52885. */
  52886. update(data: ArrayBufferView): void;
  52887. }
  52888. }
  52889. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52890. import { Scene } from "babylonjs/scene";
  52891. import { Plane } from "babylonjs/Maths/math";
  52892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52893. /**
  52894. * Creates a refraction texture used by refraction channel of the standard material.
  52895. * It is like a mirror but to see through a material.
  52896. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52897. */
  52898. export class RefractionTexture extends RenderTargetTexture {
  52899. /**
  52900. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52901. * 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.
  52902. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52903. */
  52904. refractionPlane: Plane;
  52905. /**
  52906. * Define how deep under the surface we should see.
  52907. */
  52908. depth: number;
  52909. /**
  52910. * Creates a refraction texture used by refraction channel of the standard material.
  52911. * It is like a mirror but to see through a material.
  52912. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52913. * @param name Define the texture name
  52914. * @param size Define the size of the underlying texture
  52915. * @param scene Define the scene the refraction belongs to
  52916. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52917. */
  52918. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52919. /**
  52920. * Clone the refraction texture.
  52921. * @returns the cloned texture
  52922. */
  52923. clone(): RefractionTexture;
  52924. /**
  52925. * Serialize the texture to a JSON representation you could use in Parse later on
  52926. * @returns the serialized JSON representation
  52927. */
  52928. serialize(): any;
  52929. }
  52930. }
  52931. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52932. import { Nullable } from "babylonjs/types";
  52933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52934. import { Matrix } from "babylonjs/Maths/math";
  52935. import { Engine } from "babylonjs/Engines/engine";
  52936. import { Scene } from "babylonjs/scene";
  52937. /**
  52938. * Defines the options related to the creation of an HtmlElementTexture
  52939. */
  52940. export interface IHtmlElementTextureOptions {
  52941. /**
  52942. * Defines wether mip maps should be created or not.
  52943. */
  52944. generateMipMaps?: boolean;
  52945. /**
  52946. * Defines the sampling mode of the texture.
  52947. */
  52948. samplingMode?: number;
  52949. /**
  52950. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52951. */
  52952. engine: Nullable<Engine>;
  52953. /**
  52954. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52955. */
  52956. scene: Nullable<Scene>;
  52957. }
  52958. /**
  52959. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52960. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52961. * is automatically managed.
  52962. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52963. * in your application.
  52964. *
  52965. * As the update is not automatic, you need to call them manually.
  52966. */
  52967. export class HtmlElementTexture extends BaseTexture {
  52968. /**
  52969. * The texture URL.
  52970. */
  52971. element: HTMLVideoElement | HTMLCanvasElement;
  52972. private static readonly DefaultOptions;
  52973. private _textureMatrix;
  52974. private _engine;
  52975. private _isVideo;
  52976. private _generateMipMaps;
  52977. private _samplingMode;
  52978. /**
  52979. * Instantiates a HtmlElementTexture from the following parameters.
  52980. *
  52981. * @param name Defines the name of the texture
  52982. * @param element Defines the video or canvas the texture is filled with
  52983. * @param options Defines the other none mandatory texture creation options
  52984. */
  52985. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52986. private _createInternalTexture;
  52987. /**
  52988. * Returns the texture matrix used in most of the material.
  52989. */
  52990. getTextureMatrix(): Matrix;
  52991. /**
  52992. * Updates the content of the texture.
  52993. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52994. */
  52995. update(invertY?: Nullable<boolean>): void;
  52996. }
  52997. }
  52998. declare module "babylonjs/Materials/Textures/index" {
  52999. export * from "babylonjs/Materials/Textures/baseTexture";
  53000. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53001. export * from "babylonjs/Materials/Textures/cubeTexture";
  53002. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53003. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53004. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53005. export * from "babylonjs/Materials/Textures/internalTexture";
  53006. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53007. export * from "babylonjs/Materials/Textures/Loaders/index";
  53008. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53009. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53010. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53011. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53012. export * from "babylonjs/Materials/Textures/rawTexture";
  53013. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53014. export * from "babylonjs/Materials/Textures/refractionTexture";
  53015. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53016. export * from "babylonjs/Materials/Textures/texture";
  53017. export * from "babylonjs/Materials/Textures/videoTexture";
  53018. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53019. }
  53020. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53021. /**
  53022. * Enum used to define the target of a block
  53023. */
  53024. export enum NodeMaterialBlockTargets {
  53025. /** Vertex shader */
  53026. Vertex = 1,
  53027. /** Fragment shader */
  53028. Fragment = 2,
  53029. /** Vertex and Fragment */
  53030. VertexAndFragment = 3
  53031. }
  53032. }
  53033. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53034. /**
  53035. * Defines the kind of connection point for node based material
  53036. */
  53037. export enum NodeMaterialBlockConnectionPointTypes {
  53038. /** Float */
  53039. Float = 1,
  53040. /** Int */
  53041. Int = 2,
  53042. /** Vector2 */
  53043. Vector2 = 4,
  53044. /** Vector3 */
  53045. Vector3 = 8,
  53046. /** Vector4 */
  53047. Vector4 = 16,
  53048. /** Color3 */
  53049. Color3 = 32,
  53050. /** Color4 */
  53051. Color4 = 64,
  53052. /** Matrix */
  53053. Matrix = 128,
  53054. /** Texture */
  53055. Texture = 256,
  53056. /** Texture3D */
  53057. Texture3D = 512,
  53058. /** Vector3 or Color3 */
  53059. Vector3OrColor3 = 40,
  53060. /** Vector3 or Vector4 */
  53061. Vector3OrVector4 = 24,
  53062. /** Vector4 or Color4 */
  53063. Vector4OrColor4 = 80,
  53064. /** Color3 or Color4 */
  53065. Color3OrColor4 = 96,
  53066. /** Vector3 or Color3 */
  53067. Vector3OrColor3OrVector4OrColor4 = 120,
  53068. /** Detect type based on connection */
  53069. AutoDetect = 1024,
  53070. /** Output type that will be defined by input type */
  53071. BasedOnInput = 2048,
  53072. /** Light */
  53073. Light = 4096
  53074. }
  53075. }
  53076. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53077. /**
  53078. * Enum used to define well known values e.g. values automatically provided by the system
  53079. */
  53080. export enum NodeMaterialWellKnownValues {
  53081. /** World */
  53082. World = 1,
  53083. /** View */
  53084. View = 2,
  53085. /** Projection */
  53086. Projection = 3,
  53087. /** ViewProjection */
  53088. ViewProjection = 4,
  53089. /** WorldView */
  53090. WorldView = 5,
  53091. /** WorldViewProjection */
  53092. WorldViewProjection = 6,
  53093. /** CameraPosition */
  53094. CameraPosition = 7,
  53095. /** Will be filled by the block itself */
  53096. Automatic = 8
  53097. }
  53098. }
  53099. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53100. /**
  53101. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53102. */
  53103. export enum NodeMaterialBlockConnectionPointMode {
  53104. /** Value is an uniform */
  53105. Uniform = 0,
  53106. /** Value is a mesh attribute */
  53107. Attribute = 1,
  53108. /** Value is a varying between vertex and fragment shaders */
  53109. Varying = 2,
  53110. /** Mode is undefined */
  53111. Undefined = 3
  53112. }
  53113. }
  53114. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53117. /**
  53118. * Class used to store shared data between 2 NodeMaterialBuildState
  53119. */
  53120. export class NodeMaterialBuildStateSharedData {
  53121. /**
  53122. * Gets the list of emitted varyings
  53123. */
  53124. varyings: string[];
  53125. /**
  53126. * Gets the varying declaration string
  53127. */
  53128. varyingDeclaration: string;
  53129. /**
  53130. * Uniform connection points
  53131. */
  53132. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53133. /**
  53134. * Bindable blocks (Blocks that need to set data to the effect)
  53135. */
  53136. bindableBlocks: NodeMaterialBlock[];
  53137. /**
  53138. * List of blocks that can provide a compilation fallback
  53139. */
  53140. blocksWithFallbacks: NodeMaterialBlock[];
  53141. /**
  53142. * List of blocks that can provide a define update
  53143. */
  53144. blocksWithDefines: NodeMaterialBlock[];
  53145. /**
  53146. * List of blocks that can provide a repeatable content
  53147. */
  53148. repeatableContentBlocks: NodeMaterialBlock[];
  53149. /**
  53150. * List of blocks that can provide a dynamic list of uniforms
  53151. */
  53152. dynamicUniformBlocks: NodeMaterialBlock[];
  53153. /**
  53154. * List of blocks that can block the isReady function for the material
  53155. */
  53156. blockingBlocks: NodeMaterialBlock[];
  53157. /**
  53158. * Build Id used to avoid multiple recompilations
  53159. */
  53160. buildId: number;
  53161. /** List of emitted variables */
  53162. variableNames: {
  53163. [key: string]: number;
  53164. };
  53165. /** List of emitted defines */
  53166. defineNames: {
  53167. [key: string]: number;
  53168. };
  53169. /** Should emit comments? */
  53170. emitComments: boolean;
  53171. /** Emit build activity */
  53172. verbose: boolean;
  53173. /**
  53174. * Gets the compilation hints emitted at compilation time
  53175. */
  53176. hints: {
  53177. needWorldViewMatrix: boolean;
  53178. needWorldViewProjectionMatrix: boolean;
  53179. needAlphaBlending: boolean;
  53180. needAlphaTesting: boolean;
  53181. };
  53182. /**
  53183. * List of compilation checks
  53184. */
  53185. checks: {
  53186. emitVertex: boolean;
  53187. emitFragment: boolean;
  53188. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53189. };
  53190. /** Creates a new shared data */
  53191. constructor();
  53192. /**
  53193. * Emits console errors and exceptions if there is a failing check
  53194. */
  53195. emitErrors(): void;
  53196. }
  53197. }
  53198. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53200. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53201. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53202. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53203. import { Nullable } from "babylonjs/types";
  53204. /**
  53205. * Class used to store node based material build state
  53206. */
  53207. export class NodeMaterialBuildState {
  53208. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53209. supportUniformBuffers: boolean;
  53210. /**
  53211. * Gets the list of emitted attributes
  53212. */
  53213. attributes: string[];
  53214. /**
  53215. * Gets the list of emitted uniforms
  53216. */
  53217. uniforms: string[];
  53218. /**
  53219. * Gets the list of emitted uniform buffers
  53220. */
  53221. uniformBuffers: string[];
  53222. /**
  53223. * Gets the list of emitted samplers
  53224. */
  53225. samplers: string[];
  53226. /**
  53227. * Gets the list of emitted functions
  53228. */
  53229. functions: {
  53230. [key: string]: string;
  53231. };
  53232. /**
  53233. * Gets the target of the compilation state
  53234. */
  53235. target: NodeMaterialBlockTargets;
  53236. /**
  53237. * Gets the list of emitted counters
  53238. */
  53239. counters: {
  53240. [key: string]: number;
  53241. };
  53242. /**
  53243. * Shared data between multiple NodeMaterialBuildState instances
  53244. */
  53245. sharedData: NodeMaterialBuildStateSharedData;
  53246. /** @hidden */
  53247. _vertexState: NodeMaterialBuildState;
  53248. private _attributeDeclaration;
  53249. private _uniformDeclaration;
  53250. private _samplerDeclaration;
  53251. private _varyingTransfer;
  53252. private _repeatableContentAnchorIndex;
  53253. /** @hidden */
  53254. _builtCompilationString: string;
  53255. /**
  53256. * Gets the emitted compilation strings
  53257. */
  53258. compilationString: string;
  53259. /**
  53260. * Finalize the compilation strings
  53261. * @param state defines the current compilation state
  53262. */
  53263. finalize(state: NodeMaterialBuildState): void;
  53264. /** @hidden */
  53265. readonly _repeatableContentAnchor: string;
  53266. /** @hidden */
  53267. _getFreeVariableName(prefix: string): string;
  53268. /** @hidden */
  53269. _getFreeDefineName(prefix: string): string;
  53270. /** @hidden */
  53271. _excludeVariableName(name: string): void;
  53272. /** @hidden */
  53273. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53274. /** @hidden */
  53275. _emitFunction(name: string, code: string, comments: string): void;
  53276. /** @hidden */
  53277. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53278. replaceStrings?: {
  53279. search: RegExp;
  53280. replace: string;
  53281. }[];
  53282. repeatKey?: string;
  53283. }): string;
  53284. /** @hidden */
  53285. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53286. repeatKey?: string;
  53287. removeAttributes?: boolean;
  53288. removeUniforms?: boolean;
  53289. removeVaryings?: boolean;
  53290. removeIfDef?: boolean;
  53291. replaceStrings?: {
  53292. search: RegExp;
  53293. replace: string;
  53294. }[];
  53295. }, storeKey?: string): void;
  53296. /** @hidden */
  53297. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53298. private _emitDefine;
  53299. /** @hidden */
  53300. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53301. }
  53302. }
  53303. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53305. /**
  53306. * Root class for all node material optimizers
  53307. */
  53308. export class NodeMaterialOptimizer {
  53309. /**
  53310. * Function used to optimize a NodeMaterial graph
  53311. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53312. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53313. */
  53314. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53315. }
  53316. }
  53317. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53321. /**
  53322. * Block used to transform a vector4 with a matrix
  53323. */
  53324. export class Vector4TransformBlock extends NodeMaterialBlock {
  53325. /**
  53326. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53327. */
  53328. complementW: number;
  53329. /**
  53330. * Creates a new Vector4TransformBlock
  53331. * @param name defines the block name
  53332. */
  53333. constructor(name: string);
  53334. /**
  53335. * Gets the current class name
  53336. * @returns the class name
  53337. */
  53338. getClassName(): string;
  53339. /**
  53340. * Gets the vector input
  53341. */
  53342. readonly vector: NodeMaterialConnectionPoint;
  53343. /**
  53344. * Gets the output component
  53345. */
  53346. readonly output: NodeMaterialConnectionPoint;
  53347. /**
  53348. * Gets the matrix transform input
  53349. */
  53350. readonly transform: NodeMaterialConnectionPoint;
  53351. protected _buildBlock(state: NodeMaterialBuildState): this;
  53352. }
  53353. }
  53354. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53355. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53356. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53357. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53358. /**
  53359. * Block used to output the vertex position
  53360. */
  53361. export class VertexOutputBlock extends NodeMaterialBlock {
  53362. /**
  53363. * Creates a new VertexOutputBlock
  53364. * @param name defines the block name
  53365. */
  53366. constructor(name: string);
  53367. /**
  53368. * Gets the current class name
  53369. * @returns the class name
  53370. */
  53371. getClassName(): string;
  53372. /**
  53373. * Gets the vector input component
  53374. */
  53375. readonly vector: NodeMaterialConnectionPoint;
  53376. protected _buildBlock(state: NodeMaterialBuildState): this;
  53377. }
  53378. }
  53379. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53383. /**
  53384. * Block used to output the final color
  53385. */
  53386. export class FragmentOutputBlock extends NodeMaterialBlock {
  53387. /**
  53388. * Gets or sets a boolean indicating if this block will output an alpha value
  53389. */
  53390. alphaBlendingEnabled: boolean;
  53391. /**
  53392. * Create a new FragmentOutputBlock
  53393. * @param name defines the block name
  53394. */
  53395. constructor(name: string);
  53396. /**
  53397. * Gets the current class name
  53398. * @returns the class name
  53399. */
  53400. getClassName(): string;
  53401. /**
  53402. * Gets the color input component
  53403. */
  53404. readonly color: NodeMaterialConnectionPoint;
  53405. protected _buildBlock(state: NodeMaterialBuildState): this;
  53406. }
  53407. }
  53408. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53410. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53411. import { Scene } from "babylonjs/scene";
  53412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53413. import { Matrix } from "babylonjs/Maths/math";
  53414. import { Mesh } from "babylonjs/Meshes/mesh";
  53415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53416. import { Observable } from "babylonjs/Misc/observable";
  53417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53419. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53420. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53421. import { Nullable } from "babylonjs/types";
  53422. /**
  53423. * Interface used to configure the node material editor
  53424. */
  53425. export interface INodeMaterialEditorOptions {
  53426. /** Define the URl to load node editor script */
  53427. editorURL?: string;
  53428. }
  53429. /** @hidden */
  53430. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53431. /** BONES */
  53432. NUM_BONE_INFLUENCERS: number;
  53433. BonesPerMesh: number;
  53434. BONETEXTURE: boolean;
  53435. /** MORPH TARGETS */
  53436. MORPHTARGETS: boolean;
  53437. MORPHTARGETS_NORMAL: boolean;
  53438. MORPHTARGETS_TANGENT: boolean;
  53439. MORPHTARGETS_UV: boolean;
  53440. NUM_MORPH_INFLUENCERS: number;
  53441. /** IMAGE PROCESSING */
  53442. IMAGEPROCESSING: boolean;
  53443. VIGNETTE: boolean;
  53444. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53445. VIGNETTEBLENDMODEOPAQUE: boolean;
  53446. TONEMAPPING: boolean;
  53447. TONEMAPPING_ACES: boolean;
  53448. CONTRAST: boolean;
  53449. EXPOSURE: boolean;
  53450. COLORCURVES: boolean;
  53451. COLORGRADING: boolean;
  53452. COLORGRADING3D: boolean;
  53453. SAMPLER3DGREENDEPTH: boolean;
  53454. SAMPLER3DBGRMAP: boolean;
  53455. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53456. constructor();
  53457. setValue(name: string, value: boolean): void;
  53458. }
  53459. /**
  53460. * Class used to configure NodeMaterial
  53461. */
  53462. export interface INodeMaterialOptions {
  53463. /**
  53464. * Defines if blocks should emit comments
  53465. */
  53466. emitComments: boolean;
  53467. }
  53468. /**
  53469. * Class used to create a node based material built by assembling shader blocks
  53470. */
  53471. export class NodeMaterial extends PushMaterial {
  53472. private _options;
  53473. private _vertexCompilationState;
  53474. private _fragmentCompilationState;
  53475. private _sharedData;
  53476. private _buildId;
  53477. private _buildWasSuccessful;
  53478. private _cachedWorldViewMatrix;
  53479. private _cachedWorldViewProjectionMatrix;
  53480. private _textureConnectionPoints;
  53481. private _optimizers;
  53482. /** Define the URl to load node editor script */
  53483. static EditorURL: string;
  53484. private BJSNODEMATERIALEDITOR;
  53485. /** Get the inspector from bundle or global */
  53486. private _getGlobalNodeMaterialEditor;
  53487. /**
  53488. * Defines the maximum number of lights that can be used in the material
  53489. */
  53490. maxSimultaneousLights: number;
  53491. /**
  53492. * Observable raised when the material is built
  53493. */
  53494. onBuildObservable: Observable<NodeMaterial>;
  53495. /**
  53496. * Gets or sets the root nodes of the material vertex shader
  53497. */
  53498. _vertexOutputNodes: NodeMaterialBlock[];
  53499. /**
  53500. * Gets or sets the root nodes of the material fragment (pixel) shader
  53501. */
  53502. _fragmentOutputNodes: NodeMaterialBlock[];
  53503. /** Gets or sets options to control the node material overall behavior */
  53504. options: INodeMaterialOptions;
  53505. /**
  53506. * Default configuration related to image processing available in the standard Material.
  53507. */
  53508. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53509. /**
  53510. * Gets the image processing configuration used either in this material.
  53511. */
  53512. /**
  53513. * Sets the Default image processing configuration used either in the this material.
  53514. *
  53515. * If sets to null, the scene one is in use.
  53516. */
  53517. imageProcessingConfiguration: ImageProcessingConfiguration;
  53518. /**
  53519. * Create a new node based material
  53520. * @param name defines the material name
  53521. * @param scene defines the hosting scene
  53522. * @param options defines creation option
  53523. */
  53524. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53525. /**
  53526. * Gets the current class name of the material e.g. "NodeMaterial"
  53527. * @returns the class name
  53528. */
  53529. getClassName(): string;
  53530. /**
  53531. * Keep track of the image processing observer to allow dispose and replace.
  53532. */
  53533. private _imageProcessingObserver;
  53534. /**
  53535. * Attaches a new image processing configuration to the Standard Material.
  53536. * @param configuration
  53537. */
  53538. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53539. /**
  53540. * Adds a new optimizer to the list of optimizers
  53541. * @param optimizer defines the optimizers to add
  53542. * @returns the current material
  53543. */
  53544. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53545. /**
  53546. * Remove an optimizer from the list of optimizers
  53547. * @param optimizer defines the optimizers to remove
  53548. * @returns the current material
  53549. */
  53550. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53551. /**
  53552. * Add a new block to the list of output nodes
  53553. * @param node defines the node to add
  53554. * @returns the current material
  53555. */
  53556. addOutputNode(node: NodeMaterialBlock): this;
  53557. /**
  53558. * Remove a block from the list of root nodes
  53559. * @param node defines the node to remove
  53560. * @returns the current material
  53561. */
  53562. removeOutputNode(node: NodeMaterialBlock): this;
  53563. private _addVertexOutputNode;
  53564. private _removeVertexOutputNode;
  53565. private _addFragmentOutputNode;
  53566. private _removeFragmentOutputNode;
  53567. /**
  53568. * Specifies if the material will require alpha blending
  53569. * @returns a boolean specifying if alpha blending is needed
  53570. */
  53571. needAlphaBlending(): boolean;
  53572. /**
  53573. * Specifies if this material should be rendered in alpha test mode
  53574. * @returns a boolean specifying if an alpha test is needed.
  53575. */
  53576. needAlphaTesting(): boolean;
  53577. private _initializeBlock;
  53578. private _resetDualBlocks;
  53579. /**
  53580. * Build the material and generates the inner effect
  53581. * @param verbose defines if the build should log activity
  53582. */
  53583. build(verbose?: boolean): void;
  53584. /**
  53585. * Runs an otpimization phase to try to improve the shader code
  53586. */
  53587. optimize(): void;
  53588. private _prepareDefinesForAttributes;
  53589. /**
  53590. * Get if the submesh is ready to be used and all its information available.
  53591. * Child classes can use it to update shaders
  53592. * @param mesh defines the mesh to check
  53593. * @param subMesh defines which submesh to check
  53594. * @param useInstances specifies that instances should be used
  53595. * @returns a boolean indicating that the submesh is ready or not
  53596. */
  53597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53598. /**
  53599. * Binds the world matrix to the material
  53600. * @param world defines the world transformation matrix
  53601. */
  53602. bindOnlyWorldMatrix(world: Matrix): void;
  53603. /**
  53604. * Binds the submesh to this material by preparing the effect and shader to draw
  53605. * @param world defines the world transformation matrix
  53606. * @param mesh defines the mesh containing the submesh
  53607. * @param subMesh defines the submesh to bind the material to
  53608. */
  53609. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53610. /**
  53611. * Gets the active textures from the material
  53612. * @returns an array of textures
  53613. */
  53614. getActiveTextures(): BaseTexture[];
  53615. /**
  53616. * Specifies if the material uses a texture
  53617. * @param texture defines the texture to check against the material
  53618. * @returns a boolean specifying if the material uses the texture
  53619. */
  53620. hasTexture(texture: BaseTexture): boolean;
  53621. /**
  53622. * Disposes the material
  53623. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53624. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53625. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53626. */
  53627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53628. /** Creates the node editor window. */
  53629. private _createNodeEditor;
  53630. /**
  53631. * Launch the node material editor
  53632. * @param config Define the configuration of the editor
  53633. * @return a promise fulfilled when the node editor is visible
  53634. */
  53635. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53636. /**
  53637. * Clear the current material
  53638. */
  53639. clear(): void;
  53640. /**
  53641. * Clear the current material and set it to a default state
  53642. */
  53643. setToDefault(): void;
  53644. }
  53645. }
  53646. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53647. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53649. import { Nullable } from "babylonjs/types";
  53650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53651. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53652. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53654. import { Mesh } from "babylonjs/Meshes/mesh";
  53655. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53656. /**
  53657. * Defines a block that can be used inside a node based material
  53658. */
  53659. export class NodeMaterialBlock {
  53660. private _buildId;
  53661. private _target;
  53662. private _isFinalMerger;
  53663. /** @hidden */
  53664. _inputs: NodeMaterialConnectionPoint[];
  53665. /** @hidden */
  53666. _outputs: NodeMaterialConnectionPoint[];
  53667. /**
  53668. * Gets or sets the name of the block
  53669. */
  53670. name: string;
  53671. /**
  53672. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53673. */
  53674. readonly isFinalMerger: boolean;
  53675. /**
  53676. * Gets or sets the build Id
  53677. */
  53678. buildId: number;
  53679. /**
  53680. * Gets or sets the target of the block
  53681. */
  53682. target: NodeMaterialBlockTargets;
  53683. /**
  53684. * Gets the list of input points
  53685. */
  53686. readonly inputs: NodeMaterialConnectionPoint[];
  53687. /** Gets the list of output points */
  53688. readonly outputs: NodeMaterialConnectionPoint[];
  53689. /**
  53690. * Find an input by its name
  53691. * @param name defines the name of the input to look for
  53692. * @returns the input or null if not found
  53693. */
  53694. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53695. /**
  53696. * Find an output by its name
  53697. * @param name defines the name of the outputto look for
  53698. * @returns the output or null if not found
  53699. */
  53700. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53701. /**
  53702. * Creates a new NodeMaterialBlock
  53703. * @param name defines the block name
  53704. * @param target defines the target of that block (Vertex by default)
  53705. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53706. */
  53707. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53708. /**
  53709. * Initialize the block and prepare the context for build
  53710. * @param state defines the state that will be used for the build
  53711. */
  53712. initialize(state: NodeMaterialBuildState): void;
  53713. /**
  53714. * Bind data to effect. Will only be called for blocks with isBindable === true
  53715. * @param effect defines the effect to bind data to
  53716. * @param nodeMaterial defines the hosting NodeMaterial
  53717. * @param mesh defines the mesh that will be rendered
  53718. */
  53719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53720. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53721. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53722. protected _writeFloat(value: number): string;
  53723. /**
  53724. * Gets the current class name e.g. "NodeMaterialBlock"
  53725. * @returns the class name
  53726. */
  53727. getClassName(): string;
  53728. /**
  53729. * Register a new input. Must be called inside a block constructor
  53730. * @param name defines the connection point name
  53731. * @param type defines the connection point type
  53732. * @param isOptional defines a boolean indicating that this input can be omitted
  53733. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53734. * @returns the current block
  53735. */
  53736. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53737. /**
  53738. * Register a new output. Must be called inside a block constructor
  53739. * @param name defines the connection point name
  53740. * @param type defines the connection point type
  53741. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53742. * @returns the current block
  53743. */
  53744. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53745. /**
  53746. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53747. * @param forOutput defines an optional connection point to check compatibility with
  53748. * @returns the first available input or null
  53749. */
  53750. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53751. /**
  53752. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53753. * @param forBlock defines an optional block to check compatibility with
  53754. * @returns the first available input or null
  53755. */
  53756. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53757. /**
  53758. * Connect current block with another block
  53759. * @param other defines the block to connect with
  53760. * @param options define the various options to help pick the right connections
  53761. * @returns the current block
  53762. */
  53763. connectTo(other: NodeMaterialBlock, options?: {
  53764. input?: string;
  53765. output?: string;
  53766. outputSwizzle?: string;
  53767. }): this | undefined;
  53768. protected _buildBlock(state: NodeMaterialBuildState): void;
  53769. /**
  53770. * Add uniforms, samplers and uniform buffers at compilation time
  53771. * @param state defines the state to update
  53772. * @param nodeMaterial defines the node material requesting the update
  53773. * @param defines defines the material defines to update
  53774. */
  53775. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53776. /**
  53777. * Add potential fallbacks if shader compilation fails
  53778. * @param mesh defines the mesh to be rendered
  53779. * @param fallbacks defines the current prioritized list of fallbacks
  53780. */
  53781. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53782. /**
  53783. * Update defines for shader compilation
  53784. * @param mesh defines the mesh to be rendered
  53785. * @param nodeMaterial defines the node material requesting the update
  53786. * @param defines defines the material defines to update
  53787. * @param useInstances specifies that instances should be used
  53788. */
  53789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53790. /**
  53791. * Lets the block try to connect some inputs automatically
  53792. */
  53793. autoConfigure(): void;
  53794. /**
  53795. * Function called when a block is declared as repeatable content generator
  53796. * @param vertexShaderState defines the current compilation state for the vertex shader
  53797. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53798. * @param mesh defines the mesh to be rendered
  53799. * @param defines defines the material defines to update
  53800. */
  53801. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53802. /**
  53803. * Checks if the block is ready
  53804. * @param mesh defines the mesh to be rendered
  53805. * @param nodeMaterial defines the node material requesting the update
  53806. * @param defines defines the material defines to update
  53807. * @param useInstances specifies that instances should be used
  53808. * @returns true if the block is ready
  53809. */
  53810. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53811. /**
  53812. * Compile the current node and generate the shader code
  53813. * @param state defines the current compilation state (uniforms, samplers, current string)
  53814. * @returns the current block
  53815. */
  53816. build(state: NodeMaterialBuildState): this | undefined;
  53817. }
  53818. }
  53819. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53820. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53821. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53822. import { Nullable } from "babylonjs/types";
  53823. import { Effect } from "babylonjs/Materials/effect";
  53824. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53825. import { Scene } from "babylonjs/scene";
  53826. import { Matrix } from "babylonjs/Maths/math";
  53827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53828. /**
  53829. * Defines a connection point for a block
  53830. */
  53831. export class NodeMaterialConnectionPoint {
  53832. /** @hidden */
  53833. _ownerBlock: NodeMaterialBlock;
  53834. /** @hidden */
  53835. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53836. private _associatedVariableName;
  53837. private _endpoints;
  53838. private _storedValue;
  53839. private _valueCallback;
  53840. private _mode;
  53841. /** @hidden */
  53842. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53843. /** @hidden */
  53844. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53845. /** @hidden */
  53846. _needToEmitVarying: boolean;
  53847. /** @hidden */
  53848. _forceUniformInVertexShaderOnly: boolean;
  53849. private _type;
  53850. /**
  53851. * Gets or sets the connection point type (default is float)
  53852. */
  53853. type: NodeMaterialBlockConnectionPointTypes;
  53854. /**
  53855. * Gets or sets the connection point name
  53856. */
  53857. name: string;
  53858. /**
  53859. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53860. */
  53861. swizzle: string;
  53862. /**
  53863. * Gets or sets a boolean indicating that this connection point can be omitted
  53864. */
  53865. isOptional: boolean;
  53866. /**
  53867. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53868. */
  53869. define: string;
  53870. /** Gets or sets the target of that connection point */
  53871. target: NodeMaterialBlockTargets;
  53872. /**
  53873. * Gets or sets the value of that point.
  53874. * Please note that this value will be ignored if valueCallback is defined
  53875. */
  53876. value: any;
  53877. /**
  53878. * Gets or sets a callback used to get the value of that point.
  53879. * Please note that setting this value will force the connection point to ignore the value property
  53880. */
  53881. valueCallback: () => any;
  53882. /**
  53883. * Gets or sets the associated variable name in the shader
  53884. */
  53885. associatedVariableName: string;
  53886. /**
  53887. * Gets a boolean indicating that this connection point not defined yet
  53888. */
  53889. readonly isUndefined: boolean;
  53890. /**
  53891. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53892. * In this case the connection point name must be the name of the uniform to use.
  53893. * Can only be set on inputs
  53894. */
  53895. isUniform: boolean;
  53896. /**
  53897. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53898. * In this case the connection point name must be the name of the attribute to use
  53899. * Can only be set on inputs
  53900. */
  53901. isAttribute: boolean;
  53902. /**
  53903. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53904. * Can only be set on exit points
  53905. */
  53906. isVarying: boolean;
  53907. /** Get the other side of the connection (if any) */
  53908. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53909. /** Get the block that owns this connection point */
  53910. readonly ownerBlock: NodeMaterialBlock;
  53911. /** Get the block connected on the other side of this connection (if any) */
  53912. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53913. /** Get the block connected on the endpoints of this connection (if any) */
  53914. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53915. /**
  53916. * Creates a new connection point
  53917. * @param name defines the connection point name
  53918. * @param ownerBlock defines the block hosting this connection point
  53919. */
  53920. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53921. /**
  53922. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53923. * @returns the class name
  53924. */
  53925. getClassName(): string;
  53926. /**
  53927. * Set the source of this connection point to a vertex attribute
  53928. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53929. * @returns the current connection point
  53930. */
  53931. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53932. /**
  53933. * Set the source of this connection point to a well known value
  53934. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53935. * @returns the current connection point
  53936. */
  53937. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53938. /**
  53939. * Gets a boolean indicating that the current connection point is a well known value
  53940. */
  53941. readonly isWellKnownValue: boolean;
  53942. /**
  53943. * Gets or sets the current well known value or null if not defined as well know value
  53944. */
  53945. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53946. private _getTypeLength;
  53947. /**
  53948. * Gets an boolean indicating if the current point can be connected to another point
  53949. * @param connectionPoint defines the other connection point
  53950. * @returns true if the connection is possible
  53951. */
  53952. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53953. /**
  53954. * Connect this point to another connection point
  53955. * @param connectionPoint defines the other connection point
  53956. * @returns the current connection point
  53957. */
  53958. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53959. /**
  53960. * Disconnect this point from one of his endpoint
  53961. * @param endpoint defines the other connection point
  53962. * @returns the current connection point
  53963. */
  53964. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53965. /**
  53966. * When connection point is an uniform, this function will send its value to the effect
  53967. * @param effect defines the effect to transmit value to
  53968. * @param world defines the world matrix
  53969. * @param worldView defines the worldxview matrix
  53970. * @param worldViewProjection defines the worldxviewxprojection matrix
  53971. */
  53972. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53973. /**
  53974. * When connection point is an uniform, this function will send its value to the effect
  53975. * @param effect defines the effect to transmit value to
  53976. * @param scene defines the hosting scene
  53977. */
  53978. transmit(effect: Effect, scene: Scene): void;
  53979. }
  53980. }
  53981. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53985. import { Mesh } from "babylonjs/Meshes/mesh";
  53986. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53988. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53989. /**
  53990. * Block used to add support for vertex skinning (bones)
  53991. */
  53992. export class BonesBlock extends NodeMaterialBlock {
  53993. /**
  53994. * Creates a new BonesBlock
  53995. * @param name defines the block name
  53996. */
  53997. constructor(name: string);
  53998. /**
  53999. * Initialize the block and prepare the context for build
  54000. * @param state defines the state that will be used for the build
  54001. */
  54002. initialize(state: NodeMaterialBuildState): void;
  54003. /**
  54004. * Gets the current class name
  54005. * @returns the class name
  54006. */
  54007. getClassName(): string;
  54008. /**
  54009. * Gets the matrix indices input component
  54010. */
  54011. readonly matricesIndices: NodeMaterialConnectionPoint;
  54012. /**
  54013. * Gets the matrix weights input component
  54014. */
  54015. readonly matricesWeights: NodeMaterialConnectionPoint;
  54016. /**
  54017. * Gets the extra matrix indices input component
  54018. */
  54019. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54020. /**
  54021. * Gets the extra matrix weights input component
  54022. */
  54023. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54024. /**
  54025. * Gets the world input component
  54026. */
  54027. readonly world: NodeMaterialConnectionPoint;
  54028. /**
  54029. * Gets the output component
  54030. */
  54031. readonly output: NodeMaterialConnectionPoint;
  54032. autoConfigure(): void;
  54033. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54036. protected _buildBlock(state: NodeMaterialBuildState): this;
  54037. }
  54038. }
  54039. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54044. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54045. /**
  54046. * Block used to add support for instances
  54047. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54048. */
  54049. export class InstancesBlock extends NodeMaterialBlock {
  54050. /**
  54051. * Creates a new InstancesBlock
  54052. * @param name defines the block name
  54053. */
  54054. constructor(name: string);
  54055. /**
  54056. * Gets the current class name
  54057. * @returns the class name
  54058. */
  54059. getClassName(): string;
  54060. /**
  54061. * Gets the first world row input component
  54062. */
  54063. readonly world0: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the second world row input component
  54066. */
  54067. readonly world1: NodeMaterialConnectionPoint;
  54068. /**
  54069. * Gets the third world row input component
  54070. */
  54071. readonly world2: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the forth world row input component
  54074. */
  54075. readonly world3: NodeMaterialConnectionPoint;
  54076. /**
  54077. * Gets the world input component
  54078. */
  54079. readonly world: NodeMaterialConnectionPoint;
  54080. /**
  54081. * Gets the output component
  54082. */
  54083. readonly output: NodeMaterialConnectionPoint;
  54084. autoConfigure(): void;
  54085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54086. protected _buildBlock(state: NodeMaterialBuildState): this;
  54087. }
  54088. }
  54089. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54094. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54095. import { Effect } from "babylonjs/Materials/effect";
  54096. import { Mesh } from "babylonjs/Meshes/mesh";
  54097. /**
  54098. * Block used to add morph targets support to vertex shader
  54099. */
  54100. export class MorphTargetsBlock extends NodeMaterialBlock {
  54101. private _repeatableContentAnchor;
  54102. private _repeatebleContentGenerated;
  54103. /**
  54104. * Create a new MorphTargetsBlock
  54105. * @param name defines the block name
  54106. */
  54107. constructor(name: string);
  54108. /**
  54109. * Gets the current class name
  54110. * @returns the class name
  54111. */
  54112. getClassName(): string;
  54113. /**
  54114. * Gets the position input component
  54115. */
  54116. readonly position: NodeMaterialConnectionPoint;
  54117. /**
  54118. * Gets the normal input component
  54119. */
  54120. readonly normal: NodeMaterialConnectionPoint;
  54121. /**
  54122. * Gets the tangent input component
  54123. */
  54124. readonly tangent: NodeMaterialConnectionPoint;
  54125. /**
  54126. * Gets the tangent input component
  54127. */
  54128. readonly uv: NodeMaterialConnectionPoint;
  54129. /**
  54130. * Gets the position output component
  54131. */
  54132. readonly positionOutput: NodeMaterialConnectionPoint;
  54133. /**
  54134. * Gets the normal output component
  54135. */
  54136. readonly normalOutput: NodeMaterialConnectionPoint;
  54137. /**
  54138. * Gets the tangent output component
  54139. */
  54140. readonly tangentOutput: NodeMaterialConnectionPoint;
  54141. /**
  54142. * Gets the tangent output component
  54143. */
  54144. readonly uvOutput: NodeMaterialConnectionPoint;
  54145. initialize(state: NodeMaterialBuildState): void;
  54146. autoConfigure(): void;
  54147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54148. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54149. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54150. protected _buildBlock(state: NodeMaterialBuildState): this;
  54151. }
  54152. }
  54153. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54154. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54155. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54156. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54157. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54158. }
  54159. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54163. /**
  54164. * Block used to add an alpha test in the fragment shader
  54165. */
  54166. export class AlphaTestBlock extends NodeMaterialBlock {
  54167. /**
  54168. * Gets or sets the alpha value where alpha testing happens
  54169. */
  54170. alphaCutOff: number;
  54171. /**
  54172. * Create a new AlphaTestBlock
  54173. * @param name defines the block name
  54174. */
  54175. constructor(name: string);
  54176. /**
  54177. * Gets the current class name
  54178. * @returns the class name
  54179. */
  54180. getClassName(): string;
  54181. /**
  54182. * Gets the color input component
  54183. */
  54184. readonly color: NodeMaterialConnectionPoint;
  54185. protected _buildBlock(state: NodeMaterialBuildState): this;
  54186. }
  54187. }
  54188. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54192. /**
  54193. * Block used to create a Color4 out of 4 inputs (one for each component)
  54194. */
  54195. export class RGBAMergerBlock extends NodeMaterialBlock {
  54196. /**
  54197. * Create a new RGBAMergerBlock
  54198. * @param name defines the block name
  54199. */
  54200. constructor(name: string);
  54201. /**
  54202. * Gets the current class name
  54203. * @returns the class name
  54204. */
  54205. getClassName(): string;
  54206. /**
  54207. * Gets the R input component
  54208. */
  54209. readonly r: NodeMaterialConnectionPoint;
  54210. /**
  54211. * Gets the G input component
  54212. */
  54213. readonly g: NodeMaterialConnectionPoint;
  54214. /**
  54215. * Gets the B input component
  54216. */
  54217. readonly b: NodeMaterialConnectionPoint;
  54218. /**
  54219. * Gets the RGB input component
  54220. */
  54221. readonly rgb: NodeMaterialConnectionPoint;
  54222. /**
  54223. * Gets the R input component
  54224. */
  54225. readonly a: NodeMaterialConnectionPoint;
  54226. /**
  54227. * Gets the output component
  54228. */
  54229. readonly output: NodeMaterialConnectionPoint;
  54230. protected _buildBlock(state: NodeMaterialBuildState): this;
  54231. }
  54232. }
  54233. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54237. /**
  54238. * Block used to create a Color3 out of 3 inputs (one for each component)
  54239. */
  54240. export class RGBMergerBlock extends NodeMaterialBlock {
  54241. /**
  54242. * Create a new RGBMergerBlock
  54243. * @param name defines the block name
  54244. */
  54245. constructor(name: string);
  54246. /**
  54247. * Gets the current class name
  54248. * @returns the class name
  54249. */
  54250. getClassName(): string;
  54251. /**
  54252. * Gets the R component input
  54253. */
  54254. readonly r: NodeMaterialConnectionPoint;
  54255. /**
  54256. * Gets the G component input
  54257. */
  54258. readonly g: NodeMaterialConnectionPoint;
  54259. /**
  54260. * Gets the B component input
  54261. */
  54262. readonly b: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the output component
  54265. */
  54266. readonly output: NodeMaterialConnectionPoint;
  54267. protected _buildBlock(state: NodeMaterialBuildState): this;
  54268. }
  54269. }
  54270. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54274. /**
  54275. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54276. */
  54277. export class RGBASplitterBlock extends NodeMaterialBlock {
  54278. /**
  54279. * Create a new RGBASplitterBlock
  54280. * @param name defines the block name
  54281. */
  54282. constructor(name: string);
  54283. /**
  54284. * Gets the current class name
  54285. * @returns the class name
  54286. */
  54287. getClassName(): string;
  54288. /**
  54289. * Gets the input component
  54290. */
  54291. readonly input: NodeMaterialConnectionPoint;
  54292. protected _buildBlock(state: NodeMaterialBuildState): this;
  54293. }
  54294. }
  54295. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54299. /**
  54300. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54301. */
  54302. export class RGBSplitterBlock extends NodeMaterialBlock {
  54303. /**
  54304. * Create a new RGBSplitterBlock
  54305. * @param name defines the block name
  54306. */
  54307. constructor(name: string);
  54308. /**
  54309. * Gets the current class name
  54310. * @returns the class name
  54311. */
  54312. getClassName(): string;
  54313. /**
  54314. * Gets the input component
  54315. */
  54316. readonly input: NodeMaterialConnectionPoint;
  54317. protected _buildBlock(state: NodeMaterialBuildState): this;
  54318. }
  54319. }
  54320. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54325. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54326. /**
  54327. * Block used to read a texture from a sampler
  54328. */
  54329. export class TextureBlock extends NodeMaterialBlock {
  54330. private _defineName;
  54331. /**
  54332. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54333. */
  54334. autoConnectTextureMatrix: boolean;
  54335. /**
  54336. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54337. */
  54338. autoSelectUV: boolean;
  54339. /**
  54340. * Create a new TextureBlock
  54341. * @param name defines the block name
  54342. */
  54343. constructor(name: string);
  54344. /**
  54345. * Gets the current class name
  54346. * @returns the class name
  54347. */
  54348. getClassName(): string;
  54349. /**
  54350. * Gets the uv input component
  54351. */
  54352. readonly uv: NodeMaterialConnectionPoint;
  54353. /**
  54354. * Gets the texture information input component
  54355. */
  54356. readonly textureInfo: NodeMaterialConnectionPoint;
  54357. /**
  54358. * Gets the transformed uv input component
  54359. */
  54360. readonly transformedUV: NodeMaterialConnectionPoint;
  54361. /**
  54362. * Gets the texture input component
  54363. */
  54364. readonly texture: NodeMaterialConnectionPoint;
  54365. /**
  54366. * Gets the texture transform input component
  54367. */
  54368. readonly textureTransform: NodeMaterialConnectionPoint;
  54369. /**
  54370. * Gets the output component
  54371. */
  54372. readonly output: NodeMaterialConnectionPoint;
  54373. autoConfigure(): void;
  54374. initialize(state: NodeMaterialBuildState): void;
  54375. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54376. isReady(): boolean;
  54377. private _injectVertexCode;
  54378. protected _buildBlock(state: NodeMaterialBuildState): this;
  54379. }
  54380. }
  54381. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54386. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54387. import { Effect } from "babylonjs/Materials/effect";
  54388. import { Mesh } from "babylonjs/Meshes/mesh";
  54389. /**
  54390. * Block used to add image processing support to fragment shader
  54391. */
  54392. export class ImageProcessingBlock extends NodeMaterialBlock {
  54393. /**
  54394. * Create a new ImageProcessingBlock
  54395. * @param name defines the block name
  54396. */
  54397. constructor(name: string);
  54398. /**
  54399. * Gets the current class name
  54400. * @returns the class name
  54401. */
  54402. getClassName(): string;
  54403. /**
  54404. * Gets the color input component
  54405. */
  54406. readonly color: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the output component
  54409. */
  54410. readonly output: NodeMaterialConnectionPoint;
  54411. /**
  54412. * Initialize the block and prepare the context for build
  54413. * @param state defines the state that will be used for the build
  54414. */
  54415. initialize(state: NodeMaterialBuildState): void;
  54416. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54419. protected _buildBlock(state: NodeMaterialBuildState): this;
  54420. }
  54421. }
  54422. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54423. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54424. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54425. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54426. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54427. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54428. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54429. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54430. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54431. }
  54432. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54435. import { Mesh } from "babylonjs/Meshes/mesh";
  54436. import { Effect } from "babylonjs/Materials/effect";
  54437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54439. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54440. /**
  54441. * Block used to add support for scene fog
  54442. */
  54443. export class FogBlock extends NodeMaterialBlock {
  54444. /**
  54445. * Create a new FogBlock
  54446. * @param name defines the block name
  54447. */
  54448. constructor(name: string);
  54449. /**
  54450. * Gets the current class name
  54451. * @returns the class name
  54452. */
  54453. getClassName(): string;
  54454. /**
  54455. * Gets the world position input component
  54456. */
  54457. readonly worldPosition: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the view input component
  54460. */
  54461. readonly view: NodeMaterialConnectionPoint;
  54462. /**
  54463. * Gets the color input component
  54464. */
  54465. readonly color: NodeMaterialConnectionPoint;
  54466. /**
  54467. * Gets the fog color input component
  54468. */
  54469. readonly fogColor: NodeMaterialConnectionPoint;
  54470. /**
  54471. * Gets the for parameter input component
  54472. */
  54473. readonly fogParameters: NodeMaterialConnectionPoint;
  54474. /**
  54475. * Gets the output component
  54476. */
  54477. readonly output: NodeMaterialConnectionPoint;
  54478. autoConfigure(): void;
  54479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54480. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54481. protected _buildBlock(state: NodeMaterialBuildState): this;
  54482. }
  54483. }
  54484. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54489. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54490. import { Effect } from "babylonjs/Materials/effect";
  54491. import { Mesh } from "babylonjs/Meshes/mesh";
  54492. /**
  54493. * Block used to add light in the fragment shader
  54494. */
  54495. export class LightBlock extends NodeMaterialBlock {
  54496. private _lightId;
  54497. /**
  54498. * Create a new LightBlock
  54499. * @param name defines the block name
  54500. */
  54501. constructor(name: string);
  54502. /**
  54503. * Gets the current class name
  54504. * @returns the class name
  54505. */
  54506. getClassName(): string;
  54507. /**
  54508. * Gets the world position input component
  54509. */
  54510. readonly worldPosition: NodeMaterialConnectionPoint;
  54511. /**
  54512. * Gets the world normal input component
  54513. */
  54514. readonly worldNormal: NodeMaterialConnectionPoint;
  54515. /**
  54516. * Gets the light input component.
  54517. * If not defined, all lights will be considered
  54518. */
  54519. readonly light: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the camera (or eye) position component
  54522. */
  54523. readonly cameraPosition: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the diffuse output component
  54526. */
  54527. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the specular output component
  54530. */
  54531. readonly specularOutput: NodeMaterialConnectionPoint;
  54532. autoConfigure(): void;
  54533. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54534. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54536. private _injectVertexCode;
  54537. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54538. }
  54539. }
  54540. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54541. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54542. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54543. }
  54544. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  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 multiply 2 values
  54550. */
  54551. export class MultiplyBlock extends NodeMaterialBlock {
  54552. /**
  54553. * Creates a new MultiplyBlock
  54554. * @param name defines the block name
  54555. */
  54556. constructor(name: string);
  54557. /**
  54558. * Gets the current class name
  54559. * @returns the class name
  54560. */
  54561. getClassName(): string;
  54562. /**
  54563. * Gets the left operand input component
  54564. */
  54565. readonly left: NodeMaterialConnectionPoint;
  54566. /**
  54567. * Gets the right operand input component
  54568. */
  54569. readonly right: 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/addBlock" {
  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 add 2 vector4
  54583. */
  54584. export class AddBlock extends NodeMaterialBlock {
  54585. /**
  54586. * Creates a new AddBlock
  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 left operand input component
  54597. */
  54598. readonly left: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the right operand input component
  54601. */
  54602. readonly right: 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/clampBlock" {
  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 clamp a float
  54616. */
  54617. export class ClampBlock extends NodeMaterialBlock {
  54618. /** Gets or sets the minimum range */
  54619. minimum: number;
  54620. /** Gets or sets the maximum range */
  54621. maximum: number;
  54622. /**
  54623. * Creates a new ClampBlock
  54624. * @param name defines the block name
  54625. */
  54626. constructor(name: string);
  54627. /**
  54628. * Gets the current class name
  54629. * @returns the class name
  54630. */
  54631. getClassName(): string;
  54632. /**
  54633. * Gets the value input component
  54634. */
  54635. readonly value: NodeMaterialConnectionPoint;
  54636. /**
  54637. * Gets the output component
  54638. */
  54639. readonly output: NodeMaterialConnectionPoint;
  54640. protected _buildBlock(state: NodeMaterialBuildState): this;
  54641. }
  54642. }
  54643. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54647. /**
  54648. * Block used to transform a vector2 with a matrix
  54649. */
  54650. export class Vector2TransformBlock extends NodeMaterialBlock {
  54651. /**
  54652. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54653. */
  54654. complementZ: number;
  54655. /**
  54656. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54657. */
  54658. complementW: number;
  54659. /**
  54660. * Creates a new Vector2TransformBlock
  54661. * @param name defines the block name
  54662. */
  54663. constructor(name: string);
  54664. /**
  54665. * Gets the vector input
  54666. */
  54667. readonly vector: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the matrix transform input
  54670. */
  54671. readonly transform: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the output component
  54674. */
  54675. readonly output: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the current class name
  54678. * @returns the class name
  54679. */
  54680. getClassName(): string;
  54681. protected _buildBlock(state: NodeMaterialBuildState): this;
  54682. }
  54683. }
  54684. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54685. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54686. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54687. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54688. /**
  54689. * Block used to transform a vector3 with a matrix
  54690. */
  54691. export class Vector3TransformBlock extends NodeMaterialBlock {
  54692. /**
  54693. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54694. */
  54695. complement: number;
  54696. /**
  54697. * Creates a new Vector3TransformBlock
  54698. * @param name defines the block name
  54699. */
  54700. constructor(name: string);
  54701. /**
  54702. * Gets the vector input
  54703. */
  54704. readonly vector: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the matrix transform input
  54707. */
  54708. readonly transform: 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/vector2TransformBlock";
  54729. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54730. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54731. }
  54732. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54733. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54734. }
  54735. declare module "babylonjs/Materials/Node/index" {
  54736. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54737. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54738. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54739. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54740. export * from "babylonjs/Materials/Node/nodeMaterial";
  54741. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54742. export * from "babylonjs/Materials/Node/Blocks/index";
  54743. export * from "babylonjs/Materials/Node/Optimizers/index";
  54744. }
  54745. declare module "babylonjs/Materials/effectRenderer" {
  54746. import { Nullable } from "babylonjs/types";
  54747. import { Texture } from "babylonjs/Materials/Textures/texture";
  54748. import { Engine } from "babylonjs/Engines/engine";
  54749. import { Observable } from "babylonjs/Misc/observable";
  54750. import { Effect } from "babylonjs/Materials/effect";
  54751. /**
  54752. * Helper class to render one or more effects
  54753. */
  54754. export class EffectRenderer {
  54755. private engine;
  54756. private static _Vertices;
  54757. private static _Indices;
  54758. private _vertexBuffers;
  54759. private _indexBuffer;
  54760. private _ringBufferIndex;
  54761. private _ringScreenBuffer;
  54762. private _getNextFrameBuffer;
  54763. /**
  54764. * Creates an effect renderer
  54765. * @param engine the engine to use for rendering
  54766. */
  54767. constructor(engine: Engine);
  54768. /**
  54769. * renders one or more effects to a specified texture
  54770. * @param effectWrappers list of effects to renderer
  54771. * @param outputTexture texture to draw to, if null it will render to the screen
  54772. */
  54773. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54774. /**
  54775. * Disposes of the effect renderer
  54776. */
  54777. dispose(): void;
  54778. }
  54779. /**
  54780. * Options to create an EffectWrapper
  54781. */
  54782. interface EffectWrapperCreationOptions {
  54783. /**
  54784. * Engine to use to create the effect
  54785. */
  54786. engine: Engine;
  54787. /**
  54788. * Fragment shader for the effect
  54789. */
  54790. fragmentShader: string;
  54791. /**
  54792. * Attributes to use in the shader
  54793. */
  54794. attributeNames: Array<string>;
  54795. /**
  54796. * Uniforms to use in the shader
  54797. */
  54798. uniformNames: Array<string>;
  54799. /**
  54800. * Texture sampler names to use in the shader
  54801. */
  54802. samplerNames: Array<string>;
  54803. }
  54804. /**
  54805. * Wraps an effect to be used for rendering
  54806. */
  54807. export class EffectWrapper {
  54808. /**
  54809. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54810. */
  54811. onApplyObservable: Observable<{}>;
  54812. /**
  54813. * The underlying effect
  54814. */
  54815. effect: Effect;
  54816. /**
  54817. * Creates an effect to be renderer
  54818. * @param creationOptions options to create the effect
  54819. */
  54820. constructor(creationOptions: EffectWrapperCreationOptions);
  54821. /**
  54822. * Disposes of the effect wrapper
  54823. */
  54824. dispose(): void;
  54825. }
  54826. }
  54827. declare module "babylonjs/Materials/index" {
  54828. export * from "babylonjs/Materials/Background/index";
  54829. export * from "babylonjs/Materials/colorCurves";
  54830. export * from "babylonjs/Materials/effect";
  54831. export * from "babylonjs/Materials/fresnelParameters";
  54832. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54833. export * from "babylonjs/Materials/material";
  54834. export * from "babylonjs/Materials/materialDefines";
  54835. export * from "babylonjs/Materials/materialHelper";
  54836. export * from "babylonjs/Materials/multiMaterial";
  54837. export * from "babylonjs/Materials/PBR/index";
  54838. export * from "babylonjs/Materials/pushMaterial";
  54839. export * from "babylonjs/Materials/shaderMaterial";
  54840. export * from "babylonjs/Materials/standardMaterial";
  54841. export * from "babylonjs/Materials/Textures/index";
  54842. export * from "babylonjs/Materials/uniformBuffer";
  54843. export * from "babylonjs/Materials/materialFlags";
  54844. export * from "babylonjs/Materials/Node/index";
  54845. export * from "babylonjs/Materials/effectRenderer";
  54846. }
  54847. declare module "babylonjs/Maths/index" {
  54848. export * from "babylonjs/Maths/math.scalar";
  54849. export * from "babylonjs/Maths/math";
  54850. export * from "babylonjs/Maths/sphericalPolynomial";
  54851. }
  54852. declare module "babylonjs/Misc/workerPool" {
  54853. import { IDisposable } from "babylonjs/scene";
  54854. /**
  54855. * Helper class to push actions to a pool of workers.
  54856. */
  54857. export class WorkerPool implements IDisposable {
  54858. private _workerInfos;
  54859. private _pendingActions;
  54860. /**
  54861. * Constructor
  54862. * @param workers Array of workers to use for actions
  54863. */
  54864. constructor(workers: Array<Worker>);
  54865. /**
  54866. * Terminates all workers and clears any pending actions.
  54867. */
  54868. dispose(): void;
  54869. /**
  54870. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54871. * pended until a worker has completed its action.
  54872. * @param action The action to perform. Call onComplete when the action is complete.
  54873. */
  54874. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54875. private _execute;
  54876. }
  54877. }
  54878. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54879. import { IDisposable } from "babylonjs/scene";
  54880. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54881. /**
  54882. * Configuration for Draco compression
  54883. */
  54884. export interface IDracoCompressionConfiguration {
  54885. /**
  54886. * Configuration for the decoder.
  54887. */
  54888. decoder: {
  54889. /**
  54890. * The url to the WebAssembly module.
  54891. */
  54892. wasmUrl?: string;
  54893. /**
  54894. * The url to the WebAssembly binary.
  54895. */
  54896. wasmBinaryUrl?: string;
  54897. /**
  54898. * The url to the fallback JavaScript module.
  54899. */
  54900. fallbackUrl?: string;
  54901. };
  54902. }
  54903. /**
  54904. * Draco compression (https://google.github.io/draco/)
  54905. *
  54906. * This class wraps the Draco module.
  54907. *
  54908. * **Encoder**
  54909. *
  54910. * The encoder is not currently implemented.
  54911. *
  54912. * **Decoder**
  54913. *
  54914. * 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.
  54915. *
  54916. * To update the configuration, use the following code:
  54917. * ```javascript
  54918. * DracoCompression.Configuration = {
  54919. * decoder: {
  54920. * wasmUrl: "<url to the WebAssembly library>",
  54921. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54922. * fallbackUrl: "<url to the fallback JavaScript library>",
  54923. * }
  54924. * };
  54925. * ```
  54926. *
  54927. * 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.
  54928. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54929. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54930. *
  54931. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54932. * ```javascript
  54933. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54934. * ```
  54935. *
  54936. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54937. */
  54938. export class DracoCompression implements IDisposable {
  54939. private _workerPoolPromise?;
  54940. private _decoderModulePromise?;
  54941. /**
  54942. * The configuration. Defaults to the following urls:
  54943. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54944. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54945. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54946. */
  54947. static Configuration: IDracoCompressionConfiguration;
  54948. /**
  54949. * Returns true if the decoder configuration is available.
  54950. */
  54951. static readonly DecoderAvailable: boolean;
  54952. /**
  54953. * Default number of workers to create when creating the draco compression object.
  54954. */
  54955. static DefaultNumWorkers: number;
  54956. private static GetDefaultNumWorkers;
  54957. private static _Default;
  54958. /**
  54959. * Default instance for the draco compression object.
  54960. */
  54961. static readonly Default: DracoCompression;
  54962. /**
  54963. * Constructor
  54964. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54965. */
  54966. constructor(numWorkers?: number);
  54967. /**
  54968. * Stop all async operations and release resources.
  54969. */
  54970. dispose(): void;
  54971. /**
  54972. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54973. * @returns a promise that resolves when ready
  54974. */
  54975. whenReadyAsync(): Promise<void>;
  54976. /**
  54977. * Decode Draco compressed mesh data to vertex data.
  54978. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54979. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54980. * @returns A promise that resolves with the decoded vertex data
  54981. */
  54982. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54983. [kind: string]: number;
  54984. }): Promise<VertexData>;
  54985. }
  54986. }
  54987. declare module "babylonjs/Meshes/Compression/index" {
  54988. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54989. }
  54990. declare module "babylonjs/Meshes/csg" {
  54991. import { Nullable } from "babylonjs/types";
  54992. import { Scene } from "babylonjs/scene";
  54993. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54994. import { Mesh } from "babylonjs/Meshes/mesh";
  54995. import { Material } from "babylonjs/Materials/material";
  54996. /**
  54997. * Class for building Constructive Solid Geometry
  54998. */
  54999. export class CSG {
  55000. private polygons;
  55001. /**
  55002. * The world matrix
  55003. */
  55004. matrix: Matrix;
  55005. /**
  55006. * Stores the position
  55007. */
  55008. position: Vector3;
  55009. /**
  55010. * Stores the rotation
  55011. */
  55012. rotation: Vector3;
  55013. /**
  55014. * Stores the rotation quaternion
  55015. */
  55016. rotationQuaternion: Nullable<Quaternion>;
  55017. /**
  55018. * Stores the scaling vector
  55019. */
  55020. scaling: Vector3;
  55021. /**
  55022. * Convert the Mesh to CSG
  55023. * @param mesh The Mesh to convert to CSG
  55024. * @returns A new CSG from the Mesh
  55025. */
  55026. static FromMesh(mesh: Mesh): CSG;
  55027. /**
  55028. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55029. * @param polygons Polygons used to construct a CSG solid
  55030. */
  55031. private static FromPolygons;
  55032. /**
  55033. * Clones, or makes a deep copy, of the CSG
  55034. * @returns A new CSG
  55035. */
  55036. clone(): CSG;
  55037. /**
  55038. * Unions this CSG with another CSG
  55039. * @param csg The CSG to union against this CSG
  55040. * @returns The unioned CSG
  55041. */
  55042. union(csg: CSG): CSG;
  55043. /**
  55044. * Unions this CSG with another CSG in place
  55045. * @param csg The CSG to union against this CSG
  55046. */
  55047. unionInPlace(csg: CSG): void;
  55048. /**
  55049. * Subtracts this CSG with another CSG
  55050. * @param csg The CSG to subtract against this CSG
  55051. * @returns A new CSG
  55052. */
  55053. subtract(csg: CSG): CSG;
  55054. /**
  55055. * Subtracts this CSG with another CSG in place
  55056. * @param csg The CSG to subtact against this CSG
  55057. */
  55058. subtractInPlace(csg: CSG): void;
  55059. /**
  55060. * Intersect this CSG with another CSG
  55061. * @param csg The CSG to intersect against this CSG
  55062. * @returns A new CSG
  55063. */
  55064. intersect(csg: CSG): CSG;
  55065. /**
  55066. * Intersects this CSG with another CSG in place
  55067. * @param csg The CSG to intersect against this CSG
  55068. */
  55069. intersectInPlace(csg: CSG): void;
  55070. /**
  55071. * Return a new CSG solid with solid and empty space switched. This solid is
  55072. * not modified.
  55073. * @returns A new CSG solid with solid and empty space switched
  55074. */
  55075. inverse(): CSG;
  55076. /**
  55077. * Inverses the CSG in place
  55078. */
  55079. inverseInPlace(): void;
  55080. /**
  55081. * This is used to keep meshes transformations so they can be restored
  55082. * when we build back a Babylon Mesh
  55083. * NB : All CSG operations are performed in world coordinates
  55084. * @param csg The CSG to copy the transform attributes from
  55085. * @returns This CSG
  55086. */
  55087. copyTransformAttributes(csg: CSG): CSG;
  55088. /**
  55089. * Build Raw mesh from CSG
  55090. * Coordinates here are in world space
  55091. * @param name The name of the mesh geometry
  55092. * @param scene The Scene
  55093. * @param keepSubMeshes Specifies if the submeshes should be kept
  55094. * @returns A new Mesh
  55095. */
  55096. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55097. /**
  55098. * Build Mesh from CSG taking material and transforms into account
  55099. * @param name The name of the Mesh
  55100. * @param material The material of the Mesh
  55101. * @param scene The Scene
  55102. * @param keepSubMeshes Specifies if submeshes should be kept
  55103. * @returns The new Mesh
  55104. */
  55105. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55106. }
  55107. }
  55108. declare module "babylonjs/Meshes/trailMesh" {
  55109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55110. import { Mesh } from "babylonjs/Meshes/mesh";
  55111. import { Scene } from "babylonjs/scene";
  55112. /**
  55113. * Class used to create a trail following a mesh
  55114. */
  55115. export class TrailMesh extends Mesh {
  55116. private _generator;
  55117. private _autoStart;
  55118. private _running;
  55119. private _diameter;
  55120. private _length;
  55121. private _sectionPolygonPointsCount;
  55122. private _sectionVectors;
  55123. private _sectionNormalVectors;
  55124. private _beforeRenderObserver;
  55125. /**
  55126. * @constructor
  55127. * @param name The value used by scene.getMeshByName() to do a lookup.
  55128. * @param generator The mesh to generate a trail.
  55129. * @param scene The scene to add this mesh to.
  55130. * @param diameter Diameter of trailing mesh. Default is 1.
  55131. * @param length Length of trailing mesh. Default is 60.
  55132. * @param autoStart Automatically start trailing mesh. Default true.
  55133. */
  55134. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55135. /**
  55136. * "TrailMesh"
  55137. * @returns "TrailMesh"
  55138. */
  55139. getClassName(): string;
  55140. private _createMesh;
  55141. /**
  55142. * Start trailing mesh.
  55143. */
  55144. start(): void;
  55145. /**
  55146. * Stop trailing mesh.
  55147. */
  55148. stop(): void;
  55149. /**
  55150. * Update trailing mesh geometry.
  55151. */
  55152. update(): void;
  55153. /**
  55154. * Returns a new TrailMesh object.
  55155. * @param name is a string, the name given to the new mesh
  55156. * @param newGenerator use new generator object for cloned trail mesh
  55157. * @returns a new mesh
  55158. */
  55159. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55160. /**
  55161. * Serializes this trail mesh
  55162. * @param serializationObject object to write serialization to
  55163. */
  55164. serialize(serializationObject: any): void;
  55165. /**
  55166. * Parses a serialized trail mesh
  55167. * @param parsedMesh the serialized mesh
  55168. * @param scene the scene to create the trail mesh in
  55169. * @returns the created trail mesh
  55170. */
  55171. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55172. }
  55173. }
  55174. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55175. import { Nullable } from "babylonjs/types";
  55176. import { Scene } from "babylonjs/scene";
  55177. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55178. import { Mesh } from "babylonjs/Meshes/mesh";
  55179. /**
  55180. * Class containing static functions to help procedurally build meshes
  55181. */
  55182. export class TiledBoxBuilder {
  55183. /**
  55184. * Creates a box mesh
  55185. * 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)
  55186. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55190. * @param name defines the name of the mesh
  55191. * @param options defines the options used to create the mesh
  55192. * @param scene defines the hosting scene
  55193. * @returns the box mesh
  55194. */
  55195. static CreateTiledBox(name: string, options: {
  55196. pattern?: number;
  55197. width?: number;
  55198. height?: number;
  55199. depth?: number;
  55200. tileSize?: number;
  55201. tileWidth?: number;
  55202. tileHeight?: number;
  55203. alignHorizontal?: number;
  55204. alignVertical?: number;
  55205. faceUV?: Vector4[];
  55206. faceColors?: Color4[];
  55207. sideOrientation?: number;
  55208. updatable?: boolean;
  55209. }, scene?: Nullable<Scene>): Mesh;
  55210. }
  55211. }
  55212. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55213. import { Vector4 } from "babylonjs/Maths/math";
  55214. import { Mesh } from "babylonjs/Meshes/mesh";
  55215. /**
  55216. * Class containing static functions to help procedurally build meshes
  55217. */
  55218. export class TorusKnotBuilder {
  55219. /**
  55220. * Creates a torus knot mesh
  55221. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55222. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55223. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55224. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55228. * @param name defines the name of the mesh
  55229. * @param options defines the options used to create the mesh
  55230. * @param scene defines the hosting scene
  55231. * @returns the torus knot mesh
  55232. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55233. */
  55234. static CreateTorusKnot(name: string, options: {
  55235. radius?: number;
  55236. tube?: number;
  55237. radialSegments?: number;
  55238. tubularSegments?: number;
  55239. p?: number;
  55240. q?: number;
  55241. updatable?: boolean;
  55242. sideOrientation?: number;
  55243. frontUVs?: Vector4;
  55244. backUVs?: Vector4;
  55245. }, scene: any): Mesh;
  55246. }
  55247. }
  55248. declare module "babylonjs/Meshes/polygonMesh" {
  55249. import { Scene } from "babylonjs/scene";
  55250. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55251. import { Mesh } from "babylonjs/Meshes/mesh";
  55252. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55253. /**
  55254. * Polygon
  55255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55256. */
  55257. export class Polygon {
  55258. /**
  55259. * Creates a rectangle
  55260. * @param xmin bottom X coord
  55261. * @param ymin bottom Y coord
  55262. * @param xmax top X coord
  55263. * @param ymax top Y coord
  55264. * @returns points that make the resulting rectation
  55265. */
  55266. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55267. /**
  55268. * Creates a circle
  55269. * @param radius radius of circle
  55270. * @param cx scale in x
  55271. * @param cy scale in y
  55272. * @param numberOfSides number of sides that make up the circle
  55273. * @returns points that make the resulting circle
  55274. */
  55275. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55276. /**
  55277. * Creates a polygon from input string
  55278. * @param input Input polygon data
  55279. * @returns the parsed points
  55280. */
  55281. static Parse(input: string): Vector2[];
  55282. /**
  55283. * Starts building a polygon from x and y coordinates
  55284. * @param x x coordinate
  55285. * @param y y coordinate
  55286. * @returns the started path2
  55287. */
  55288. static StartingAt(x: number, y: number): Path2;
  55289. }
  55290. /**
  55291. * Builds a polygon
  55292. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55293. */
  55294. export class PolygonMeshBuilder {
  55295. private _points;
  55296. private _outlinepoints;
  55297. private _holes;
  55298. private _name;
  55299. private _scene;
  55300. private _epoints;
  55301. private _eholes;
  55302. private _addToepoint;
  55303. /**
  55304. * Babylon reference to the earcut plugin.
  55305. */
  55306. bjsEarcut: any;
  55307. /**
  55308. * Creates a PolygonMeshBuilder
  55309. * @param name name of the builder
  55310. * @param contours Path of the polygon
  55311. * @param scene scene to add to when creating the mesh
  55312. * @param earcutInjection can be used to inject your own earcut reference
  55313. */
  55314. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55315. /**
  55316. * Adds a whole within the polygon
  55317. * @param hole Array of points defining the hole
  55318. * @returns this
  55319. */
  55320. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55321. /**
  55322. * Creates the polygon
  55323. * @param updatable If the mesh should be updatable
  55324. * @param depth The depth of the mesh created
  55325. * @returns the created mesh
  55326. */
  55327. build(updatable?: boolean, depth?: number): Mesh;
  55328. /**
  55329. * Creates the polygon
  55330. * @param depth The depth of the mesh created
  55331. * @returns the created VertexData
  55332. */
  55333. buildVertexData(depth?: number): VertexData;
  55334. /**
  55335. * Adds a side to the polygon
  55336. * @param positions points that make the polygon
  55337. * @param normals normals of the polygon
  55338. * @param uvs uvs of the polygon
  55339. * @param indices indices of the polygon
  55340. * @param bounds bounds of the polygon
  55341. * @param points points of the polygon
  55342. * @param depth depth of the polygon
  55343. * @param flip flip of the polygon
  55344. */
  55345. private addSide;
  55346. }
  55347. }
  55348. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55349. import { Scene } from "babylonjs/scene";
  55350. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55351. import { Mesh } from "babylonjs/Meshes/mesh";
  55352. import { Nullable } from "babylonjs/types";
  55353. /**
  55354. * Class containing static functions to help procedurally build meshes
  55355. */
  55356. export class PolygonBuilder {
  55357. /**
  55358. * Creates a polygon mesh
  55359. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55360. * * 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
  55361. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55364. * * Remember you can only change the shape positions, not their number when updating a polygon
  55365. * @param name defines the name of the mesh
  55366. * @param options defines the options used to create the mesh
  55367. * @param scene defines the hosting scene
  55368. * @param earcutInjection can be used to inject your own earcut reference
  55369. * @returns the polygon mesh
  55370. */
  55371. static CreatePolygon(name: string, options: {
  55372. shape: Vector3[];
  55373. holes?: Vector3[][];
  55374. depth?: number;
  55375. faceUV?: Vector4[];
  55376. faceColors?: Color4[];
  55377. updatable?: boolean;
  55378. sideOrientation?: number;
  55379. frontUVs?: Vector4;
  55380. backUVs?: Vector4;
  55381. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55382. /**
  55383. * Creates an extruded polygon mesh, with depth in the Y direction.
  55384. * * 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)
  55385. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55386. * @param name defines the name of the mesh
  55387. * @param options defines the options used to create the mesh
  55388. * @param scene defines the hosting scene
  55389. * @param earcutInjection can be used to inject your own earcut reference
  55390. * @returns the polygon mesh
  55391. */
  55392. static ExtrudePolygon(name: string, options: {
  55393. shape: Vector3[];
  55394. holes?: Vector3[][];
  55395. depth?: number;
  55396. faceUV?: Vector4[];
  55397. faceColors?: Color4[];
  55398. updatable?: boolean;
  55399. sideOrientation?: number;
  55400. frontUVs?: Vector4;
  55401. backUVs?: Vector4;
  55402. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55403. }
  55404. }
  55405. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55406. import { Scene } from "babylonjs/scene";
  55407. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55408. import { Mesh } from "babylonjs/Meshes/mesh";
  55409. import { Nullable } from "babylonjs/types";
  55410. /**
  55411. * Class containing static functions to help procedurally build meshes
  55412. */
  55413. export class LatheBuilder {
  55414. /**
  55415. * Creates lathe mesh.
  55416. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55417. * * 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
  55418. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55419. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55420. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55421. * * 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
  55422. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55423. * * 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
  55424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55428. * @param name defines the name of the mesh
  55429. * @param options defines the options used to create the mesh
  55430. * @param scene defines the hosting scene
  55431. * @returns the lathe mesh
  55432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55433. */
  55434. static CreateLathe(name: string, options: {
  55435. shape: Vector3[];
  55436. radius?: number;
  55437. tessellation?: number;
  55438. clip?: number;
  55439. arc?: number;
  55440. closed?: boolean;
  55441. updatable?: boolean;
  55442. sideOrientation?: number;
  55443. frontUVs?: Vector4;
  55444. backUVs?: Vector4;
  55445. cap?: number;
  55446. invertUV?: boolean;
  55447. }, scene?: Nullable<Scene>): Mesh;
  55448. }
  55449. }
  55450. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55451. import { Nullable } from "babylonjs/types";
  55452. import { Scene } from "babylonjs/scene";
  55453. import { Vector4 } from "babylonjs/Maths/math";
  55454. import { Mesh } from "babylonjs/Meshes/mesh";
  55455. /**
  55456. * Class containing static functions to help procedurally build meshes
  55457. */
  55458. export class TiledPlaneBuilder {
  55459. /**
  55460. * Creates a tiled plane mesh
  55461. * * The parameter `pattern` will, depending on value, do nothing or
  55462. * * * flip (reflect about central vertical) alternate tiles across and up
  55463. * * * flip every tile on alternate rows
  55464. * * * rotate (180 degs) alternate tiles across and up
  55465. * * * rotate every tile on alternate rows
  55466. * * * flip and rotate alternate tiles across and up
  55467. * * * flip and rotate every tile on alternate rows
  55468. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55469. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55472. * * 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)
  55473. * * 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)
  55474. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55475. * @param name defines the name of the mesh
  55476. * @param options defines the options used to create the mesh
  55477. * @param scene defines the hosting scene
  55478. * @returns the box mesh
  55479. */
  55480. static CreateTiledPlane(name: string, options: {
  55481. pattern?: number;
  55482. tileSize?: number;
  55483. tileWidth?: number;
  55484. tileHeight?: number;
  55485. size?: number;
  55486. width?: number;
  55487. height?: number;
  55488. alignHorizontal?: number;
  55489. alignVertical?: number;
  55490. sideOrientation?: number;
  55491. frontUVs?: Vector4;
  55492. backUVs?: Vector4;
  55493. updatable?: boolean;
  55494. }, scene?: Nullable<Scene>): Mesh;
  55495. }
  55496. }
  55497. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55498. import { Nullable } from "babylonjs/types";
  55499. import { Scene } from "babylonjs/scene";
  55500. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55501. import { Mesh } from "babylonjs/Meshes/mesh";
  55502. /**
  55503. * Class containing static functions to help procedurally build meshes
  55504. */
  55505. export class TubeBuilder {
  55506. /**
  55507. * Creates a tube mesh.
  55508. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55509. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55510. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55511. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55512. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55513. * * 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)
  55514. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55515. * * 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
  55516. * * 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
  55517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55521. * @param name defines the name of the mesh
  55522. * @param options defines the options used to create the mesh
  55523. * @param scene defines the hosting scene
  55524. * @returns the tube mesh
  55525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55526. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55527. */
  55528. static CreateTube(name: string, options: {
  55529. path: Vector3[];
  55530. radius?: number;
  55531. tessellation?: number;
  55532. radiusFunction?: {
  55533. (i: number, distance: number): number;
  55534. };
  55535. cap?: number;
  55536. arc?: number;
  55537. updatable?: boolean;
  55538. sideOrientation?: number;
  55539. frontUVs?: Vector4;
  55540. backUVs?: Vector4;
  55541. instance?: Mesh;
  55542. invertUV?: boolean;
  55543. }, scene?: Nullable<Scene>): Mesh;
  55544. }
  55545. }
  55546. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55547. import { Scene } from "babylonjs/scene";
  55548. import { Vector4 } from "babylonjs/Maths/math";
  55549. import { Mesh } from "babylonjs/Meshes/mesh";
  55550. import { Nullable } from "babylonjs/types";
  55551. /**
  55552. * Class containing static functions to help procedurally build meshes
  55553. */
  55554. export class IcoSphereBuilder {
  55555. /**
  55556. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55557. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55558. * * 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`)
  55559. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55560. * * 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
  55561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55564. * @param name defines the name of the mesh
  55565. * @param options defines the options used to create the mesh
  55566. * @param scene defines the hosting scene
  55567. * @returns the icosahedron mesh
  55568. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55569. */
  55570. static CreateIcoSphere(name: string, options: {
  55571. radius?: number;
  55572. radiusX?: number;
  55573. radiusY?: number;
  55574. radiusZ?: number;
  55575. flat?: boolean;
  55576. subdivisions?: number;
  55577. sideOrientation?: number;
  55578. frontUVs?: Vector4;
  55579. backUVs?: Vector4;
  55580. updatable?: boolean;
  55581. }, scene?: Nullable<Scene>): Mesh;
  55582. }
  55583. }
  55584. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55585. import { Vector3 } from "babylonjs/Maths/math";
  55586. import { Mesh } from "babylonjs/Meshes/mesh";
  55587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55588. /**
  55589. * Class containing static functions to help procedurally build meshes
  55590. */
  55591. export class DecalBuilder {
  55592. /**
  55593. * Creates a decal mesh.
  55594. * 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
  55595. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55596. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55597. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55598. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55599. * @param name defines the name of the mesh
  55600. * @param sourceMesh defines the mesh where the decal must be applied
  55601. * @param options defines the options used to create the mesh
  55602. * @param scene defines the hosting scene
  55603. * @returns the decal mesh
  55604. * @see https://doc.babylonjs.com/how_to/decals
  55605. */
  55606. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55607. position?: Vector3;
  55608. normal?: Vector3;
  55609. size?: Vector3;
  55610. angle?: number;
  55611. }): Mesh;
  55612. }
  55613. }
  55614. declare module "babylonjs/Meshes/meshBuilder" {
  55615. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55616. import { Nullable } from "babylonjs/types";
  55617. import { Scene } from "babylonjs/scene";
  55618. import { Mesh } from "babylonjs/Meshes/mesh";
  55619. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55620. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55622. /**
  55623. * Class containing static functions to help procedurally build meshes
  55624. */
  55625. export class MeshBuilder {
  55626. /**
  55627. * Creates a box mesh
  55628. * * The parameter `size` sets the size (float) of each box side (default 1)
  55629. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55630. * * 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)
  55631. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55635. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55636. * @param name defines the name of the mesh
  55637. * @param options defines the options used to create the mesh
  55638. * @param scene defines the hosting scene
  55639. * @returns the box mesh
  55640. */
  55641. static CreateBox(name: string, options: {
  55642. size?: number;
  55643. width?: number;
  55644. height?: number;
  55645. depth?: number;
  55646. faceUV?: Vector4[];
  55647. faceColors?: Color4[];
  55648. sideOrientation?: number;
  55649. frontUVs?: Vector4;
  55650. backUVs?: Vector4;
  55651. updatable?: boolean;
  55652. }, scene?: Nullable<Scene>): Mesh;
  55653. /**
  55654. * Creates a tiled box mesh
  55655. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55657. * @param name defines the name of the mesh
  55658. * @param options defines the options used to create the mesh
  55659. * @param scene defines the hosting scene
  55660. * @returns the tiled box mesh
  55661. */
  55662. static CreateTiledBox(name: string, options: {
  55663. pattern?: number;
  55664. size?: number;
  55665. width?: number;
  55666. height?: number;
  55667. depth: number;
  55668. tileSize?: number;
  55669. tileWidth?: number;
  55670. tileHeight?: number;
  55671. faceUV?: Vector4[];
  55672. faceColors?: Color4[];
  55673. alignHorizontal?: number;
  55674. alignVertical?: number;
  55675. sideOrientation?: number;
  55676. updatable?: boolean;
  55677. }, scene?: Nullable<Scene>): Mesh;
  55678. /**
  55679. * Creates a sphere mesh
  55680. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55681. * * 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`)
  55682. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55683. * * 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
  55684. * * 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)
  55685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55688. * @param name defines the name of the mesh
  55689. * @param options defines the options used to create the mesh
  55690. * @param scene defines the hosting scene
  55691. * @returns the sphere mesh
  55692. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55693. */
  55694. static CreateSphere(name: string, options: {
  55695. segments?: number;
  55696. diameter?: number;
  55697. diameterX?: number;
  55698. diameterY?: number;
  55699. diameterZ?: number;
  55700. arc?: number;
  55701. slice?: number;
  55702. sideOrientation?: number;
  55703. frontUVs?: Vector4;
  55704. backUVs?: Vector4;
  55705. updatable?: boolean;
  55706. }, scene?: Nullable<Scene>): Mesh;
  55707. /**
  55708. * Creates a plane polygonal mesh. By default, this is a disc
  55709. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55710. * * 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
  55711. * * 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
  55712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55715. * @param name defines the name of the mesh
  55716. * @param options defines the options used to create the mesh
  55717. * @param scene defines the hosting scene
  55718. * @returns the plane polygonal mesh
  55719. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55720. */
  55721. static CreateDisc(name: string, options: {
  55722. radius?: number;
  55723. tessellation?: number;
  55724. arc?: number;
  55725. updatable?: boolean;
  55726. sideOrientation?: number;
  55727. frontUVs?: Vector4;
  55728. backUVs?: Vector4;
  55729. }, scene?: Nullable<Scene>): Mesh;
  55730. /**
  55731. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55732. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55733. * * 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`)
  55734. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55735. * * 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
  55736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55739. * @param name defines the name of the mesh
  55740. * @param options defines the options used to create the mesh
  55741. * @param scene defines the hosting scene
  55742. * @returns the icosahedron mesh
  55743. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55744. */
  55745. static CreateIcoSphere(name: string, options: {
  55746. radius?: number;
  55747. radiusX?: number;
  55748. radiusY?: number;
  55749. radiusZ?: number;
  55750. flat?: boolean;
  55751. subdivisions?: number;
  55752. sideOrientation?: number;
  55753. frontUVs?: Vector4;
  55754. backUVs?: Vector4;
  55755. updatable?: boolean;
  55756. }, scene?: Nullable<Scene>): Mesh;
  55757. /**
  55758. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55759. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55760. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55761. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55762. * * 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
  55763. * * 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
  55764. * * 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
  55765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55768. * * 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
  55769. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55770. * * 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
  55771. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55773. * @param name defines the name of the mesh
  55774. * @param options defines the options used to create the mesh
  55775. * @param scene defines the hosting scene
  55776. * @returns the ribbon mesh
  55777. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55779. */
  55780. static CreateRibbon(name: string, options: {
  55781. pathArray: Vector3[][];
  55782. closeArray?: boolean;
  55783. closePath?: boolean;
  55784. offset?: number;
  55785. updatable?: boolean;
  55786. sideOrientation?: number;
  55787. frontUVs?: Vector4;
  55788. backUVs?: Vector4;
  55789. instance?: Mesh;
  55790. invertUV?: boolean;
  55791. uvs?: Vector2[];
  55792. colors?: Color4[];
  55793. }, scene?: Nullable<Scene>): Mesh;
  55794. /**
  55795. * Creates a cylinder or a cone mesh
  55796. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55797. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55798. * * 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.
  55799. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55800. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55801. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55802. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55803. * * 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).
  55804. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55805. * * 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).
  55806. * * 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
  55807. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55808. * * 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
  55809. * * 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.
  55810. * * If `enclose` is false, a ring surface is one element.
  55811. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55812. * * 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
  55813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55816. * @param name defines the name of the mesh
  55817. * @param options defines the options used to create the mesh
  55818. * @param scene defines the hosting scene
  55819. * @returns the cylinder mesh
  55820. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55821. */
  55822. static CreateCylinder(name: string, options: {
  55823. height?: number;
  55824. diameterTop?: number;
  55825. diameterBottom?: number;
  55826. diameter?: number;
  55827. tessellation?: number;
  55828. subdivisions?: number;
  55829. arc?: number;
  55830. faceColors?: Color4[];
  55831. faceUV?: Vector4[];
  55832. updatable?: boolean;
  55833. hasRings?: boolean;
  55834. enclose?: boolean;
  55835. cap?: number;
  55836. sideOrientation?: number;
  55837. frontUVs?: Vector4;
  55838. backUVs?: Vector4;
  55839. }, scene?: Nullable<Scene>): Mesh;
  55840. /**
  55841. * Creates a torus mesh
  55842. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55843. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55844. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55848. * @param name defines the name of the mesh
  55849. * @param options defines the options used to create the mesh
  55850. * @param scene defines the hosting scene
  55851. * @returns the torus mesh
  55852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55853. */
  55854. static CreateTorus(name: string, options: {
  55855. diameter?: number;
  55856. thickness?: number;
  55857. tessellation?: number;
  55858. updatable?: boolean;
  55859. sideOrientation?: number;
  55860. frontUVs?: Vector4;
  55861. backUVs?: Vector4;
  55862. }, scene?: Nullable<Scene>): Mesh;
  55863. /**
  55864. * Creates a torus knot mesh
  55865. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55866. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55867. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55868. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55872. * @param name defines the name of the mesh
  55873. * @param options defines the options used to create the mesh
  55874. * @param scene defines the hosting scene
  55875. * @returns the torus knot mesh
  55876. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55877. */
  55878. static CreateTorusKnot(name: string, options: {
  55879. radius?: number;
  55880. tube?: number;
  55881. radialSegments?: number;
  55882. tubularSegments?: number;
  55883. p?: number;
  55884. q?: number;
  55885. updatable?: boolean;
  55886. sideOrientation?: number;
  55887. frontUVs?: Vector4;
  55888. backUVs?: Vector4;
  55889. }, scene?: Nullable<Scene>): Mesh;
  55890. /**
  55891. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55892. * * 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
  55893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55894. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55895. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55896. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55898. * * 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
  55899. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55902. * @param name defines the name of the new line system
  55903. * @param options defines the options used to create the line system
  55904. * @param scene defines the hosting scene
  55905. * @returns a new line system mesh
  55906. */
  55907. static CreateLineSystem(name: string, options: {
  55908. lines: Vector3[][];
  55909. updatable?: boolean;
  55910. instance?: Nullable<LinesMesh>;
  55911. colors?: Nullable<Color4[][]>;
  55912. useVertexAlpha?: boolean;
  55913. }, scene: Nullable<Scene>): LinesMesh;
  55914. /**
  55915. * Creates a line mesh
  55916. * 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
  55917. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55918. * * The parameter `points` is an array successive Vector3
  55919. * * 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
  55920. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55921. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55922. * * When updating an instance, remember that only point positions can change, not the number of points
  55923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55925. * @param name defines the name of the new line system
  55926. * @param options defines the options used to create the line system
  55927. * @param scene defines the hosting scene
  55928. * @returns a new line mesh
  55929. */
  55930. static CreateLines(name: string, options: {
  55931. points: Vector3[];
  55932. updatable?: boolean;
  55933. instance?: Nullable<LinesMesh>;
  55934. colors?: Color4[];
  55935. useVertexAlpha?: boolean;
  55936. }, scene?: Nullable<Scene>): LinesMesh;
  55937. /**
  55938. * Creates a dashed line mesh
  55939. * * 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
  55940. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55941. * * The parameter `points` is an array successive Vector3
  55942. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55943. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55944. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55945. * * 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
  55946. * * When updating an instance, remember that only point positions can change, not the number of points
  55947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55948. * @param name defines the name of the mesh
  55949. * @param options defines the options used to create the mesh
  55950. * @param scene defines the hosting scene
  55951. * @returns the dashed line mesh
  55952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55953. */
  55954. static CreateDashedLines(name: string, options: {
  55955. points: Vector3[];
  55956. dashSize?: number;
  55957. gapSize?: number;
  55958. dashNb?: number;
  55959. updatable?: boolean;
  55960. instance?: LinesMesh;
  55961. }, scene?: Nullable<Scene>): LinesMesh;
  55962. /**
  55963. * 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.
  55964. * * 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.
  55965. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55966. * * 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.
  55967. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55968. * * 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
  55969. * * 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
  55970. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55971. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55972. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55973. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55975. * @param name defines the name of the mesh
  55976. * @param options defines the options used to create the mesh
  55977. * @param scene defines the hosting scene
  55978. * @returns the extruded shape mesh
  55979. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55981. */
  55982. static ExtrudeShape(name: string, options: {
  55983. shape: Vector3[];
  55984. path: Vector3[];
  55985. scale?: number;
  55986. rotation?: number;
  55987. cap?: number;
  55988. updatable?: boolean;
  55989. sideOrientation?: number;
  55990. frontUVs?: Vector4;
  55991. backUVs?: Vector4;
  55992. instance?: Mesh;
  55993. invertUV?: boolean;
  55994. }, scene?: Nullable<Scene>): Mesh;
  55995. /**
  55996. * Creates an custom extruded shape mesh.
  55997. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55998. * * 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.
  55999. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56000. * * 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
  56001. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56002. * * 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
  56003. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56004. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56005. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56006. * * 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
  56007. * * 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
  56008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56013. * @param name defines the name of the mesh
  56014. * @param options defines the options used to create the mesh
  56015. * @param scene defines the hosting scene
  56016. * @returns the custom extruded shape mesh
  56017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56020. */
  56021. static ExtrudeShapeCustom(name: string, options: {
  56022. shape: Vector3[];
  56023. path: Vector3[];
  56024. scaleFunction?: any;
  56025. rotationFunction?: any;
  56026. ribbonCloseArray?: boolean;
  56027. ribbonClosePath?: boolean;
  56028. cap?: number;
  56029. updatable?: boolean;
  56030. sideOrientation?: number;
  56031. frontUVs?: Vector4;
  56032. backUVs?: Vector4;
  56033. instance?: Mesh;
  56034. invertUV?: boolean;
  56035. }, scene?: Nullable<Scene>): Mesh;
  56036. /**
  56037. * Creates lathe mesh.
  56038. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56039. * * 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
  56040. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56041. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56042. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56043. * * 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
  56044. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56045. * * 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
  56046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56050. * @param name defines the name of the mesh
  56051. * @param options defines the options used to create the mesh
  56052. * @param scene defines the hosting scene
  56053. * @returns the lathe mesh
  56054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56055. */
  56056. static CreateLathe(name: string, options: {
  56057. shape: Vector3[];
  56058. radius?: number;
  56059. tessellation?: number;
  56060. clip?: number;
  56061. arc?: number;
  56062. closed?: boolean;
  56063. updatable?: boolean;
  56064. sideOrientation?: number;
  56065. frontUVs?: Vector4;
  56066. backUVs?: Vector4;
  56067. cap?: number;
  56068. invertUV?: boolean;
  56069. }, scene?: Nullable<Scene>): Mesh;
  56070. /**
  56071. * Creates a tiled plane mesh
  56072. * * You can set a limited pattern arrangement with the tiles
  56073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56074. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56076. * @param name defines the name of the mesh
  56077. * @param options defines the options used to create the mesh
  56078. * @param scene defines the hosting scene
  56079. * @returns the plane mesh
  56080. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56081. */
  56082. static CreateTiledPlane(name: string, options: {
  56083. pattern?: number;
  56084. tileSize?: number;
  56085. tileWidth?: number;
  56086. tileHeight?: number;
  56087. size?: number;
  56088. width?: number;
  56089. height?: number;
  56090. alignHorizontal?: number;
  56091. alignVertical?: number;
  56092. sideOrientation?: number;
  56093. frontUVs?: Vector4;
  56094. backUVs?: Vector4;
  56095. updatable?: boolean;
  56096. }, scene?: Nullable<Scene>): Mesh;
  56097. /**
  56098. * Creates a plane mesh
  56099. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56100. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56101. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56105. * @param name defines the name of the mesh
  56106. * @param options defines the options used to create the mesh
  56107. * @param scene defines the hosting scene
  56108. * @returns the plane mesh
  56109. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56110. */
  56111. static CreatePlane(name: string, options: {
  56112. size?: number;
  56113. width?: number;
  56114. height?: number;
  56115. sideOrientation?: number;
  56116. frontUVs?: Vector4;
  56117. backUVs?: Vector4;
  56118. updatable?: boolean;
  56119. sourcePlane?: Plane;
  56120. }, scene?: Nullable<Scene>): Mesh;
  56121. /**
  56122. * Creates a ground mesh
  56123. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56124. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56126. * @param name defines the name of the mesh
  56127. * @param options defines the options used to create the mesh
  56128. * @param scene defines the hosting scene
  56129. * @returns the ground mesh
  56130. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56131. */
  56132. static CreateGround(name: string, options: {
  56133. width?: number;
  56134. height?: number;
  56135. subdivisions?: number;
  56136. subdivisionsX?: number;
  56137. subdivisionsY?: number;
  56138. updatable?: boolean;
  56139. }, scene?: Nullable<Scene>): Mesh;
  56140. /**
  56141. * Creates a tiled ground mesh
  56142. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56143. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56144. * * 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
  56145. * * 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
  56146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56147. * @param name defines the name of the mesh
  56148. * @param options defines the options used to create the mesh
  56149. * @param scene defines the hosting scene
  56150. * @returns the tiled ground mesh
  56151. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56152. */
  56153. static CreateTiledGround(name: string, options: {
  56154. xmin: number;
  56155. zmin: number;
  56156. xmax: number;
  56157. zmax: number;
  56158. subdivisions?: {
  56159. w: number;
  56160. h: number;
  56161. };
  56162. precision?: {
  56163. w: number;
  56164. h: number;
  56165. };
  56166. updatable?: boolean;
  56167. }, scene?: Nullable<Scene>): Mesh;
  56168. /**
  56169. * Creates a ground mesh from a height map
  56170. * * The parameter `url` sets the URL of the height map image resource.
  56171. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56172. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56173. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56174. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56175. * * 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.
  56176. * * 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).
  56177. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56179. * @param name defines the name of the mesh
  56180. * @param url defines the url to the height map
  56181. * @param options defines the options used to create the mesh
  56182. * @param scene defines the hosting scene
  56183. * @returns the ground mesh
  56184. * @see https://doc.babylonjs.com/babylon101/height_map
  56185. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56186. */
  56187. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56188. width?: number;
  56189. height?: number;
  56190. subdivisions?: number;
  56191. minHeight?: number;
  56192. maxHeight?: number;
  56193. colorFilter?: Color3;
  56194. alphaFilter?: number;
  56195. updatable?: boolean;
  56196. onReady?: (mesh: GroundMesh) => void;
  56197. }, scene?: Nullable<Scene>): GroundMesh;
  56198. /**
  56199. * Creates a polygon mesh
  56200. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56201. * * 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
  56202. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56205. * * Remember you can only change the shape positions, not their number when updating a polygon
  56206. * @param name defines the name of the mesh
  56207. * @param options defines the options used to create the mesh
  56208. * @param scene defines the hosting scene
  56209. * @param earcutInjection can be used to inject your own earcut reference
  56210. * @returns the polygon mesh
  56211. */
  56212. static CreatePolygon(name: string, options: {
  56213. shape: Vector3[];
  56214. holes?: Vector3[][];
  56215. depth?: number;
  56216. faceUV?: Vector4[];
  56217. faceColors?: Color4[];
  56218. updatable?: boolean;
  56219. sideOrientation?: number;
  56220. frontUVs?: Vector4;
  56221. backUVs?: Vector4;
  56222. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56223. /**
  56224. * Creates an extruded polygon mesh, with depth in the Y direction.
  56225. * * 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)
  56226. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56227. * @param name defines the name of the mesh
  56228. * @param options defines the options used to create the mesh
  56229. * @param scene defines the hosting scene
  56230. * @param earcutInjection can be used to inject your own earcut reference
  56231. * @returns the polygon mesh
  56232. */
  56233. static ExtrudePolygon(name: string, options: {
  56234. shape: Vector3[];
  56235. holes?: Vector3[][];
  56236. depth?: number;
  56237. faceUV?: Vector4[];
  56238. faceColors?: Color4[];
  56239. updatable?: boolean;
  56240. sideOrientation?: number;
  56241. frontUVs?: Vector4;
  56242. backUVs?: Vector4;
  56243. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56244. /**
  56245. * Creates a tube mesh.
  56246. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56247. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56248. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56249. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56250. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56251. * * 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)
  56252. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56253. * * 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
  56254. * * 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
  56255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56259. * @param name defines the name of the mesh
  56260. * @param options defines the options used to create the mesh
  56261. * @param scene defines the hosting scene
  56262. * @returns the tube mesh
  56263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56264. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56265. */
  56266. static CreateTube(name: string, options: {
  56267. path: Vector3[];
  56268. radius?: number;
  56269. tessellation?: number;
  56270. radiusFunction?: {
  56271. (i: number, distance: number): number;
  56272. };
  56273. cap?: number;
  56274. arc?: number;
  56275. updatable?: boolean;
  56276. sideOrientation?: number;
  56277. frontUVs?: Vector4;
  56278. backUVs?: Vector4;
  56279. instance?: Mesh;
  56280. invertUV?: boolean;
  56281. }, scene?: Nullable<Scene>): Mesh;
  56282. /**
  56283. * Creates a polyhedron mesh
  56284. * * 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
  56285. * * The parameter `size` (positive float, default 1) sets the polygon size
  56286. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56287. * * 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`
  56288. * * 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
  56289. * * 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)`)
  56290. * * 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
  56291. * * 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
  56292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56295. * @param name defines the name of the mesh
  56296. * @param options defines the options used to create the mesh
  56297. * @param scene defines the hosting scene
  56298. * @returns the polyhedron mesh
  56299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56300. */
  56301. static CreatePolyhedron(name: string, options: {
  56302. type?: number;
  56303. size?: number;
  56304. sizeX?: number;
  56305. sizeY?: number;
  56306. sizeZ?: number;
  56307. custom?: any;
  56308. faceUV?: Vector4[];
  56309. faceColors?: Color4[];
  56310. flat?: boolean;
  56311. updatable?: boolean;
  56312. sideOrientation?: number;
  56313. frontUVs?: Vector4;
  56314. backUVs?: Vector4;
  56315. }, scene?: Nullable<Scene>): Mesh;
  56316. /**
  56317. * Creates a decal mesh.
  56318. * 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
  56319. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56320. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56321. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56322. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56323. * @param name defines the name of the mesh
  56324. * @param sourceMesh defines the mesh where the decal must be applied
  56325. * @param options defines the options used to create the mesh
  56326. * @param scene defines the hosting scene
  56327. * @returns the decal mesh
  56328. * @see https://doc.babylonjs.com/how_to/decals
  56329. */
  56330. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56331. position?: Vector3;
  56332. normal?: Vector3;
  56333. size?: Vector3;
  56334. angle?: number;
  56335. }): Mesh;
  56336. }
  56337. }
  56338. declare module "babylonjs/Meshes/meshSimplification" {
  56339. import { Mesh } from "babylonjs/Meshes/mesh";
  56340. /**
  56341. * A simplifier interface for future simplification implementations
  56342. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56343. */
  56344. export interface ISimplifier {
  56345. /**
  56346. * Simplification of a given mesh according to the given settings.
  56347. * Since this requires computation, it is assumed that the function runs async.
  56348. * @param settings The settings of the simplification, including quality and distance
  56349. * @param successCallback A callback that will be called after the mesh was simplified.
  56350. * @param errorCallback in case of an error, this callback will be called. optional.
  56351. */
  56352. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56353. }
  56354. /**
  56355. * Expected simplification settings.
  56356. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56357. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56358. */
  56359. export interface ISimplificationSettings {
  56360. /**
  56361. * Gets or sets the expected quality
  56362. */
  56363. quality: number;
  56364. /**
  56365. * Gets or sets the distance when this optimized version should be used
  56366. */
  56367. distance: number;
  56368. /**
  56369. * Gets an already optimized mesh
  56370. */
  56371. optimizeMesh?: boolean;
  56372. }
  56373. /**
  56374. * Class used to specify simplification options
  56375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56376. */
  56377. export class SimplificationSettings implements ISimplificationSettings {
  56378. /** expected quality */
  56379. quality: number;
  56380. /** distance when this optimized version should be used */
  56381. distance: number;
  56382. /** already optimized mesh */
  56383. optimizeMesh?: boolean | undefined;
  56384. /**
  56385. * Creates a SimplificationSettings
  56386. * @param quality expected quality
  56387. * @param distance distance when this optimized version should be used
  56388. * @param optimizeMesh already optimized mesh
  56389. */
  56390. constructor(
  56391. /** expected quality */
  56392. quality: number,
  56393. /** distance when this optimized version should be used */
  56394. distance: number,
  56395. /** already optimized mesh */
  56396. optimizeMesh?: boolean | undefined);
  56397. }
  56398. /**
  56399. * Interface used to define a simplification task
  56400. */
  56401. export interface ISimplificationTask {
  56402. /**
  56403. * Array of settings
  56404. */
  56405. settings: Array<ISimplificationSettings>;
  56406. /**
  56407. * Simplification type
  56408. */
  56409. simplificationType: SimplificationType;
  56410. /**
  56411. * Mesh to simplify
  56412. */
  56413. mesh: Mesh;
  56414. /**
  56415. * Callback called on success
  56416. */
  56417. successCallback?: () => void;
  56418. /**
  56419. * Defines if parallel processing can be used
  56420. */
  56421. parallelProcessing: boolean;
  56422. }
  56423. /**
  56424. * Queue used to order the simplification tasks
  56425. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56426. */
  56427. export class SimplificationQueue {
  56428. private _simplificationArray;
  56429. /**
  56430. * Gets a boolean indicating that the process is still running
  56431. */
  56432. running: boolean;
  56433. /**
  56434. * Creates a new queue
  56435. */
  56436. constructor();
  56437. /**
  56438. * Adds a new simplification task
  56439. * @param task defines a task to add
  56440. */
  56441. addTask(task: ISimplificationTask): void;
  56442. /**
  56443. * Execute next task
  56444. */
  56445. executeNext(): void;
  56446. /**
  56447. * Execute a simplification task
  56448. * @param task defines the task to run
  56449. */
  56450. runSimplification(task: ISimplificationTask): void;
  56451. private getSimplifier;
  56452. }
  56453. /**
  56454. * The implemented types of simplification
  56455. * At the moment only Quadratic Error Decimation is implemented
  56456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56457. */
  56458. export enum SimplificationType {
  56459. /** Quadratic error decimation */
  56460. QUADRATIC = 0
  56461. }
  56462. }
  56463. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56464. import { Scene } from "babylonjs/scene";
  56465. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56466. import { ISceneComponent } from "babylonjs/sceneComponent";
  56467. module "babylonjs/scene" {
  56468. interface Scene {
  56469. /** @hidden (Backing field) */
  56470. _simplificationQueue: SimplificationQueue;
  56471. /**
  56472. * Gets or sets the simplification queue attached to the scene
  56473. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56474. */
  56475. simplificationQueue: SimplificationQueue;
  56476. }
  56477. }
  56478. module "babylonjs/Meshes/mesh" {
  56479. interface Mesh {
  56480. /**
  56481. * Simplify the mesh according to the given array of settings.
  56482. * Function will return immediately and will simplify async
  56483. * @param settings a collection of simplification settings
  56484. * @param parallelProcessing should all levels calculate parallel or one after the other
  56485. * @param simplificationType the type of simplification to run
  56486. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56487. * @returns the current mesh
  56488. */
  56489. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56490. }
  56491. }
  56492. /**
  56493. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56494. * created in a scene
  56495. */
  56496. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56497. /**
  56498. * The component name helpfull to identify the component in the list of scene components.
  56499. */
  56500. readonly name: string;
  56501. /**
  56502. * The scene the component belongs to.
  56503. */
  56504. scene: Scene;
  56505. /**
  56506. * Creates a new instance of the component for the given scene
  56507. * @param scene Defines the scene to register the component in
  56508. */
  56509. constructor(scene: Scene);
  56510. /**
  56511. * Registers the component in a given scene
  56512. */
  56513. register(): void;
  56514. /**
  56515. * Rebuilds the elements related to this component in case of
  56516. * context lost for instance.
  56517. */
  56518. rebuild(): void;
  56519. /**
  56520. * Disposes the component and the associated ressources
  56521. */
  56522. dispose(): void;
  56523. private _beforeCameraUpdate;
  56524. }
  56525. }
  56526. declare module "babylonjs/Meshes/Builders/index" {
  56527. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56528. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56529. export * from "babylonjs/Meshes/Builders/discBuilder";
  56530. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56531. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56532. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56533. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56534. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56535. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56536. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56537. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56538. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56539. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56540. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56541. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56542. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56543. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56544. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56545. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56546. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56547. }
  56548. declare module "babylonjs/Meshes/index" {
  56549. export * from "babylonjs/Meshes/abstractMesh";
  56550. export * from "babylonjs/Meshes/buffer";
  56551. export * from "babylonjs/Meshes/Compression/index";
  56552. export * from "babylonjs/Meshes/csg";
  56553. export * from "babylonjs/Meshes/geometry";
  56554. export * from "babylonjs/Meshes/groundMesh";
  56555. export * from "babylonjs/Meshes/trailMesh";
  56556. export * from "babylonjs/Meshes/instancedMesh";
  56557. export * from "babylonjs/Meshes/linesMesh";
  56558. export * from "babylonjs/Meshes/mesh";
  56559. export * from "babylonjs/Meshes/mesh.vertexData";
  56560. export * from "babylonjs/Meshes/meshBuilder";
  56561. export * from "babylonjs/Meshes/meshSimplification";
  56562. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56563. export * from "babylonjs/Meshes/polygonMesh";
  56564. export * from "babylonjs/Meshes/subMesh";
  56565. export * from "babylonjs/Meshes/meshLODLevel";
  56566. export * from "babylonjs/Meshes/transformNode";
  56567. export * from "babylonjs/Meshes/Builders/index";
  56568. export * from "babylonjs/Meshes/dataBuffer";
  56569. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56570. }
  56571. declare module "babylonjs/Morph/index" {
  56572. export * from "babylonjs/Morph/morphTarget";
  56573. export * from "babylonjs/Morph/morphTargetManager";
  56574. }
  56575. declare module "babylonjs/Offline/database" {
  56576. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56577. /**
  56578. * Class used to enable access to IndexedDB
  56579. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56580. */
  56581. export class Database implements IOfflineProvider {
  56582. private _callbackManifestChecked;
  56583. private _currentSceneUrl;
  56584. private _db;
  56585. private _enableSceneOffline;
  56586. private _enableTexturesOffline;
  56587. private _manifestVersionFound;
  56588. private _mustUpdateRessources;
  56589. private _hasReachedQuota;
  56590. private _isSupported;
  56591. private _idbFactory;
  56592. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56593. private static IsUASupportingBlobStorage;
  56594. /**
  56595. * Gets a boolean indicating if Database storate is enabled (off by default)
  56596. */
  56597. static IDBStorageEnabled: boolean;
  56598. /**
  56599. * Gets a boolean indicating if scene must be saved in the database
  56600. */
  56601. readonly enableSceneOffline: boolean;
  56602. /**
  56603. * Gets a boolean indicating if textures must be saved in the database
  56604. */
  56605. readonly enableTexturesOffline: boolean;
  56606. /**
  56607. * Creates a new Database
  56608. * @param urlToScene defines the url to load the scene
  56609. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56610. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56611. */
  56612. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56613. private static _ParseURL;
  56614. private static _ReturnFullUrlLocation;
  56615. private _checkManifestFile;
  56616. /**
  56617. * Open the database and make it available
  56618. * @param successCallback defines the callback to call on success
  56619. * @param errorCallback defines the callback to call on error
  56620. */
  56621. open(successCallback: () => void, errorCallback: () => void): void;
  56622. /**
  56623. * Loads an image from the database
  56624. * @param url defines the url to load from
  56625. * @param image defines the target DOM image
  56626. */
  56627. loadImage(url: string, image: HTMLImageElement): void;
  56628. private _loadImageFromDBAsync;
  56629. private _saveImageIntoDBAsync;
  56630. private _checkVersionFromDB;
  56631. private _loadVersionFromDBAsync;
  56632. private _saveVersionIntoDBAsync;
  56633. /**
  56634. * Loads a file from database
  56635. * @param url defines the URL to load from
  56636. * @param sceneLoaded defines a callback to call on success
  56637. * @param progressCallBack defines a callback to call when progress changed
  56638. * @param errorCallback defines a callback to call on error
  56639. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56640. */
  56641. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56642. private _loadFileAsync;
  56643. private _saveFileAsync;
  56644. /**
  56645. * Validates if xhr data is correct
  56646. * @param xhr defines the request to validate
  56647. * @param dataType defines the expected data type
  56648. * @returns true if data is correct
  56649. */
  56650. private static _ValidateXHRData;
  56651. }
  56652. }
  56653. declare module "babylonjs/Offline/index" {
  56654. export * from "babylonjs/Offline/database";
  56655. export * from "babylonjs/Offline/IOfflineProvider";
  56656. }
  56657. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56658. /** @hidden */
  56659. export var gpuUpdateParticlesPixelShader: {
  56660. name: string;
  56661. shader: string;
  56662. };
  56663. }
  56664. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56665. /** @hidden */
  56666. export var gpuUpdateParticlesVertexShader: {
  56667. name: string;
  56668. shader: string;
  56669. };
  56670. }
  56671. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56672. /** @hidden */
  56673. export var clipPlaneFragmentDeclaration2: {
  56674. name: string;
  56675. shader: string;
  56676. };
  56677. }
  56678. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56679. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56680. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56682. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56683. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56684. /** @hidden */
  56685. export var gpuRenderParticlesPixelShader: {
  56686. name: string;
  56687. shader: string;
  56688. };
  56689. }
  56690. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56691. /** @hidden */
  56692. export var clipPlaneVertexDeclaration2: {
  56693. name: string;
  56694. shader: string;
  56695. };
  56696. }
  56697. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56698. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56699. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56700. /** @hidden */
  56701. export var gpuRenderParticlesVertexShader: {
  56702. name: string;
  56703. shader: string;
  56704. };
  56705. }
  56706. declare module "babylonjs/Particles/gpuParticleSystem" {
  56707. import { Nullable } from "babylonjs/types";
  56708. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56709. import { Observable } from "babylonjs/Misc/observable";
  56710. import { Color4, Color3 } from "babylonjs/Maths/math";
  56711. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56712. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56713. import { Scene, IDisposable } from "babylonjs/scene";
  56714. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56715. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56716. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56717. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56718. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56719. /**
  56720. * This represents a GPU particle system in Babylon
  56721. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56722. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56723. */
  56724. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56725. /**
  56726. * The layer mask we are rendering the particles through.
  56727. */
  56728. layerMask: number;
  56729. private _capacity;
  56730. private _activeCount;
  56731. private _currentActiveCount;
  56732. private _accumulatedCount;
  56733. private _renderEffect;
  56734. private _updateEffect;
  56735. private _buffer0;
  56736. private _buffer1;
  56737. private _spriteBuffer;
  56738. private _updateVAO;
  56739. private _renderVAO;
  56740. private _targetIndex;
  56741. private _sourceBuffer;
  56742. private _targetBuffer;
  56743. private _engine;
  56744. private _currentRenderId;
  56745. private _started;
  56746. private _stopped;
  56747. private _timeDelta;
  56748. private _randomTexture;
  56749. private _randomTexture2;
  56750. private _attributesStrideSize;
  56751. private _updateEffectOptions;
  56752. private _randomTextureSize;
  56753. private _actualFrame;
  56754. private readonly _rawTextureWidth;
  56755. /**
  56756. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56757. */
  56758. static readonly IsSupported: boolean;
  56759. /**
  56760. * An event triggered when the system is disposed.
  56761. */
  56762. onDisposeObservable: Observable<GPUParticleSystem>;
  56763. /**
  56764. * Gets the maximum number of particles active at the same time.
  56765. * @returns The max number of active particles.
  56766. */
  56767. getCapacity(): number;
  56768. /**
  56769. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56770. * to override the particles.
  56771. */
  56772. forceDepthWrite: boolean;
  56773. /**
  56774. * Gets or set the number of active particles
  56775. */
  56776. activeParticleCount: number;
  56777. private _preWarmDone;
  56778. /**
  56779. * Is this system ready to be used/rendered
  56780. * @return true if the system is ready
  56781. */
  56782. isReady(): boolean;
  56783. /**
  56784. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56785. * @returns True if it has been started, otherwise false.
  56786. */
  56787. isStarted(): boolean;
  56788. /**
  56789. * Starts the particle system and begins to emit
  56790. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56791. */
  56792. start(delay?: number): void;
  56793. /**
  56794. * Stops the particle system.
  56795. */
  56796. stop(): void;
  56797. /**
  56798. * Remove all active particles
  56799. */
  56800. reset(): void;
  56801. /**
  56802. * Returns the string "GPUParticleSystem"
  56803. * @returns a string containing the class name
  56804. */
  56805. getClassName(): string;
  56806. private _colorGradientsTexture;
  56807. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56808. /**
  56809. * Adds a new color gradient
  56810. * @param gradient defines the gradient to use (between 0 and 1)
  56811. * @param color1 defines the color to affect to the specified gradient
  56812. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56813. * @returns the current particle system
  56814. */
  56815. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56816. /**
  56817. * Remove a specific color gradient
  56818. * @param gradient defines the gradient to remove
  56819. * @returns the current particle system
  56820. */
  56821. removeColorGradient(gradient: number): GPUParticleSystem;
  56822. private _angularSpeedGradientsTexture;
  56823. private _sizeGradientsTexture;
  56824. private _velocityGradientsTexture;
  56825. private _limitVelocityGradientsTexture;
  56826. private _dragGradientsTexture;
  56827. private _addFactorGradient;
  56828. /**
  56829. * Adds a new size gradient
  56830. * @param gradient defines the gradient to use (between 0 and 1)
  56831. * @param factor defines the size factor to affect to the specified gradient
  56832. * @returns the current particle system
  56833. */
  56834. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56835. /**
  56836. * Remove a specific size gradient
  56837. * @param gradient defines the gradient to remove
  56838. * @returns the current particle system
  56839. */
  56840. removeSizeGradient(gradient: number): GPUParticleSystem;
  56841. /**
  56842. * Adds a new angular speed gradient
  56843. * @param gradient defines the gradient to use (between 0 and 1)
  56844. * @param factor defines the angular speed to affect to the specified gradient
  56845. * @returns the current particle system
  56846. */
  56847. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56848. /**
  56849. * Remove a specific angular speed gradient
  56850. * @param gradient defines the gradient to remove
  56851. * @returns the current particle system
  56852. */
  56853. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56854. /**
  56855. * Adds a new velocity gradient
  56856. * @param gradient defines the gradient to use (between 0 and 1)
  56857. * @param factor defines the velocity to affect to the specified gradient
  56858. * @returns the current particle system
  56859. */
  56860. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56861. /**
  56862. * Remove a specific velocity gradient
  56863. * @param gradient defines the gradient to remove
  56864. * @returns the current particle system
  56865. */
  56866. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56867. /**
  56868. * Adds a new limit velocity gradient
  56869. * @param gradient defines the gradient to use (between 0 and 1)
  56870. * @param factor defines the limit velocity value to affect to the specified gradient
  56871. * @returns the current particle system
  56872. */
  56873. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56874. /**
  56875. * Remove a specific limit velocity gradient
  56876. * @param gradient defines the gradient to remove
  56877. * @returns the current particle system
  56878. */
  56879. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56880. /**
  56881. * Adds a new drag gradient
  56882. * @param gradient defines the gradient to use (between 0 and 1)
  56883. * @param factor defines the drag value to affect to the specified gradient
  56884. * @returns the current particle system
  56885. */
  56886. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56887. /**
  56888. * Remove a specific drag gradient
  56889. * @param gradient defines the gradient to remove
  56890. * @returns the current particle system
  56891. */
  56892. removeDragGradient(gradient: number): GPUParticleSystem;
  56893. /**
  56894. * Not supported by GPUParticleSystem
  56895. * @param gradient defines the gradient to use (between 0 and 1)
  56896. * @param factor defines the emit rate value to affect to the specified gradient
  56897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56898. * @returns the current particle system
  56899. */
  56900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56901. /**
  56902. * Not supported by GPUParticleSystem
  56903. * @param gradient defines the gradient to remove
  56904. * @returns the current particle system
  56905. */
  56906. removeEmitRateGradient(gradient: number): IParticleSystem;
  56907. /**
  56908. * Not supported by GPUParticleSystem
  56909. * @param gradient defines the gradient to use (between 0 and 1)
  56910. * @param factor defines the start size value to affect to the specified gradient
  56911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56912. * @returns the current particle system
  56913. */
  56914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56915. /**
  56916. * Not supported by GPUParticleSystem
  56917. * @param gradient defines the gradient to remove
  56918. * @returns the current particle system
  56919. */
  56920. removeStartSizeGradient(gradient: number): IParticleSystem;
  56921. /**
  56922. * Not supported by GPUParticleSystem
  56923. * @param gradient defines the gradient to use (between 0 and 1)
  56924. * @param min defines the color remap minimal range
  56925. * @param max defines the color remap maximal range
  56926. * @returns the current particle system
  56927. */
  56928. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56929. /**
  56930. * Not supported by GPUParticleSystem
  56931. * @param gradient defines the gradient to remove
  56932. * @returns the current particle system
  56933. */
  56934. removeColorRemapGradient(): IParticleSystem;
  56935. /**
  56936. * Not supported by GPUParticleSystem
  56937. * @param gradient defines the gradient to use (between 0 and 1)
  56938. * @param min defines the alpha remap minimal range
  56939. * @param max defines the alpha remap maximal range
  56940. * @returns the current particle system
  56941. */
  56942. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56943. /**
  56944. * Not supported by GPUParticleSystem
  56945. * @param gradient defines the gradient to remove
  56946. * @returns the current particle system
  56947. */
  56948. removeAlphaRemapGradient(): IParticleSystem;
  56949. /**
  56950. * Not supported by GPUParticleSystem
  56951. * @param gradient defines the gradient to use (between 0 and 1)
  56952. * @param color defines the color to affect to the specified gradient
  56953. * @returns the current particle system
  56954. */
  56955. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56956. /**
  56957. * Not supported by GPUParticleSystem
  56958. * @param gradient defines the gradient to remove
  56959. * @returns the current particle system
  56960. */
  56961. removeRampGradient(): IParticleSystem;
  56962. /**
  56963. * Not supported by GPUParticleSystem
  56964. * @returns the list of ramp gradients
  56965. */
  56966. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56967. /**
  56968. * Not supported by GPUParticleSystem
  56969. * Gets or sets a boolean indicating that ramp gradients must be used
  56970. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56971. */
  56972. useRampGradients: boolean;
  56973. /**
  56974. * Not supported by GPUParticleSystem
  56975. * @param gradient defines the gradient to use (between 0 and 1)
  56976. * @param factor defines the life time factor to affect to the specified gradient
  56977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56978. * @returns the current particle system
  56979. */
  56980. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56981. /**
  56982. * Not supported by GPUParticleSystem
  56983. * @param gradient defines the gradient to remove
  56984. * @returns the current particle system
  56985. */
  56986. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56987. /**
  56988. * Instantiates a GPU particle system.
  56989. * 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.
  56990. * @param name The name of the particle system
  56991. * @param options The options used to create the system
  56992. * @param scene The scene the particle system belongs to
  56993. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56994. */
  56995. constructor(name: string, options: Partial<{
  56996. capacity: number;
  56997. randomTextureSize: number;
  56998. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56999. protected _reset(): void;
  57000. private _createUpdateVAO;
  57001. private _createRenderVAO;
  57002. private _initialize;
  57003. /** @hidden */
  57004. _recreateUpdateEffect(): void;
  57005. /** @hidden */
  57006. _recreateRenderEffect(): void;
  57007. /**
  57008. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57009. * @param preWarm defines if we are in the pre-warmimg phase
  57010. */
  57011. animate(preWarm?: boolean): void;
  57012. private _createFactorGradientTexture;
  57013. private _createSizeGradientTexture;
  57014. private _createAngularSpeedGradientTexture;
  57015. private _createVelocityGradientTexture;
  57016. private _createLimitVelocityGradientTexture;
  57017. private _createDragGradientTexture;
  57018. private _createColorGradientTexture;
  57019. /**
  57020. * Renders the particle system in its current state
  57021. * @param preWarm defines if the system should only update the particles but not render them
  57022. * @returns the current number of particles
  57023. */
  57024. render(preWarm?: boolean): number;
  57025. /**
  57026. * Rebuilds the particle system
  57027. */
  57028. rebuild(): void;
  57029. private _releaseBuffers;
  57030. private _releaseVAOs;
  57031. /**
  57032. * Disposes the particle system and free the associated resources
  57033. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57034. */
  57035. dispose(disposeTexture?: boolean): void;
  57036. /**
  57037. * Clones the particle system.
  57038. * @param name The name of the cloned object
  57039. * @param newEmitter The new emitter to use
  57040. * @returns the cloned particle system
  57041. */
  57042. clone(name: string, newEmitter: any): GPUParticleSystem;
  57043. /**
  57044. * Serializes the particle system to a JSON object.
  57045. * @returns the JSON object
  57046. */
  57047. serialize(): any;
  57048. /**
  57049. * Parses a JSON object to create a GPU particle system.
  57050. * @param parsedParticleSystem The JSON object to parse
  57051. * @param scene The scene to create the particle system in
  57052. * @param rootUrl The root url to use to load external dependencies like texture
  57053. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57054. * @returns the parsed GPU particle system
  57055. */
  57056. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57057. }
  57058. }
  57059. declare module "babylonjs/Particles/particleSystemSet" {
  57060. import { Nullable } from "babylonjs/types";
  57061. import { Color3 } from "babylonjs/Maths/math";
  57062. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57064. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57065. import { Scene, IDisposable } from "babylonjs/scene";
  57066. /**
  57067. * Represents a set of particle systems working together to create a specific effect
  57068. */
  57069. export class ParticleSystemSet implements IDisposable {
  57070. private _emitterCreationOptions;
  57071. private _emitterNode;
  57072. /**
  57073. * Gets the particle system list
  57074. */
  57075. systems: IParticleSystem[];
  57076. /**
  57077. * Gets the emitter node used with this set
  57078. */
  57079. readonly emitterNode: Nullable<TransformNode>;
  57080. /**
  57081. * Creates a new emitter mesh as a sphere
  57082. * @param options defines the options used to create the sphere
  57083. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57084. * @param scene defines the hosting scene
  57085. */
  57086. setEmitterAsSphere(options: {
  57087. diameter: number;
  57088. segments: number;
  57089. color: Color3;
  57090. }, renderingGroupId: number, scene: Scene): void;
  57091. /**
  57092. * Starts all particle systems of the set
  57093. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57094. */
  57095. start(emitter?: AbstractMesh): void;
  57096. /**
  57097. * Release all associated resources
  57098. */
  57099. dispose(): void;
  57100. /**
  57101. * Serialize the set into a JSON compatible object
  57102. * @returns a JSON compatible representation of the set
  57103. */
  57104. serialize(): any;
  57105. /**
  57106. * Parse a new ParticleSystemSet from a serialized source
  57107. * @param data defines a JSON compatible representation of the set
  57108. * @param scene defines the hosting scene
  57109. * @param gpu defines if we want GPU particles or CPU particles
  57110. * @returns a new ParticleSystemSet
  57111. */
  57112. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57113. }
  57114. }
  57115. declare module "babylonjs/Particles/particleHelper" {
  57116. import { Nullable } from "babylonjs/types";
  57117. import { Scene } from "babylonjs/scene";
  57118. import { Vector3 } from "babylonjs/Maths/math";
  57119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57120. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57121. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57122. /**
  57123. * This class is made for on one-liner static method to help creating particle system set.
  57124. */
  57125. export class ParticleHelper {
  57126. /**
  57127. * Gets or sets base Assets URL
  57128. */
  57129. static BaseAssetsUrl: string;
  57130. /**
  57131. * Create a default particle system that you can tweak
  57132. * @param emitter defines the emitter to use
  57133. * @param capacity defines the system capacity (default is 500 particles)
  57134. * @param scene defines the hosting scene
  57135. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57136. * @returns the new Particle system
  57137. */
  57138. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57139. /**
  57140. * This is the main static method (one-liner) of this helper to create different particle systems
  57141. * @param type This string represents the type to the particle system to create
  57142. * @param scene The scene where the particle system should live
  57143. * @param gpu If the system will use gpu
  57144. * @returns the ParticleSystemSet created
  57145. */
  57146. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57147. /**
  57148. * Static function used to export a particle system to a ParticleSystemSet variable.
  57149. * Please note that the emitter shape is not exported
  57150. * @param systems defines the particle systems to export
  57151. * @returns the created particle system set
  57152. */
  57153. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57154. }
  57155. }
  57156. declare module "babylonjs/Particles/particleSystemComponent" {
  57157. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57158. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57159. import "babylonjs/Shaders/particles.vertex";
  57160. module "babylonjs/Engines/engine" {
  57161. interface Engine {
  57162. /**
  57163. * Create an effect to use with particle systems.
  57164. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57165. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57166. * @param uniformsNames defines a list of attribute names
  57167. * @param samplers defines an array of string used to represent textures
  57168. * @param defines defines the string containing the defines to use to compile the shaders
  57169. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57170. * @param onCompiled defines a function to call when the effect creation is successful
  57171. * @param onError defines a function to call when the effect creation has failed
  57172. * @returns the new Effect
  57173. */
  57174. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57175. }
  57176. }
  57177. module "babylonjs/Meshes/mesh" {
  57178. interface Mesh {
  57179. /**
  57180. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57181. * @returns an array of IParticleSystem
  57182. */
  57183. getEmittedParticleSystems(): IParticleSystem[];
  57184. /**
  57185. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57186. * @returns an array of IParticleSystem
  57187. */
  57188. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57189. }
  57190. }
  57191. /**
  57192. * @hidden
  57193. */
  57194. export var _IDoNeedToBeInTheBuild: number;
  57195. }
  57196. declare module "babylonjs/Particles/index" {
  57197. export * from "babylonjs/Particles/baseParticleSystem";
  57198. export * from "babylonjs/Particles/EmitterTypes/index";
  57199. export * from "babylonjs/Particles/gpuParticleSystem";
  57200. export * from "babylonjs/Particles/IParticleSystem";
  57201. export * from "babylonjs/Particles/particle";
  57202. export * from "babylonjs/Particles/particleHelper";
  57203. export * from "babylonjs/Particles/particleSystem";
  57204. export * from "babylonjs/Particles/particleSystemComponent";
  57205. export * from "babylonjs/Particles/particleSystemSet";
  57206. export * from "babylonjs/Particles/solidParticle";
  57207. export * from "babylonjs/Particles/solidParticleSystem";
  57208. export * from "babylonjs/Particles/subEmitter";
  57209. }
  57210. declare module "babylonjs/Physics/physicsEngineComponent" {
  57211. import { Nullable } from "babylonjs/types";
  57212. import { Observable, Observer } from "babylonjs/Misc/observable";
  57213. import { Vector3 } from "babylonjs/Maths/math";
  57214. import { Mesh } from "babylonjs/Meshes/mesh";
  57215. import { ISceneComponent } from "babylonjs/sceneComponent";
  57216. import { Scene } from "babylonjs/scene";
  57217. import { Node } from "babylonjs/node";
  57218. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57219. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57220. module "babylonjs/scene" {
  57221. interface Scene {
  57222. /** @hidden (Backing field) */
  57223. _physicsEngine: Nullable<IPhysicsEngine>;
  57224. /**
  57225. * Gets the current physics engine
  57226. * @returns a IPhysicsEngine or null if none attached
  57227. */
  57228. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57229. /**
  57230. * Enables physics to the current scene
  57231. * @param gravity defines the scene's gravity for the physics engine
  57232. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57233. * @return a boolean indicating if the physics engine was initialized
  57234. */
  57235. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57236. /**
  57237. * Disables and disposes the physics engine associated with the scene
  57238. */
  57239. disablePhysicsEngine(): void;
  57240. /**
  57241. * Gets a boolean indicating if there is an active physics engine
  57242. * @returns a boolean indicating if there is an active physics engine
  57243. */
  57244. isPhysicsEnabled(): boolean;
  57245. /**
  57246. * Deletes a physics compound impostor
  57247. * @param compound defines the compound to delete
  57248. */
  57249. deleteCompoundImpostor(compound: any): void;
  57250. /**
  57251. * An event triggered when physic simulation is about to be run
  57252. */
  57253. onBeforePhysicsObservable: Observable<Scene>;
  57254. /**
  57255. * An event triggered when physic simulation has been done
  57256. */
  57257. onAfterPhysicsObservable: Observable<Scene>;
  57258. }
  57259. }
  57260. module "babylonjs/Meshes/abstractMesh" {
  57261. interface AbstractMesh {
  57262. /** @hidden */
  57263. _physicsImpostor: Nullable<PhysicsImpostor>;
  57264. /**
  57265. * Gets or sets impostor used for physic simulation
  57266. * @see http://doc.babylonjs.com/features/physics_engine
  57267. */
  57268. physicsImpostor: Nullable<PhysicsImpostor>;
  57269. /**
  57270. * Gets the current physics impostor
  57271. * @see http://doc.babylonjs.com/features/physics_engine
  57272. * @returns a physics impostor or null
  57273. */
  57274. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57275. /** Apply a physic impulse to the mesh
  57276. * @param force defines the force to apply
  57277. * @param contactPoint defines where to apply the force
  57278. * @returns the current mesh
  57279. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57280. */
  57281. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57282. /**
  57283. * Creates a physic joint between two meshes
  57284. * @param otherMesh defines the other mesh to use
  57285. * @param pivot1 defines the pivot to use on this mesh
  57286. * @param pivot2 defines the pivot to use on the other mesh
  57287. * @param options defines additional options (can be plugin dependent)
  57288. * @returns the current mesh
  57289. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57290. */
  57291. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57292. /** @hidden */
  57293. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57294. }
  57295. }
  57296. /**
  57297. * Defines the physics engine scene component responsible to manage a physics engine
  57298. */
  57299. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57300. /**
  57301. * The component name helpful to identify the component in the list of scene components.
  57302. */
  57303. readonly name: string;
  57304. /**
  57305. * The scene the component belongs to.
  57306. */
  57307. scene: Scene;
  57308. /**
  57309. * Creates a new instance of the component for the given scene
  57310. * @param scene Defines the scene to register the component in
  57311. */
  57312. constructor(scene: Scene);
  57313. /**
  57314. * Registers the component in a given scene
  57315. */
  57316. register(): void;
  57317. /**
  57318. * Rebuilds the elements related to this component in case of
  57319. * context lost for instance.
  57320. */
  57321. rebuild(): void;
  57322. /**
  57323. * Disposes the component and the associated ressources
  57324. */
  57325. dispose(): void;
  57326. }
  57327. }
  57328. declare module "babylonjs/Physics/physicsHelper" {
  57329. import { Nullable } from "babylonjs/types";
  57330. import { Vector3 } from "babylonjs/Maths/math";
  57331. import { Mesh } from "babylonjs/Meshes/mesh";
  57332. import { Scene } from "babylonjs/scene";
  57333. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57334. /**
  57335. * A helper for physics simulations
  57336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57337. */
  57338. export class PhysicsHelper {
  57339. private _scene;
  57340. private _physicsEngine;
  57341. /**
  57342. * Initializes the Physics helper
  57343. * @param scene Babylon.js scene
  57344. */
  57345. constructor(scene: Scene);
  57346. /**
  57347. * Applies a radial explosion impulse
  57348. * @param origin the origin of the explosion
  57349. * @param radiusOrEventOptions the radius or the options of radial explosion
  57350. * @param strength the explosion strength
  57351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57352. * @returns A physics radial explosion event, or null
  57353. */
  57354. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57355. /**
  57356. * Applies a radial explosion force
  57357. * @param origin the origin of the explosion
  57358. * @param radiusOrEventOptions the radius or the options of radial explosion
  57359. * @param strength the explosion strength
  57360. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57361. * @returns A physics radial explosion event, or null
  57362. */
  57363. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57364. /**
  57365. * Creates a gravitational field
  57366. * @param origin the origin of the explosion
  57367. * @param radiusOrEventOptions the radius or the options of radial explosion
  57368. * @param strength the explosion strength
  57369. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57370. * @returns A physics gravitational field event, or null
  57371. */
  57372. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57373. /**
  57374. * Creates a physics updraft event
  57375. * @param origin the origin of the updraft
  57376. * @param radiusOrEventOptions the radius or the options of the updraft
  57377. * @param strength the strength of the updraft
  57378. * @param height the height of the updraft
  57379. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57380. * @returns A physics updraft event, or null
  57381. */
  57382. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57383. /**
  57384. * Creates a physics vortex event
  57385. * @param origin the of the vortex
  57386. * @param radiusOrEventOptions the radius or the options of the vortex
  57387. * @param strength the strength of the vortex
  57388. * @param height the height of the vortex
  57389. * @returns a Physics vortex event, or null
  57390. * A physics vortex event or null
  57391. */
  57392. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57393. }
  57394. /**
  57395. * Represents a physics radial explosion event
  57396. */
  57397. class PhysicsRadialExplosionEvent {
  57398. private _scene;
  57399. private _options;
  57400. private _sphere;
  57401. private _dataFetched;
  57402. /**
  57403. * Initializes a radial explosioin event
  57404. * @param _scene BabylonJS scene
  57405. * @param _options The options for the vortex event
  57406. */
  57407. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57408. /**
  57409. * Returns the data related to the radial explosion event (sphere).
  57410. * @returns The radial explosion event data
  57411. */
  57412. getData(): PhysicsRadialExplosionEventData;
  57413. /**
  57414. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57415. * @param impostor A physics imposter
  57416. * @param origin the origin of the explosion
  57417. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57418. */
  57419. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57420. /**
  57421. * Triggers affecterd impostors callbacks
  57422. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57423. */
  57424. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57425. /**
  57426. * Disposes the sphere.
  57427. * @param force Specifies if the sphere should be disposed by force
  57428. */
  57429. dispose(force?: boolean): void;
  57430. /*** Helpers ***/
  57431. private _prepareSphere;
  57432. private _intersectsWithSphere;
  57433. }
  57434. /**
  57435. * Represents a gravitational field event
  57436. */
  57437. class PhysicsGravitationalFieldEvent {
  57438. private _physicsHelper;
  57439. private _scene;
  57440. private _origin;
  57441. private _options;
  57442. private _tickCallback;
  57443. private _sphere;
  57444. private _dataFetched;
  57445. /**
  57446. * Initializes the physics gravitational field event
  57447. * @param _physicsHelper A physics helper
  57448. * @param _scene BabylonJS scene
  57449. * @param _origin The origin position of the gravitational field event
  57450. * @param _options The options for the vortex event
  57451. */
  57452. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57453. /**
  57454. * Returns the data related to the gravitational field event (sphere).
  57455. * @returns A gravitational field event
  57456. */
  57457. getData(): PhysicsGravitationalFieldEventData;
  57458. /**
  57459. * Enables the gravitational field.
  57460. */
  57461. enable(): void;
  57462. /**
  57463. * Disables the gravitational field.
  57464. */
  57465. disable(): void;
  57466. /**
  57467. * Disposes the sphere.
  57468. * @param force The force to dispose from the gravitational field event
  57469. */
  57470. dispose(force?: boolean): void;
  57471. private _tick;
  57472. }
  57473. /**
  57474. * Represents a physics updraft event
  57475. */
  57476. class PhysicsUpdraftEvent {
  57477. private _scene;
  57478. private _origin;
  57479. private _options;
  57480. private _physicsEngine;
  57481. private _originTop;
  57482. private _originDirection;
  57483. private _tickCallback;
  57484. private _cylinder;
  57485. private _cylinderPosition;
  57486. private _dataFetched;
  57487. /**
  57488. * Initializes the physics updraft event
  57489. * @param _scene BabylonJS scene
  57490. * @param _origin The origin position of the updraft
  57491. * @param _options The options for the updraft event
  57492. */
  57493. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57494. /**
  57495. * Returns the data related to the updraft event (cylinder).
  57496. * @returns A physics updraft event
  57497. */
  57498. getData(): PhysicsUpdraftEventData;
  57499. /**
  57500. * Enables the updraft.
  57501. */
  57502. enable(): void;
  57503. /**
  57504. * Disables the updraft.
  57505. */
  57506. disable(): void;
  57507. /**
  57508. * Disposes the cylinder.
  57509. * @param force Specifies if the updraft should be disposed by force
  57510. */
  57511. dispose(force?: boolean): void;
  57512. private getImpostorHitData;
  57513. private _tick;
  57514. /*** Helpers ***/
  57515. private _prepareCylinder;
  57516. private _intersectsWithCylinder;
  57517. }
  57518. /**
  57519. * Represents a physics vortex event
  57520. */
  57521. class PhysicsVortexEvent {
  57522. private _scene;
  57523. private _origin;
  57524. private _options;
  57525. private _physicsEngine;
  57526. private _originTop;
  57527. private _tickCallback;
  57528. private _cylinder;
  57529. private _cylinderPosition;
  57530. private _dataFetched;
  57531. /**
  57532. * Initializes the physics vortex event
  57533. * @param _scene The BabylonJS scene
  57534. * @param _origin The origin position of the vortex
  57535. * @param _options The options for the vortex event
  57536. */
  57537. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57538. /**
  57539. * Returns the data related to the vortex event (cylinder).
  57540. * @returns The physics vortex event data
  57541. */
  57542. getData(): PhysicsVortexEventData;
  57543. /**
  57544. * Enables the vortex.
  57545. */
  57546. enable(): void;
  57547. /**
  57548. * Disables the cortex.
  57549. */
  57550. disable(): void;
  57551. /**
  57552. * Disposes the sphere.
  57553. * @param force
  57554. */
  57555. dispose(force?: boolean): void;
  57556. private getImpostorHitData;
  57557. private _tick;
  57558. /*** Helpers ***/
  57559. private _prepareCylinder;
  57560. private _intersectsWithCylinder;
  57561. }
  57562. /**
  57563. * Options fot the radial explosion event
  57564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57565. */
  57566. export class PhysicsRadialExplosionEventOptions {
  57567. /**
  57568. * The radius of the sphere for the radial explosion.
  57569. */
  57570. radius: number;
  57571. /**
  57572. * The strenth of the explosion.
  57573. */
  57574. strength: number;
  57575. /**
  57576. * The strenght of the force in correspondence to the distance of the affected object
  57577. */
  57578. falloff: PhysicsRadialImpulseFalloff;
  57579. /**
  57580. * Sphere options for the radial explosion.
  57581. */
  57582. sphere: {
  57583. segments: number;
  57584. diameter: number;
  57585. };
  57586. /**
  57587. * Sphere options for the radial explosion.
  57588. */
  57589. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57590. }
  57591. /**
  57592. * Options fot the updraft event
  57593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57594. */
  57595. export class PhysicsUpdraftEventOptions {
  57596. /**
  57597. * The radius of the cylinder for the vortex
  57598. */
  57599. radius: number;
  57600. /**
  57601. * The strenth of the updraft.
  57602. */
  57603. strength: number;
  57604. /**
  57605. * The height of the cylinder for the updraft.
  57606. */
  57607. height: number;
  57608. /**
  57609. * The mode for the the updraft.
  57610. */
  57611. updraftMode: PhysicsUpdraftMode;
  57612. }
  57613. /**
  57614. * Options fot the vortex event
  57615. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57616. */
  57617. export class PhysicsVortexEventOptions {
  57618. /**
  57619. * The radius of the cylinder for the vortex
  57620. */
  57621. radius: number;
  57622. /**
  57623. * The strenth of the vortex.
  57624. */
  57625. strength: number;
  57626. /**
  57627. * The height of the cylinder for the vortex.
  57628. */
  57629. height: number;
  57630. /**
  57631. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57632. */
  57633. centripetalForceThreshold: number;
  57634. /**
  57635. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57636. */
  57637. centripetalForceMultiplier: number;
  57638. /**
  57639. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57640. */
  57641. centrifugalForceMultiplier: number;
  57642. /**
  57643. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57644. */
  57645. updraftForceMultiplier: number;
  57646. }
  57647. /**
  57648. * The strenght of the force in correspondence to the distance of the affected object
  57649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57650. */
  57651. export enum PhysicsRadialImpulseFalloff {
  57652. /** Defines that impulse is constant in strength across it's whole radius */
  57653. Constant = 0,
  57654. /** Defines that impulse gets weaker if it's further from the origin */
  57655. Linear = 1
  57656. }
  57657. /**
  57658. * The strength of the force in correspondence to the distance of the affected object
  57659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57660. */
  57661. export enum PhysicsUpdraftMode {
  57662. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57663. Center = 0,
  57664. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57665. Perpendicular = 1
  57666. }
  57667. /**
  57668. * Interface for a physics hit data
  57669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57670. */
  57671. export interface PhysicsHitData {
  57672. /**
  57673. * The force applied at the contact point
  57674. */
  57675. force: Vector3;
  57676. /**
  57677. * The contact point
  57678. */
  57679. contactPoint: Vector3;
  57680. /**
  57681. * The distance from the origin to the contact point
  57682. */
  57683. distanceFromOrigin: number;
  57684. }
  57685. /**
  57686. * Interface for radial explosion event data
  57687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57688. */
  57689. export interface PhysicsRadialExplosionEventData {
  57690. /**
  57691. * A sphere used for the radial explosion event
  57692. */
  57693. sphere: Mesh;
  57694. }
  57695. /**
  57696. * Interface for gravitational field event data
  57697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57698. */
  57699. export interface PhysicsGravitationalFieldEventData {
  57700. /**
  57701. * A sphere mesh used for the gravitational field event
  57702. */
  57703. sphere: Mesh;
  57704. }
  57705. /**
  57706. * Interface for updraft event data
  57707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57708. */
  57709. export interface PhysicsUpdraftEventData {
  57710. /**
  57711. * A cylinder used for the updraft event
  57712. */
  57713. cylinder: Mesh;
  57714. }
  57715. /**
  57716. * Interface for vortex event data
  57717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57718. */
  57719. export interface PhysicsVortexEventData {
  57720. /**
  57721. * A cylinder used for the vortex event
  57722. */
  57723. cylinder: Mesh;
  57724. }
  57725. /**
  57726. * Interface for an affected physics impostor
  57727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57728. */
  57729. export interface PhysicsAffectedImpostorWithData {
  57730. /**
  57731. * The impostor affected by the effect
  57732. */
  57733. impostor: PhysicsImpostor;
  57734. /**
  57735. * The data about the hit/horce from the explosion
  57736. */
  57737. hitData: PhysicsHitData;
  57738. }
  57739. }
  57740. declare module "babylonjs/Physics/Plugins/index" {
  57741. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57742. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57743. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57744. }
  57745. declare module "babylonjs/Physics/index" {
  57746. export * from "babylonjs/Physics/IPhysicsEngine";
  57747. export * from "babylonjs/Physics/physicsEngine";
  57748. export * from "babylonjs/Physics/physicsEngineComponent";
  57749. export * from "babylonjs/Physics/physicsHelper";
  57750. export * from "babylonjs/Physics/physicsImpostor";
  57751. export * from "babylonjs/Physics/physicsJoint";
  57752. export * from "babylonjs/Physics/Plugins/index";
  57753. }
  57754. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57755. /** @hidden */
  57756. export var blackAndWhitePixelShader: {
  57757. name: string;
  57758. shader: string;
  57759. };
  57760. }
  57761. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57763. import { Camera } from "babylonjs/Cameras/camera";
  57764. import { Engine } from "babylonjs/Engines/engine";
  57765. import "babylonjs/Shaders/blackAndWhite.fragment";
  57766. /**
  57767. * Post process used to render in black and white
  57768. */
  57769. export class BlackAndWhitePostProcess extends PostProcess {
  57770. /**
  57771. * Linear about to convert he result to black and white (default: 1)
  57772. */
  57773. degree: number;
  57774. /**
  57775. * Creates a black and white post process
  57776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57777. * @param name The name of the effect.
  57778. * @param options The required width/height ratio to downsize to before computing the render pass.
  57779. * @param camera The camera to apply the render pass to.
  57780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57781. * @param engine The engine which the post process will be applied. (default: current engine)
  57782. * @param reusable If the post process can be reused on the same frame. (default: false)
  57783. */
  57784. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57785. }
  57786. }
  57787. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57788. import { Nullable } from "babylonjs/types";
  57789. import { Camera } from "babylonjs/Cameras/camera";
  57790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57791. import { Engine } from "babylonjs/Engines/engine";
  57792. /**
  57793. * This represents a set of one or more post processes in Babylon.
  57794. * A post process can be used to apply a shader to a texture after it is rendered.
  57795. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57796. */
  57797. export class PostProcessRenderEffect {
  57798. private _postProcesses;
  57799. private _getPostProcesses;
  57800. private _singleInstance;
  57801. private _cameras;
  57802. private _indicesForCamera;
  57803. /**
  57804. * Name of the effect
  57805. * @hidden
  57806. */
  57807. _name: string;
  57808. /**
  57809. * Instantiates a post process render effect.
  57810. * A post process can be used to apply a shader to a texture after it is rendered.
  57811. * @param engine The engine the effect is tied to
  57812. * @param name The name of the effect
  57813. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57814. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57815. */
  57816. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57817. /**
  57818. * Checks if all the post processes in the effect are supported.
  57819. */
  57820. readonly isSupported: boolean;
  57821. /**
  57822. * Updates the current state of the effect
  57823. * @hidden
  57824. */
  57825. _update(): void;
  57826. /**
  57827. * Attaches the effect on cameras
  57828. * @param cameras The camera to attach to.
  57829. * @hidden
  57830. */
  57831. _attachCameras(cameras: Camera): void;
  57832. /**
  57833. * Attaches the effect on cameras
  57834. * @param cameras The camera to attach to.
  57835. * @hidden
  57836. */
  57837. _attachCameras(cameras: Camera[]): void;
  57838. /**
  57839. * Detaches the effect on cameras
  57840. * @param cameras The camera to detatch from.
  57841. * @hidden
  57842. */
  57843. _detachCameras(cameras: Camera): void;
  57844. /**
  57845. * Detatches the effect on cameras
  57846. * @param cameras The camera to detatch from.
  57847. * @hidden
  57848. */
  57849. _detachCameras(cameras: Camera[]): void;
  57850. /**
  57851. * Enables the effect on given cameras
  57852. * @param cameras The camera to enable.
  57853. * @hidden
  57854. */
  57855. _enable(cameras: Camera): void;
  57856. /**
  57857. * Enables the effect on given cameras
  57858. * @param cameras The camera to enable.
  57859. * @hidden
  57860. */
  57861. _enable(cameras: Nullable<Camera[]>): void;
  57862. /**
  57863. * Disables the effect on the given cameras
  57864. * @param cameras The camera to disable.
  57865. * @hidden
  57866. */
  57867. _disable(cameras: Camera): void;
  57868. /**
  57869. * Disables the effect on the given cameras
  57870. * @param cameras The camera to disable.
  57871. * @hidden
  57872. */
  57873. _disable(cameras: Nullable<Camera[]>): void;
  57874. /**
  57875. * Gets a list of the post processes contained in the effect.
  57876. * @param camera The camera to get the post processes on.
  57877. * @returns The list of the post processes in the effect.
  57878. */
  57879. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57880. }
  57881. }
  57882. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57883. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57884. /** @hidden */
  57885. export var extractHighlightsPixelShader: {
  57886. name: string;
  57887. shader: string;
  57888. };
  57889. }
  57890. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57891. import { Nullable } from "babylonjs/types";
  57892. import { Camera } from "babylonjs/Cameras/camera";
  57893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57894. import { Engine } from "babylonjs/Engines/engine";
  57895. import "babylonjs/Shaders/extractHighlights.fragment";
  57896. /**
  57897. * 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.
  57898. */
  57899. export class ExtractHighlightsPostProcess extends PostProcess {
  57900. /**
  57901. * The luminance threshold, pixels below this value will be set to black.
  57902. */
  57903. threshold: number;
  57904. /** @hidden */
  57905. _exposure: number;
  57906. /**
  57907. * Post process which has the input texture to be used when performing highlight extraction
  57908. * @hidden
  57909. */
  57910. _inputPostProcess: Nullable<PostProcess>;
  57911. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57912. }
  57913. }
  57914. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57915. /** @hidden */
  57916. export var bloomMergePixelShader: {
  57917. name: string;
  57918. shader: string;
  57919. };
  57920. }
  57921. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57923. import { Nullable } from "babylonjs/types";
  57924. import { Engine } from "babylonjs/Engines/engine";
  57925. import { Camera } from "babylonjs/Cameras/camera";
  57926. import "babylonjs/Shaders/bloomMerge.fragment";
  57927. /**
  57928. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57929. */
  57930. export class BloomMergePostProcess extends PostProcess {
  57931. /** Weight of the bloom to be added to the original input. */
  57932. weight: number;
  57933. /**
  57934. * Creates a new instance of @see BloomMergePostProcess
  57935. * @param name The name of the effect.
  57936. * @param originalFromInput Post process which's input will be used for the merge.
  57937. * @param blurred Blurred highlights post process which's output will be used.
  57938. * @param weight Weight of the bloom to be added to the original input.
  57939. * @param options The required width/height ratio to downsize to before computing the render pass.
  57940. * @param camera The camera to apply the render pass to.
  57941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57942. * @param engine The engine which the post process will be applied. (default: current engine)
  57943. * @param reusable If the post process can be reused on the same frame. (default: false)
  57944. * @param textureType Type of textures used when performing the post process. (default: 0)
  57945. * @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)
  57946. */
  57947. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57948. /** Weight of the bloom to be added to the original input. */
  57949. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57950. }
  57951. }
  57952. declare module "babylonjs/PostProcesses/bloomEffect" {
  57953. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57954. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57955. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57956. import { Camera } from "babylonjs/Cameras/camera";
  57957. import { Scene } from "babylonjs/scene";
  57958. /**
  57959. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57960. */
  57961. export class BloomEffect extends PostProcessRenderEffect {
  57962. private bloomScale;
  57963. /**
  57964. * @hidden Internal
  57965. */
  57966. _effects: Array<PostProcess>;
  57967. /**
  57968. * @hidden Internal
  57969. */
  57970. _downscale: ExtractHighlightsPostProcess;
  57971. private _blurX;
  57972. private _blurY;
  57973. private _merge;
  57974. /**
  57975. * The luminance threshold to find bright areas of the image to bloom.
  57976. */
  57977. threshold: number;
  57978. /**
  57979. * The strength of the bloom.
  57980. */
  57981. weight: number;
  57982. /**
  57983. * Specifies the size of the bloom blur kernel, relative to the final output size
  57984. */
  57985. kernel: number;
  57986. /**
  57987. * Creates a new instance of @see BloomEffect
  57988. * @param scene The scene the effect belongs to.
  57989. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57990. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57991. * @param bloomWeight The the strength of bloom.
  57992. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57993. * @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)
  57994. */
  57995. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57996. /**
  57997. * Disposes each of the internal effects for a given camera.
  57998. * @param camera The camera to dispose the effect on.
  57999. */
  58000. disposeEffects(camera: Camera): void;
  58001. /**
  58002. * @hidden Internal
  58003. */
  58004. _updateEffects(): void;
  58005. /**
  58006. * Internal
  58007. * @returns if all the contained post processes are ready.
  58008. * @hidden
  58009. */
  58010. _isReady(): boolean;
  58011. }
  58012. }
  58013. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  58014. /** @hidden */
  58015. export var chromaticAberrationPixelShader: {
  58016. name: string;
  58017. shader: string;
  58018. };
  58019. }
  58020. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  58021. import { Vector2 } from "babylonjs/Maths/math";
  58022. import { Nullable } from "babylonjs/types";
  58023. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58024. import { Camera } from "babylonjs/Cameras/camera";
  58025. import { Engine } from "babylonjs/Engines/engine";
  58026. import "babylonjs/Shaders/chromaticAberration.fragment";
  58027. /**
  58028. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58029. */
  58030. export class ChromaticAberrationPostProcess extends PostProcess {
  58031. /**
  58032. * The amount of seperation of rgb channels (default: 30)
  58033. */
  58034. aberrationAmount: number;
  58035. /**
  58036. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58037. */
  58038. radialIntensity: number;
  58039. /**
  58040. * 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))
  58041. */
  58042. direction: Vector2;
  58043. /**
  58044. * 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))
  58045. */
  58046. centerPosition: Vector2;
  58047. /**
  58048. * Creates a new instance ChromaticAberrationPostProcess
  58049. * @param name The name of the effect.
  58050. * @param screenWidth The width of the screen to apply the effect on.
  58051. * @param screenHeight The height of the screen to apply the effect on.
  58052. * @param options The required width/height ratio to downsize to before computing the render pass.
  58053. * @param camera The camera to apply the render pass to.
  58054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58055. * @param engine The engine which the post process will be applied. (default: current engine)
  58056. * @param reusable If the post process can be reused on the same frame. (default: false)
  58057. * @param textureType Type of textures used when performing the post process. (default: 0)
  58058. * @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)
  58059. */
  58060. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58061. }
  58062. }
  58063. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58064. /** @hidden */
  58065. export var circleOfConfusionPixelShader: {
  58066. name: string;
  58067. shader: string;
  58068. };
  58069. }
  58070. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58071. import { Nullable } from "babylonjs/types";
  58072. import { Engine } from "babylonjs/Engines/engine";
  58073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58074. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58075. import { Camera } from "babylonjs/Cameras/camera";
  58076. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58077. /**
  58078. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58079. */
  58080. export class CircleOfConfusionPostProcess extends PostProcess {
  58081. /**
  58082. * 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.
  58083. */
  58084. lensSize: number;
  58085. /**
  58086. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58087. */
  58088. fStop: number;
  58089. /**
  58090. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58091. */
  58092. focusDistance: number;
  58093. /**
  58094. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58095. */
  58096. focalLength: number;
  58097. private _depthTexture;
  58098. /**
  58099. * Creates a new instance CircleOfConfusionPostProcess
  58100. * @param name The name of the effect.
  58101. * @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.
  58102. * @param options The required width/height ratio to downsize to before computing the render pass.
  58103. * @param camera The camera to apply the render pass to.
  58104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58105. * @param engine The engine which the post process will be applied. (default: current engine)
  58106. * @param reusable If the post process can be reused on the same frame. (default: false)
  58107. * @param textureType Type of textures used when performing the post process. (default: 0)
  58108. * @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)
  58109. */
  58110. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58111. /**
  58112. * 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.
  58113. */
  58114. depthTexture: RenderTargetTexture;
  58115. }
  58116. }
  58117. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58118. /** @hidden */
  58119. export var colorCorrectionPixelShader: {
  58120. name: string;
  58121. shader: string;
  58122. };
  58123. }
  58124. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58126. import { Engine } from "babylonjs/Engines/engine";
  58127. import { Camera } from "babylonjs/Cameras/camera";
  58128. import "babylonjs/Shaders/colorCorrection.fragment";
  58129. /**
  58130. *
  58131. * This post-process allows the modification of rendered colors by using
  58132. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58133. *
  58134. * The object needs to be provided an url to a texture containing the color
  58135. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58136. * Use an image editing software to tweak the LUT to match your needs.
  58137. *
  58138. * For an example of a color LUT, see here:
  58139. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58140. * For explanations on color grading, see here:
  58141. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58142. *
  58143. */
  58144. export class ColorCorrectionPostProcess extends PostProcess {
  58145. private _colorTableTexture;
  58146. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58147. }
  58148. }
  58149. declare module "babylonjs/Shaders/convolution.fragment" {
  58150. /** @hidden */
  58151. export var convolutionPixelShader: {
  58152. name: string;
  58153. shader: string;
  58154. };
  58155. }
  58156. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58158. import { Nullable } from "babylonjs/types";
  58159. import { Camera } from "babylonjs/Cameras/camera";
  58160. import { Engine } from "babylonjs/Engines/engine";
  58161. import "babylonjs/Shaders/convolution.fragment";
  58162. /**
  58163. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58164. * input texture to perform effects such as edge detection or sharpening
  58165. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58166. */
  58167. export class ConvolutionPostProcess extends PostProcess {
  58168. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58169. kernel: number[];
  58170. /**
  58171. * Creates a new instance ConvolutionPostProcess
  58172. * @param name The name of the effect.
  58173. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58174. * @param options The required width/height ratio to downsize to before computing the render pass.
  58175. * @param camera The camera to apply the render pass to.
  58176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58177. * @param engine The engine which the post process will be applied. (default: current engine)
  58178. * @param reusable If the post process can be reused on the same frame. (default: false)
  58179. * @param textureType Type of textures used when performing the post process. (default: 0)
  58180. */
  58181. constructor(name: string,
  58182. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58183. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58184. /**
  58185. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58186. */
  58187. static EdgeDetect0Kernel: number[];
  58188. /**
  58189. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58190. */
  58191. static EdgeDetect1Kernel: number[];
  58192. /**
  58193. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58194. */
  58195. static EdgeDetect2Kernel: number[];
  58196. /**
  58197. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58198. */
  58199. static SharpenKernel: number[];
  58200. /**
  58201. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58202. */
  58203. static EmbossKernel: number[];
  58204. /**
  58205. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58206. */
  58207. static GaussianKernel: number[];
  58208. }
  58209. }
  58210. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58211. import { Nullable } from "babylonjs/types";
  58212. import { Vector2 } from "babylonjs/Maths/math";
  58213. import { Camera } from "babylonjs/Cameras/camera";
  58214. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58215. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58216. import { Engine } from "babylonjs/Engines/engine";
  58217. import { Scene } from "babylonjs/scene";
  58218. /**
  58219. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58220. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58221. * based on samples that have a large difference in distance than the center pixel.
  58222. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58223. */
  58224. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58225. direction: Vector2;
  58226. /**
  58227. * Creates a new instance CircleOfConfusionPostProcess
  58228. * @param name The name of the effect.
  58229. * @param scene The scene the effect belongs to.
  58230. * @param direction The direction the blur should be applied.
  58231. * @param kernel The size of the kernel used to blur.
  58232. * @param options The required width/height ratio to downsize to before computing the render pass.
  58233. * @param camera The camera to apply the render pass to.
  58234. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58235. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58237. * @param engine The engine which the post process will be applied. (default: current engine)
  58238. * @param reusable If the post process can be reused on the same frame. (default: false)
  58239. * @param textureType Type of textures used when performing the post process. (default: 0)
  58240. * @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)
  58241. */
  58242. 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);
  58243. }
  58244. }
  58245. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58246. /** @hidden */
  58247. export var depthOfFieldMergePixelShader: {
  58248. name: string;
  58249. shader: string;
  58250. };
  58251. }
  58252. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58253. import { Nullable } from "babylonjs/types";
  58254. import { Camera } from "babylonjs/Cameras/camera";
  58255. import { Effect } from "babylonjs/Materials/effect";
  58256. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58257. import { Engine } from "babylonjs/Engines/engine";
  58258. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58259. /**
  58260. * Options to be set when merging outputs from the default pipeline.
  58261. */
  58262. export class DepthOfFieldMergePostProcessOptions {
  58263. /**
  58264. * The original image to merge on top of
  58265. */
  58266. originalFromInput: PostProcess;
  58267. /**
  58268. * Parameters to perform the merge of the depth of field effect
  58269. */
  58270. depthOfField?: {
  58271. circleOfConfusion: PostProcess;
  58272. blurSteps: Array<PostProcess>;
  58273. };
  58274. /**
  58275. * Parameters to perform the merge of bloom effect
  58276. */
  58277. bloom?: {
  58278. blurred: PostProcess;
  58279. weight: number;
  58280. };
  58281. }
  58282. /**
  58283. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58284. */
  58285. export class DepthOfFieldMergePostProcess extends PostProcess {
  58286. private blurSteps;
  58287. /**
  58288. * Creates a new instance of DepthOfFieldMergePostProcess
  58289. * @param name The name of the effect.
  58290. * @param originalFromInput Post process which's input will be used for the merge.
  58291. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58292. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58293. * @param options The required width/height ratio to downsize to before computing the render pass.
  58294. * @param camera The camera to apply the render pass to.
  58295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58296. * @param engine The engine which the post process will be applied. (default: current engine)
  58297. * @param reusable If the post process can be reused on the same frame. (default: false)
  58298. * @param textureType Type of textures used when performing the post process. (default: 0)
  58299. * @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)
  58300. */
  58301. 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);
  58302. /**
  58303. * Updates the effect with the current post process compile time values and recompiles the shader.
  58304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58307. * @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
  58308. * @param onCompiled Called when the shader has been compiled.
  58309. * @param onError Called if there is an error when compiling a shader.
  58310. */
  58311. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58312. }
  58313. }
  58314. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58315. import { Nullable } from "babylonjs/types";
  58316. import { Camera } from "babylonjs/Cameras/camera";
  58317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58318. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58319. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58320. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58321. import { Scene } from "babylonjs/scene";
  58322. /**
  58323. * Specifies the level of max blur that should be applied when using the depth of field effect
  58324. */
  58325. export enum DepthOfFieldEffectBlurLevel {
  58326. /**
  58327. * Subtle blur
  58328. */
  58329. Low = 0,
  58330. /**
  58331. * Medium blur
  58332. */
  58333. Medium = 1,
  58334. /**
  58335. * Large blur
  58336. */
  58337. High = 2
  58338. }
  58339. /**
  58340. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58341. */
  58342. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58343. private _circleOfConfusion;
  58344. /**
  58345. * @hidden Internal, blurs from high to low
  58346. */
  58347. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58348. private _depthOfFieldBlurY;
  58349. private _dofMerge;
  58350. /**
  58351. * @hidden Internal post processes in depth of field effect
  58352. */
  58353. _effects: Array<PostProcess>;
  58354. /**
  58355. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58356. */
  58357. focalLength: number;
  58358. /**
  58359. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58360. */
  58361. fStop: number;
  58362. /**
  58363. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58364. */
  58365. focusDistance: number;
  58366. /**
  58367. * 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.
  58368. */
  58369. lensSize: number;
  58370. /**
  58371. * Creates a new instance DepthOfFieldEffect
  58372. * @param scene The scene the effect belongs to.
  58373. * @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.
  58374. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58375. * @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)
  58376. */
  58377. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58378. /**
  58379. * Get the current class name of the current effet
  58380. * @returns "DepthOfFieldEffect"
  58381. */
  58382. getClassName(): string;
  58383. /**
  58384. * 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.
  58385. */
  58386. depthTexture: RenderTargetTexture;
  58387. /**
  58388. * Disposes each of the internal effects for a given camera.
  58389. * @param camera The camera to dispose the effect on.
  58390. */
  58391. disposeEffects(camera: Camera): void;
  58392. /**
  58393. * @hidden Internal
  58394. */
  58395. _updateEffects(): void;
  58396. /**
  58397. * Internal
  58398. * @returns if all the contained post processes are ready.
  58399. * @hidden
  58400. */
  58401. _isReady(): boolean;
  58402. }
  58403. }
  58404. declare module "babylonjs/Shaders/displayPass.fragment" {
  58405. /** @hidden */
  58406. export var displayPassPixelShader: {
  58407. name: string;
  58408. shader: string;
  58409. };
  58410. }
  58411. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58412. import { Nullable } from "babylonjs/types";
  58413. import { Camera } from "babylonjs/Cameras/camera";
  58414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58415. import { Engine } from "babylonjs/Engines/engine";
  58416. import "babylonjs/Shaders/displayPass.fragment";
  58417. /**
  58418. * DisplayPassPostProcess which produces an output the same as it's input
  58419. */
  58420. export class DisplayPassPostProcess extends PostProcess {
  58421. /**
  58422. * Creates the DisplayPassPostProcess
  58423. * @param name The name of the effect.
  58424. * @param options The required width/height ratio to downsize to before computing the render pass.
  58425. * @param camera The camera to apply the render pass to.
  58426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58427. * @param engine The engine which the post process will be applied. (default: current engine)
  58428. * @param reusable If the post process can be reused on the same frame. (default: false)
  58429. */
  58430. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58431. }
  58432. }
  58433. declare module "babylonjs/Shaders/filter.fragment" {
  58434. /** @hidden */
  58435. export var filterPixelShader: {
  58436. name: string;
  58437. shader: string;
  58438. };
  58439. }
  58440. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58441. import { Nullable } from "babylonjs/types";
  58442. import { Matrix } from "babylonjs/Maths/math";
  58443. import { Camera } from "babylonjs/Cameras/camera";
  58444. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58445. import { Engine } from "babylonjs/Engines/engine";
  58446. import "babylonjs/Shaders/filter.fragment";
  58447. /**
  58448. * Applies a kernel filter to the image
  58449. */
  58450. export class FilterPostProcess extends PostProcess {
  58451. /** The matrix to be applied to the image */
  58452. kernelMatrix: Matrix;
  58453. /**
  58454. *
  58455. * @param name The name of the effect.
  58456. * @param kernelMatrix The matrix to be applied to the image
  58457. * @param options The required width/height ratio to downsize to before computing the render pass.
  58458. * @param camera The camera to apply the render pass to.
  58459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58460. * @param engine The engine which the post process will be applied. (default: current engine)
  58461. * @param reusable If the post process can be reused on the same frame. (default: false)
  58462. */
  58463. constructor(name: string,
  58464. /** The matrix to be applied to the image */
  58465. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58466. }
  58467. }
  58468. declare module "babylonjs/Shaders/fxaa.fragment" {
  58469. /** @hidden */
  58470. export var fxaaPixelShader: {
  58471. name: string;
  58472. shader: string;
  58473. };
  58474. }
  58475. declare module "babylonjs/Shaders/fxaa.vertex" {
  58476. /** @hidden */
  58477. export var fxaaVertexShader: {
  58478. name: string;
  58479. shader: string;
  58480. };
  58481. }
  58482. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58483. import { Nullable } from "babylonjs/types";
  58484. import { Camera } from "babylonjs/Cameras/camera";
  58485. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58486. import { Engine } from "babylonjs/Engines/engine";
  58487. import "babylonjs/Shaders/fxaa.fragment";
  58488. import "babylonjs/Shaders/fxaa.vertex";
  58489. /**
  58490. * Fxaa post process
  58491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58492. */
  58493. export class FxaaPostProcess extends PostProcess {
  58494. /** @hidden */
  58495. texelWidth: number;
  58496. /** @hidden */
  58497. texelHeight: number;
  58498. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58499. private _getDefines;
  58500. }
  58501. }
  58502. declare module "babylonjs/Shaders/grain.fragment" {
  58503. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58504. /** @hidden */
  58505. export var grainPixelShader: {
  58506. name: string;
  58507. shader: string;
  58508. };
  58509. }
  58510. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58511. import { Nullable } from "babylonjs/types";
  58512. import { Camera } from "babylonjs/Cameras/camera";
  58513. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58514. import { Engine } from "babylonjs/Engines/engine";
  58515. import "babylonjs/Shaders/grain.fragment";
  58516. /**
  58517. * The GrainPostProcess adds noise to the image at mid luminance levels
  58518. */
  58519. export class GrainPostProcess extends PostProcess {
  58520. /**
  58521. * The intensity of the grain added (default: 30)
  58522. */
  58523. intensity: number;
  58524. /**
  58525. * If the grain should be randomized on every frame
  58526. */
  58527. animated: boolean;
  58528. /**
  58529. * Creates a new instance of @see GrainPostProcess
  58530. * @param name The name of the effect.
  58531. * @param options The required width/height ratio to downsize to before computing the render pass.
  58532. * @param camera The camera to apply the render pass to.
  58533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58534. * @param engine The engine which the post process will be applied. (default: current engine)
  58535. * @param reusable If the post process can be reused on the same frame. (default: false)
  58536. * @param textureType Type of textures used when performing the post process. (default: 0)
  58537. * @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)
  58538. */
  58539. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58540. }
  58541. }
  58542. declare module "babylonjs/Shaders/highlights.fragment" {
  58543. /** @hidden */
  58544. export var highlightsPixelShader: {
  58545. name: string;
  58546. shader: string;
  58547. };
  58548. }
  58549. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58550. import { Nullable } from "babylonjs/types";
  58551. import { Camera } from "babylonjs/Cameras/camera";
  58552. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58553. import { Engine } from "babylonjs/Engines/engine";
  58554. import "babylonjs/Shaders/highlights.fragment";
  58555. /**
  58556. * Extracts highlights from the image
  58557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58558. */
  58559. export class HighlightsPostProcess extends PostProcess {
  58560. /**
  58561. * Extracts highlights from the image
  58562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58563. * @param name The name of the effect.
  58564. * @param options The required width/height ratio to downsize to before computing the render pass.
  58565. * @param camera The camera to apply the render pass to.
  58566. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58567. * @param engine The engine which the post process will be applied. (default: current engine)
  58568. * @param reusable If the post process can be reused on the same frame. (default: false)
  58569. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58570. */
  58571. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58572. }
  58573. }
  58574. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58575. /** @hidden */
  58576. export var mrtFragmentDeclaration: {
  58577. name: string;
  58578. shader: string;
  58579. };
  58580. }
  58581. declare module "babylonjs/Shaders/geometry.fragment" {
  58582. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58583. /** @hidden */
  58584. export var geometryPixelShader: {
  58585. name: string;
  58586. shader: string;
  58587. };
  58588. }
  58589. declare module "babylonjs/Shaders/geometry.vertex" {
  58590. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58591. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58592. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58593. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58594. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58595. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58596. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58597. /** @hidden */
  58598. export var geometryVertexShader: {
  58599. name: string;
  58600. shader: string;
  58601. };
  58602. }
  58603. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58604. import { Matrix } from "babylonjs/Maths/math";
  58605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58606. import { Mesh } from "babylonjs/Meshes/mesh";
  58607. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58608. import { Effect } from "babylonjs/Materials/effect";
  58609. import { Scene } from "babylonjs/scene";
  58610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58611. import "babylonjs/Shaders/geometry.fragment";
  58612. import "babylonjs/Shaders/geometry.vertex";
  58613. /** @hidden */
  58614. interface ISavedTransformationMatrix {
  58615. world: Matrix;
  58616. viewProjection: Matrix;
  58617. }
  58618. /**
  58619. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58620. */
  58621. export class GeometryBufferRenderer {
  58622. /**
  58623. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58624. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58625. */
  58626. static readonly POSITION_TEXTURE_TYPE: number;
  58627. /**
  58628. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58629. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58630. */
  58631. static readonly VELOCITY_TEXTURE_TYPE: number;
  58632. /**
  58633. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58634. * in order to compute objects velocities when enableVelocity is set to "true"
  58635. * @hidden
  58636. */
  58637. _previousTransformationMatrices: {
  58638. [index: number]: ISavedTransformationMatrix;
  58639. };
  58640. /**
  58641. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58642. * in order to compute objects velocities when enableVelocity is set to "true"
  58643. * @hidden
  58644. */
  58645. _previousBonesTransformationMatrices: {
  58646. [index: number]: Float32Array;
  58647. };
  58648. /**
  58649. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58650. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58651. */
  58652. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58653. private _scene;
  58654. private _multiRenderTarget;
  58655. private _ratio;
  58656. private _enablePosition;
  58657. private _enableVelocity;
  58658. private _positionIndex;
  58659. private _velocityIndex;
  58660. protected _effect: Effect;
  58661. protected _cachedDefines: string;
  58662. /**
  58663. * Set the render list (meshes to be rendered) used in the G buffer.
  58664. */
  58665. renderList: Mesh[];
  58666. /**
  58667. * Gets wether or not G buffer are supported by the running hardware.
  58668. * This requires draw buffer supports
  58669. */
  58670. readonly isSupported: boolean;
  58671. /**
  58672. * Returns the index of the given texture type in the G-Buffer textures array
  58673. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58674. * @returns the index of the given texture type in the G-Buffer textures array
  58675. */
  58676. getTextureIndex(textureType: number): number;
  58677. /**
  58678. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58679. */
  58680. /**
  58681. * Sets whether or not objects positions are enabled for the G buffer.
  58682. */
  58683. enablePosition: boolean;
  58684. /**
  58685. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58686. */
  58687. /**
  58688. * Sets wether or not objects velocities are enabled for the G buffer.
  58689. */
  58690. enableVelocity: boolean;
  58691. /**
  58692. * Gets the scene associated with the buffer.
  58693. */
  58694. readonly scene: Scene;
  58695. /**
  58696. * Gets the ratio used by the buffer during its creation.
  58697. * How big is the buffer related to the main canvas.
  58698. */
  58699. readonly ratio: number;
  58700. /** @hidden */
  58701. static _SceneComponentInitialization: (scene: Scene) => void;
  58702. /**
  58703. * Creates a new G Buffer for the scene
  58704. * @param scene The scene the buffer belongs to
  58705. * @param ratio How big is the buffer related to the main canvas.
  58706. */
  58707. constructor(scene: Scene, ratio?: number);
  58708. /**
  58709. * Checks wether everything is ready to render a submesh to the G buffer.
  58710. * @param subMesh the submesh to check readiness for
  58711. * @param useInstances is the mesh drawn using instance or not
  58712. * @returns true if ready otherwise false
  58713. */
  58714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58715. /**
  58716. * Gets the current underlying G Buffer.
  58717. * @returns the buffer
  58718. */
  58719. getGBuffer(): MultiRenderTarget;
  58720. /**
  58721. * Gets the number of samples used to render the buffer (anti aliasing).
  58722. */
  58723. /**
  58724. * Sets the number of samples used to render the buffer (anti aliasing).
  58725. */
  58726. samples: number;
  58727. /**
  58728. * Disposes the renderer and frees up associated resources.
  58729. */
  58730. dispose(): void;
  58731. protected _createRenderTargets(): void;
  58732. private _copyBonesTransformationMatrices;
  58733. }
  58734. }
  58735. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58736. import { Nullable } from "babylonjs/types";
  58737. import { Scene } from "babylonjs/scene";
  58738. import { ISceneComponent } from "babylonjs/sceneComponent";
  58739. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58740. module "babylonjs/scene" {
  58741. interface Scene {
  58742. /** @hidden (Backing field) */
  58743. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58744. /**
  58745. * Gets or Sets the current geometry buffer associated to the scene.
  58746. */
  58747. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58748. /**
  58749. * Enables a GeometryBufferRender and associates it with the scene
  58750. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58751. * @returns the GeometryBufferRenderer
  58752. */
  58753. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58754. /**
  58755. * Disables the GeometryBufferRender associated with the scene
  58756. */
  58757. disableGeometryBufferRenderer(): void;
  58758. }
  58759. }
  58760. /**
  58761. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58762. * in several rendering techniques.
  58763. */
  58764. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58765. /**
  58766. * The component name helpful to identify the component in the list of scene components.
  58767. */
  58768. readonly name: string;
  58769. /**
  58770. * The scene the component belongs to.
  58771. */
  58772. scene: Scene;
  58773. /**
  58774. * Creates a new instance of the component for the given scene
  58775. * @param scene Defines the scene to register the component in
  58776. */
  58777. constructor(scene: Scene);
  58778. /**
  58779. * Registers the component in a given scene
  58780. */
  58781. register(): void;
  58782. /**
  58783. * Rebuilds the elements related to this component in case of
  58784. * context lost for instance.
  58785. */
  58786. rebuild(): void;
  58787. /**
  58788. * Disposes the component and the associated ressources
  58789. */
  58790. dispose(): void;
  58791. private _gatherRenderTargets;
  58792. }
  58793. }
  58794. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58795. /** @hidden */
  58796. export var motionBlurPixelShader: {
  58797. name: string;
  58798. shader: string;
  58799. };
  58800. }
  58801. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58802. import { Nullable } from "babylonjs/types";
  58803. import { Camera } from "babylonjs/Cameras/camera";
  58804. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58805. import { Scene } from "babylonjs/scene";
  58806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58807. import "babylonjs/Animations/animatable";
  58808. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58809. import "babylonjs/Shaders/motionBlur.fragment";
  58810. import { Engine } from "babylonjs/Engines/engine";
  58811. /**
  58812. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58813. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58814. * As an example, all you have to do is to create the post-process:
  58815. * var mb = new BABYLON.MotionBlurPostProcess(
  58816. * 'mb', // The name of the effect.
  58817. * scene, // The scene containing the objects to blur according to their velocity.
  58818. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58819. * camera // The camera to apply the render pass to.
  58820. * );
  58821. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58822. */
  58823. export class MotionBlurPostProcess extends PostProcess {
  58824. /**
  58825. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58826. */
  58827. motionStrength: number;
  58828. /**
  58829. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58830. */
  58831. /**
  58832. * Sets the number of iterations to be used for motion blur quality
  58833. */
  58834. motionBlurSamples: number;
  58835. private _motionBlurSamples;
  58836. private _geometryBufferRenderer;
  58837. /**
  58838. * Creates a new instance MotionBlurPostProcess
  58839. * @param name The name of the effect.
  58840. * @param scene The scene containing the objects to blur according to their velocity.
  58841. * @param options The required width/height ratio to downsize to before computing the render pass.
  58842. * @param camera The camera to apply the render pass to.
  58843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58844. * @param engine The engine which the post process will be applied. (default: current engine)
  58845. * @param reusable If the post process can be reused on the same frame. (default: false)
  58846. * @param textureType Type of textures used when performing the post process. (default: 0)
  58847. * @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)
  58848. */
  58849. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58850. /**
  58851. * Excludes the given skinned mesh from computing bones velocities.
  58852. * 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.
  58853. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58854. */
  58855. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58856. /**
  58857. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58858. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58859. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58860. */
  58861. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58862. /**
  58863. * Disposes the post process.
  58864. * @param camera The camera to dispose the post process on.
  58865. */
  58866. dispose(camera?: Camera): void;
  58867. }
  58868. }
  58869. declare module "babylonjs/Shaders/refraction.fragment" {
  58870. /** @hidden */
  58871. export var refractionPixelShader: {
  58872. name: string;
  58873. shader: string;
  58874. };
  58875. }
  58876. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58877. import { Color3 } from "babylonjs/Maths/math";
  58878. import { Camera } from "babylonjs/Cameras/camera";
  58879. import { Texture } from "babylonjs/Materials/Textures/texture";
  58880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58881. import { Engine } from "babylonjs/Engines/engine";
  58882. import "babylonjs/Shaders/refraction.fragment";
  58883. /**
  58884. * Post process which applies a refractin texture
  58885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58886. */
  58887. export class RefractionPostProcess extends PostProcess {
  58888. /** the base color of the refraction (used to taint the rendering) */
  58889. color: Color3;
  58890. /** simulated refraction depth */
  58891. depth: number;
  58892. /** the coefficient of the base color (0 to remove base color tainting) */
  58893. colorLevel: number;
  58894. private _refTexture;
  58895. private _ownRefractionTexture;
  58896. /**
  58897. * Gets or sets the refraction texture
  58898. * Please note that you are responsible for disposing the texture if you set it manually
  58899. */
  58900. refractionTexture: Texture;
  58901. /**
  58902. * Initializes the RefractionPostProcess
  58903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58904. * @param name The name of the effect.
  58905. * @param refractionTextureUrl Url of the refraction texture to use
  58906. * @param color the base color of the refraction (used to taint the rendering)
  58907. * @param depth simulated refraction depth
  58908. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58909. * @param camera The camera to apply the render pass to.
  58910. * @param options The required width/height ratio to downsize to before computing the render pass.
  58911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58912. * @param engine The engine which the post process will be applied. (default: current engine)
  58913. * @param reusable If the post process can be reused on the same frame. (default: false)
  58914. */
  58915. constructor(name: string, refractionTextureUrl: string,
  58916. /** the base color of the refraction (used to taint the rendering) */
  58917. color: Color3,
  58918. /** simulated refraction depth */
  58919. depth: number,
  58920. /** the coefficient of the base color (0 to remove base color tainting) */
  58921. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58922. /**
  58923. * Disposes of the post process
  58924. * @param camera Camera to dispose post process on
  58925. */
  58926. dispose(camera: Camera): void;
  58927. }
  58928. }
  58929. declare module "babylonjs/Shaders/sharpen.fragment" {
  58930. /** @hidden */
  58931. export var sharpenPixelShader: {
  58932. name: string;
  58933. shader: string;
  58934. };
  58935. }
  58936. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58937. import { Nullable } from "babylonjs/types";
  58938. import { Camera } from "babylonjs/Cameras/camera";
  58939. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58940. import "babylonjs/Shaders/sharpen.fragment";
  58941. import { Engine } from "babylonjs/Engines/engine";
  58942. /**
  58943. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58944. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58945. */
  58946. export class SharpenPostProcess extends PostProcess {
  58947. /**
  58948. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58949. */
  58950. colorAmount: number;
  58951. /**
  58952. * How much sharpness should be applied (default: 0.3)
  58953. */
  58954. edgeAmount: number;
  58955. /**
  58956. * Creates a new instance ConvolutionPostProcess
  58957. * @param name The name of the effect.
  58958. * @param options The required width/height ratio to downsize to before computing the render pass.
  58959. * @param camera The camera to apply the render pass to.
  58960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58961. * @param engine The engine which the post process will be applied. (default: current engine)
  58962. * @param reusable If the post process can be reused on the same frame. (default: false)
  58963. * @param textureType Type of textures used when performing the post process. (default: 0)
  58964. * @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)
  58965. */
  58966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58967. }
  58968. }
  58969. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58970. import { Nullable } from "babylonjs/types";
  58971. import { Camera } from "babylonjs/Cameras/camera";
  58972. import { Engine } from "babylonjs/Engines/engine";
  58973. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58974. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58975. /**
  58976. * PostProcessRenderPipeline
  58977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58978. */
  58979. export class PostProcessRenderPipeline {
  58980. private engine;
  58981. private _renderEffects;
  58982. private _renderEffectsForIsolatedPass;
  58983. /**
  58984. * List of inspectable custom properties (used by the Inspector)
  58985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58986. */
  58987. inspectableCustomProperties: IInspectable[];
  58988. /**
  58989. * @hidden
  58990. */
  58991. protected _cameras: Camera[];
  58992. /** @hidden */
  58993. _name: string;
  58994. /**
  58995. * Gets pipeline name
  58996. */
  58997. readonly name: string;
  58998. /**
  58999. * Initializes a PostProcessRenderPipeline
  59000. * @param engine engine to add the pipeline to
  59001. * @param name name of the pipeline
  59002. */
  59003. constructor(engine: Engine, name: string);
  59004. /**
  59005. * Gets the class name
  59006. * @returns "PostProcessRenderPipeline"
  59007. */
  59008. getClassName(): string;
  59009. /**
  59010. * If all the render effects in the pipeline are supported
  59011. */
  59012. readonly isSupported: boolean;
  59013. /**
  59014. * Adds an effect to the pipeline
  59015. * @param renderEffect the effect to add
  59016. */
  59017. addEffect(renderEffect: PostProcessRenderEffect): void;
  59018. /** @hidden */
  59019. _rebuild(): void;
  59020. /** @hidden */
  59021. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59022. /** @hidden */
  59023. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59024. /** @hidden */
  59025. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59026. /** @hidden */
  59027. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59028. /** @hidden */
  59029. _attachCameras(cameras: Camera, unique: boolean): void;
  59030. /** @hidden */
  59031. _attachCameras(cameras: Camera[], unique: boolean): void;
  59032. /** @hidden */
  59033. _detachCameras(cameras: Camera): void;
  59034. /** @hidden */
  59035. _detachCameras(cameras: Nullable<Camera[]>): void;
  59036. /** @hidden */
  59037. _update(): void;
  59038. /** @hidden */
  59039. _reset(): void;
  59040. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59041. /**
  59042. * Disposes of the pipeline
  59043. */
  59044. dispose(): void;
  59045. }
  59046. }
  59047. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  59048. import { Camera } from "babylonjs/Cameras/camera";
  59049. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59050. /**
  59051. * PostProcessRenderPipelineManager class
  59052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59053. */
  59054. export class PostProcessRenderPipelineManager {
  59055. private _renderPipelines;
  59056. /**
  59057. * Initializes a PostProcessRenderPipelineManager
  59058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59059. */
  59060. constructor();
  59061. /**
  59062. * Gets the list of supported render pipelines
  59063. */
  59064. readonly supportedPipelines: PostProcessRenderPipeline[];
  59065. /**
  59066. * Adds a pipeline to the manager
  59067. * @param renderPipeline The pipeline to add
  59068. */
  59069. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59070. /**
  59071. * Attaches a camera to the pipeline
  59072. * @param renderPipelineName The name of the pipeline to attach to
  59073. * @param cameras the camera to attach
  59074. * @param unique if the camera can be attached multiple times to the pipeline
  59075. */
  59076. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59077. /**
  59078. * Detaches a camera from the pipeline
  59079. * @param renderPipelineName The name of the pipeline to detach from
  59080. * @param cameras the camera to detach
  59081. */
  59082. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59083. /**
  59084. * Enables an effect by name on a pipeline
  59085. * @param renderPipelineName the name of the pipeline to enable the effect in
  59086. * @param renderEffectName the name of the effect to enable
  59087. * @param cameras the cameras that the effect should be enabled on
  59088. */
  59089. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59090. /**
  59091. * Disables an effect by name on a pipeline
  59092. * @param renderPipelineName the name of the pipeline to disable the effect in
  59093. * @param renderEffectName the name of the effect to disable
  59094. * @param cameras the cameras that the effect should be disabled on
  59095. */
  59096. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59097. /**
  59098. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59099. */
  59100. update(): void;
  59101. /** @hidden */
  59102. _rebuild(): void;
  59103. /**
  59104. * Disposes of the manager and pipelines
  59105. */
  59106. dispose(): void;
  59107. }
  59108. }
  59109. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59110. import { ISceneComponent } from "babylonjs/sceneComponent";
  59111. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59112. import { Scene } from "babylonjs/scene";
  59113. module "babylonjs/scene" {
  59114. interface Scene {
  59115. /** @hidden (Backing field) */
  59116. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59117. /**
  59118. * Gets the postprocess render pipeline manager
  59119. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59120. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59121. */
  59122. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59123. }
  59124. }
  59125. /**
  59126. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59127. */
  59128. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59129. /**
  59130. * The component name helpfull to identify the component in the list of scene components.
  59131. */
  59132. readonly name: string;
  59133. /**
  59134. * The scene the component belongs to.
  59135. */
  59136. scene: Scene;
  59137. /**
  59138. * Creates a new instance of the component for the given scene
  59139. * @param scene Defines the scene to register the component in
  59140. */
  59141. constructor(scene: Scene);
  59142. /**
  59143. * Registers the component in a given scene
  59144. */
  59145. register(): void;
  59146. /**
  59147. * Rebuilds the elements related to this component in case of
  59148. * context lost for instance.
  59149. */
  59150. rebuild(): void;
  59151. /**
  59152. * Disposes the component and the associated ressources
  59153. */
  59154. dispose(): void;
  59155. private _gatherRenderTargets;
  59156. }
  59157. }
  59158. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59159. import { Nullable } from "babylonjs/types";
  59160. import { IAnimatable } from "babylonjs/Misc/tools";
  59161. import { Camera } from "babylonjs/Cameras/camera";
  59162. import { IDisposable } from "babylonjs/scene";
  59163. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59164. import { Scene } from "babylonjs/scene";
  59165. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59166. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59167. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59168. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59169. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59170. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59171. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59172. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59173. import { Animation } from "babylonjs/Animations/animation";
  59174. /**
  59175. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59176. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59177. */
  59178. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59179. private _scene;
  59180. private _camerasToBeAttached;
  59181. /**
  59182. * ID of the sharpen post process,
  59183. */
  59184. private readonly SharpenPostProcessId;
  59185. /**
  59186. * @ignore
  59187. * ID of the image processing post process;
  59188. */
  59189. readonly ImageProcessingPostProcessId: string;
  59190. /**
  59191. * @ignore
  59192. * ID of the Fast Approximate Anti-Aliasing post process;
  59193. */
  59194. readonly FxaaPostProcessId: string;
  59195. /**
  59196. * ID of the chromatic aberration post process,
  59197. */
  59198. private readonly ChromaticAberrationPostProcessId;
  59199. /**
  59200. * ID of the grain post process
  59201. */
  59202. private readonly GrainPostProcessId;
  59203. /**
  59204. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59205. */
  59206. sharpen: SharpenPostProcess;
  59207. private _sharpenEffect;
  59208. private bloom;
  59209. /**
  59210. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59211. */
  59212. depthOfField: DepthOfFieldEffect;
  59213. /**
  59214. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59215. */
  59216. fxaa: FxaaPostProcess;
  59217. /**
  59218. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59219. */
  59220. imageProcessing: ImageProcessingPostProcess;
  59221. /**
  59222. * Chromatic aberration post process which will shift rgb colors in the image
  59223. */
  59224. chromaticAberration: ChromaticAberrationPostProcess;
  59225. private _chromaticAberrationEffect;
  59226. /**
  59227. * Grain post process which add noise to the image
  59228. */
  59229. grain: GrainPostProcess;
  59230. private _grainEffect;
  59231. /**
  59232. * Glow post process which adds a glow to emissive areas of the image
  59233. */
  59234. private _glowLayer;
  59235. /**
  59236. * Animations which can be used to tweak settings over a period of time
  59237. */
  59238. animations: Animation[];
  59239. private _imageProcessingConfigurationObserver;
  59240. private _sharpenEnabled;
  59241. private _bloomEnabled;
  59242. private _depthOfFieldEnabled;
  59243. private _depthOfFieldBlurLevel;
  59244. private _fxaaEnabled;
  59245. private _imageProcessingEnabled;
  59246. private _defaultPipelineTextureType;
  59247. private _bloomScale;
  59248. private _chromaticAberrationEnabled;
  59249. private _grainEnabled;
  59250. private _buildAllowed;
  59251. /**
  59252. * Gets active scene
  59253. */
  59254. readonly scene: Scene;
  59255. /**
  59256. * Enable or disable the sharpen process from the pipeline
  59257. */
  59258. sharpenEnabled: boolean;
  59259. private _resizeObserver;
  59260. private _hardwareScaleLevel;
  59261. private _bloomKernel;
  59262. /**
  59263. * Specifies the size of the bloom blur kernel, relative to the final output size
  59264. */
  59265. bloomKernel: number;
  59266. /**
  59267. * Specifies the weight of the bloom in the final rendering
  59268. */
  59269. private _bloomWeight;
  59270. /**
  59271. * Specifies the luma threshold for the area that will be blurred by the bloom
  59272. */
  59273. private _bloomThreshold;
  59274. private _hdr;
  59275. /**
  59276. * The strength of the bloom.
  59277. */
  59278. bloomWeight: number;
  59279. /**
  59280. * The strength of the bloom.
  59281. */
  59282. bloomThreshold: number;
  59283. /**
  59284. * The scale of the bloom, lower value will provide better performance.
  59285. */
  59286. bloomScale: number;
  59287. /**
  59288. * Enable or disable the bloom from the pipeline
  59289. */
  59290. bloomEnabled: boolean;
  59291. private _rebuildBloom;
  59292. /**
  59293. * If the depth of field is enabled.
  59294. */
  59295. depthOfFieldEnabled: boolean;
  59296. /**
  59297. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59298. */
  59299. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59300. /**
  59301. * If the anti aliasing is enabled.
  59302. */
  59303. fxaaEnabled: boolean;
  59304. private _samples;
  59305. /**
  59306. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59307. */
  59308. samples: number;
  59309. /**
  59310. * If image processing is enabled.
  59311. */
  59312. imageProcessingEnabled: boolean;
  59313. /**
  59314. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59315. */
  59316. glowLayerEnabled: boolean;
  59317. /**
  59318. * Gets the glow layer (or null if not defined)
  59319. */
  59320. readonly glowLayer: Nullable<GlowLayer>;
  59321. /**
  59322. * Enable or disable the chromaticAberration process from the pipeline
  59323. */
  59324. chromaticAberrationEnabled: boolean;
  59325. /**
  59326. * Enable or disable the grain process from the pipeline
  59327. */
  59328. grainEnabled: boolean;
  59329. /**
  59330. * @constructor
  59331. * @param name - The rendering pipeline name (default: "")
  59332. * @param hdr - If high dynamic range textures should be used (default: true)
  59333. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59334. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59335. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59336. */
  59337. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59338. /**
  59339. * Get the class name
  59340. * @returns "DefaultRenderingPipeline"
  59341. */
  59342. getClassName(): string;
  59343. /**
  59344. * Force the compilation of the entire pipeline.
  59345. */
  59346. prepare(): void;
  59347. private _hasCleared;
  59348. private _prevPostProcess;
  59349. private _prevPrevPostProcess;
  59350. private _setAutoClearAndTextureSharing;
  59351. private _depthOfFieldSceneObserver;
  59352. private _buildPipeline;
  59353. private _disposePostProcesses;
  59354. /**
  59355. * Adds a camera to the pipeline
  59356. * @param camera the camera to be added
  59357. */
  59358. addCamera(camera: Camera): void;
  59359. /**
  59360. * Removes a camera from the pipeline
  59361. * @param camera the camera to remove
  59362. */
  59363. removeCamera(camera: Camera): void;
  59364. /**
  59365. * Dispose of the pipeline and stop all post processes
  59366. */
  59367. dispose(): void;
  59368. /**
  59369. * Serialize the rendering pipeline (Used when exporting)
  59370. * @returns the serialized object
  59371. */
  59372. serialize(): any;
  59373. /**
  59374. * Parse the serialized pipeline
  59375. * @param source Source pipeline.
  59376. * @param scene The scene to load the pipeline to.
  59377. * @param rootUrl The URL of the serialized pipeline.
  59378. * @returns An instantiated pipeline from the serialized object.
  59379. */
  59380. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59381. }
  59382. }
  59383. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59384. /** @hidden */
  59385. export var lensHighlightsPixelShader: {
  59386. name: string;
  59387. shader: string;
  59388. };
  59389. }
  59390. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59391. /** @hidden */
  59392. export var depthOfFieldPixelShader: {
  59393. name: string;
  59394. shader: string;
  59395. };
  59396. }
  59397. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59398. import { Camera } from "babylonjs/Cameras/camera";
  59399. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59400. import { Scene } from "babylonjs/scene";
  59401. import "babylonjs/Shaders/chromaticAberration.fragment";
  59402. import "babylonjs/Shaders/lensHighlights.fragment";
  59403. import "babylonjs/Shaders/depthOfField.fragment";
  59404. /**
  59405. * BABYLON.JS Chromatic Aberration GLSL Shader
  59406. * Author: Olivier Guyot
  59407. * Separates very slightly R, G and B colors on the edges of the screen
  59408. * Inspired by Francois Tarlier & Martins Upitis
  59409. */
  59410. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59411. /**
  59412. * @ignore
  59413. * The chromatic aberration PostProcess id in the pipeline
  59414. */
  59415. LensChromaticAberrationEffect: string;
  59416. /**
  59417. * @ignore
  59418. * The highlights enhancing PostProcess id in the pipeline
  59419. */
  59420. HighlightsEnhancingEffect: string;
  59421. /**
  59422. * @ignore
  59423. * The depth-of-field PostProcess id in the pipeline
  59424. */
  59425. LensDepthOfFieldEffect: string;
  59426. private _scene;
  59427. private _depthTexture;
  59428. private _grainTexture;
  59429. private _chromaticAberrationPostProcess;
  59430. private _highlightsPostProcess;
  59431. private _depthOfFieldPostProcess;
  59432. private _edgeBlur;
  59433. private _grainAmount;
  59434. private _chromaticAberration;
  59435. private _distortion;
  59436. private _highlightsGain;
  59437. private _highlightsThreshold;
  59438. private _dofDistance;
  59439. private _dofAperture;
  59440. private _dofDarken;
  59441. private _dofPentagon;
  59442. private _blurNoise;
  59443. /**
  59444. * @constructor
  59445. *
  59446. * Effect parameters are as follow:
  59447. * {
  59448. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59449. * edge_blur: number; // from 0 to x (1 for realism)
  59450. * distortion: number; // from 0 to x (1 for realism)
  59451. * grain_amount: number; // from 0 to 1
  59452. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59453. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59454. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59455. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59456. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59457. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59458. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59459. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59460. * }
  59461. * Note: if an effect parameter is unset, effect is disabled
  59462. *
  59463. * @param name The rendering pipeline name
  59464. * @param parameters - An object containing all parameters (see above)
  59465. * @param scene The scene linked to this pipeline
  59466. * @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)
  59467. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59468. */
  59469. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59470. /**
  59471. * Get the class name
  59472. * @returns "LensRenderingPipeline"
  59473. */
  59474. getClassName(): string;
  59475. /**
  59476. * Gets associated scene
  59477. */
  59478. readonly scene: Scene;
  59479. /**
  59480. * Gets or sets the edge blur
  59481. */
  59482. edgeBlur: number;
  59483. /**
  59484. * Gets or sets the grain amount
  59485. */
  59486. grainAmount: number;
  59487. /**
  59488. * Gets or sets the chromatic aberration amount
  59489. */
  59490. chromaticAberration: number;
  59491. /**
  59492. * Gets or sets the depth of field aperture
  59493. */
  59494. dofAperture: number;
  59495. /**
  59496. * Gets or sets the edge distortion
  59497. */
  59498. edgeDistortion: number;
  59499. /**
  59500. * Gets or sets the depth of field distortion
  59501. */
  59502. dofDistortion: number;
  59503. /**
  59504. * Gets or sets the darken out of focus amount
  59505. */
  59506. darkenOutOfFocus: number;
  59507. /**
  59508. * Gets or sets a boolean indicating if blur noise is enabled
  59509. */
  59510. blurNoise: boolean;
  59511. /**
  59512. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59513. */
  59514. pentagonBokeh: boolean;
  59515. /**
  59516. * Gets or sets the highlight grain amount
  59517. */
  59518. highlightsGain: number;
  59519. /**
  59520. * Gets or sets the highlight threshold
  59521. */
  59522. highlightsThreshold: number;
  59523. /**
  59524. * Sets the amount of blur at the edges
  59525. * @param amount blur amount
  59526. */
  59527. setEdgeBlur(amount: number): void;
  59528. /**
  59529. * Sets edge blur to 0
  59530. */
  59531. disableEdgeBlur(): void;
  59532. /**
  59533. * Sets the amout of grain
  59534. * @param amount Amount of grain
  59535. */
  59536. setGrainAmount(amount: number): void;
  59537. /**
  59538. * Set grain amount to 0
  59539. */
  59540. disableGrain(): void;
  59541. /**
  59542. * Sets the chromatic aberration amount
  59543. * @param amount amount of chromatic aberration
  59544. */
  59545. setChromaticAberration(amount: number): void;
  59546. /**
  59547. * Sets chromatic aberration amount to 0
  59548. */
  59549. disableChromaticAberration(): void;
  59550. /**
  59551. * Sets the EdgeDistortion amount
  59552. * @param amount amount of EdgeDistortion
  59553. */
  59554. setEdgeDistortion(amount: number): void;
  59555. /**
  59556. * Sets edge distortion to 0
  59557. */
  59558. disableEdgeDistortion(): void;
  59559. /**
  59560. * Sets the FocusDistance amount
  59561. * @param amount amount of FocusDistance
  59562. */
  59563. setFocusDistance(amount: number): void;
  59564. /**
  59565. * Disables depth of field
  59566. */
  59567. disableDepthOfField(): void;
  59568. /**
  59569. * Sets the Aperture amount
  59570. * @param amount amount of Aperture
  59571. */
  59572. setAperture(amount: number): void;
  59573. /**
  59574. * Sets the DarkenOutOfFocus amount
  59575. * @param amount amount of DarkenOutOfFocus
  59576. */
  59577. setDarkenOutOfFocus(amount: number): void;
  59578. private _pentagonBokehIsEnabled;
  59579. /**
  59580. * Creates a pentagon bokeh effect
  59581. */
  59582. enablePentagonBokeh(): void;
  59583. /**
  59584. * Disables the pentagon bokeh effect
  59585. */
  59586. disablePentagonBokeh(): void;
  59587. /**
  59588. * Enables noise blur
  59589. */
  59590. enableNoiseBlur(): void;
  59591. /**
  59592. * Disables noise blur
  59593. */
  59594. disableNoiseBlur(): void;
  59595. /**
  59596. * Sets the HighlightsGain amount
  59597. * @param amount amount of HighlightsGain
  59598. */
  59599. setHighlightsGain(amount: number): void;
  59600. /**
  59601. * Sets the HighlightsThreshold amount
  59602. * @param amount amount of HighlightsThreshold
  59603. */
  59604. setHighlightsThreshold(amount: number): void;
  59605. /**
  59606. * Disables highlights
  59607. */
  59608. disableHighlights(): void;
  59609. /**
  59610. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59611. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59612. */
  59613. dispose(disableDepthRender?: boolean): void;
  59614. private _createChromaticAberrationPostProcess;
  59615. private _createHighlightsPostProcess;
  59616. private _createDepthOfFieldPostProcess;
  59617. private _createGrainTexture;
  59618. }
  59619. }
  59620. declare module "babylonjs/Shaders/ssao2.fragment" {
  59621. /** @hidden */
  59622. export var ssao2PixelShader: {
  59623. name: string;
  59624. shader: string;
  59625. };
  59626. }
  59627. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59628. /** @hidden */
  59629. export var ssaoCombinePixelShader: {
  59630. name: string;
  59631. shader: string;
  59632. };
  59633. }
  59634. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59635. import { Camera } from "babylonjs/Cameras/camera";
  59636. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59637. import { Scene } from "babylonjs/scene";
  59638. import "babylonjs/Shaders/ssao2.fragment";
  59639. import "babylonjs/Shaders/ssaoCombine.fragment";
  59640. /**
  59641. * Render pipeline to produce ssao effect
  59642. */
  59643. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59644. /**
  59645. * @ignore
  59646. * The PassPostProcess id in the pipeline that contains the original scene color
  59647. */
  59648. SSAOOriginalSceneColorEffect: string;
  59649. /**
  59650. * @ignore
  59651. * The SSAO PostProcess id in the pipeline
  59652. */
  59653. SSAORenderEffect: string;
  59654. /**
  59655. * @ignore
  59656. * The horizontal blur PostProcess id in the pipeline
  59657. */
  59658. SSAOBlurHRenderEffect: string;
  59659. /**
  59660. * @ignore
  59661. * The vertical blur PostProcess id in the pipeline
  59662. */
  59663. SSAOBlurVRenderEffect: string;
  59664. /**
  59665. * @ignore
  59666. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59667. */
  59668. SSAOCombineRenderEffect: string;
  59669. /**
  59670. * The output strength of the SSAO post-process. Default value is 1.0.
  59671. */
  59672. totalStrength: number;
  59673. /**
  59674. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59675. */
  59676. maxZ: number;
  59677. /**
  59678. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59679. */
  59680. minZAspect: number;
  59681. private _samples;
  59682. /**
  59683. * Number of samples used for the SSAO calculations. Default value is 8
  59684. */
  59685. samples: number;
  59686. private _textureSamples;
  59687. /**
  59688. * Number of samples to use for antialiasing
  59689. */
  59690. textureSamples: number;
  59691. /**
  59692. * Ratio object used for SSAO ratio and blur ratio
  59693. */
  59694. private _ratio;
  59695. /**
  59696. * Dynamically generated sphere sampler.
  59697. */
  59698. private _sampleSphere;
  59699. /**
  59700. * Blur filter offsets
  59701. */
  59702. private _samplerOffsets;
  59703. private _expensiveBlur;
  59704. /**
  59705. * If bilateral blur should be used
  59706. */
  59707. expensiveBlur: boolean;
  59708. /**
  59709. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59710. */
  59711. radius: number;
  59712. /**
  59713. * The base color of the SSAO post-process
  59714. * The final result is "base + ssao" between [0, 1]
  59715. */
  59716. base: number;
  59717. /**
  59718. * Support test.
  59719. */
  59720. static readonly IsSupported: boolean;
  59721. private _scene;
  59722. private _depthTexture;
  59723. private _normalTexture;
  59724. private _randomTexture;
  59725. private _originalColorPostProcess;
  59726. private _ssaoPostProcess;
  59727. private _blurHPostProcess;
  59728. private _blurVPostProcess;
  59729. private _ssaoCombinePostProcess;
  59730. private _firstUpdate;
  59731. /**
  59732. * Gets active scene
  59733. */
  59734. readonly scene: Scene;
  59735. /**
  59736. * @constructor
  59737. * @param name The rendering pipeline name
  59738. * @param scene The scene linked to this pipeline
  59739. * @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 }
  59740. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59741. */
  59742. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59743. /**
  59744. * Get the class name
  59745. * @returns "SSAO2RenderingPipeline"
  59746. */
  59747. getClassName(): string;
  59748. /**
  59749. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59750. */
  59751. dispose(disableGeometryBufferRenderer?: boolean): void;
  59752. private _createBlurPostProcess;
  59753. /** @hidden */
  59754. _rebuild(): void;
  59755. private _bits;
  59756. private _radicalInverse_VdC;
  59757. private _hammersley;
  59758. private _hemisphereSample_uniform;
  59759. private _generateHemisphere;
  59760. private _createSSAOPostProcess;
  59761. private _createSSAOCombinePostProcess;
  59762. private _createRandomTexture;
  59763. /**
  59764. * Serialize the rendering pipeline (Used when exporting)
  59765. * @returns the serialized object
  59766. */
  59767. serialize(): any;
  59768. /**
  59769. * Parse the serialized pipeline
  59770. * @param source Source pipeline.
  59771. * @param scene The scene to load the pipeline to.
  59772. * @param rootUrl The URL of the serialized pipeline.
  59773. * @returns An instantiated pipeline from the serialized object.
  59774. */
  59775. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59776. }
  59777. }
  59778. declare module "babylonjs/Shaders/ssao.fragment" {
  59779. /** @hidden */
  59780. export var ssaoPixelShader: {
  59781. name: string;
  59782. shader: string;
  59783. };
  59784. }
  59785. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59786. import { Camera } from "babylonjs/Cameras/camera";
  59787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59788. import { Scene } from "babylonjs/scene";
  59789. import "babylonjs/Shaders/ssao.fragment";
  59790. import "babylonjs/Shaders/ssaoCombine.fragment";
  59791. /**
  59792. * Render pipeline to produce ssao effect
  59793. */
  59794. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59795. /**
  59796. * @ignore
  59797. * The PassPostProcess id in the pipeline that contains the original scene color
  59798. */
  59799. SSAOOriginalSceneColorEffect: string;
  59800. /**
  59801. * @ignore
  59802. * The SSAO PostProcess id in the pipeline
  59803. */
  59804. SSAORenderEffect: string;
  59805. /**
  59806. * @ignore
  59807. * The horizontal blur PostProcess id in the pipeline
  59808. */
  59809. SSAOBlurHRenderEffect: string;
  59810. /**
  59811. * @ignore
  59812. * The vertical blur PostProcess id in the pipeline
  59813. */
  59814. SSAOBlurVRenderEffect: string;
  59815. /**
  59816. * @ignore
  59817. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59818. */
  59819. SSAOCombineRenderEffect: string;
  59820. /**
  59821. * The output strength of the SSAO post-process. Default value is 1.0.
  59822. */
  59823. totalStrength: number;
  59824. /**
  59825. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59826. */
  59827. radius: number;
  59828. /**
  59829. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59830. * Must not be equal to fallOff and superior to fallOff.
  59831. * Default value is 0.0075
  59832. */
  59833. area: number;
  59834. /**
  59835. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59836. * Must not be equal to area and inferior to area.
  59837. * Default value is 0.000001
  59838. */
  59839. fallOff: number;
  59840. /**
  59841. * The base color of the SSAO post-process
  59842. * The final result is "base + ssao" between [0, 1]
  59843. */
  59844. base: number;
  59845. private _scene;
  59846. private _depthTexture;
  59847. private _randomTexture;
  59848. private _originalColorPostProcess;
  59849. private _ssaoPostProcess;
  59850. private _blurHPostProcess;
  59851. private _blurVPostProcess;
  59852. private _ssaoCombinePostProcess;
  59853. private _firstUpdate;
  59854. /**
  59855. * Gets active scene
  59856. */
  59857. readonly scene: Scene;
  59858. /**
  59859. * @constructor
  59860. * @param name - The rendering pipeline name
  59861. * @param scene - The scene linked to this pipeline
  59862. * @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 }
  59863. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59864. */
  59865. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59866. /**
  59867. * Get the class name
  59868. * @returns "SSAORenderingPipeline"
  59869. */
  59870. getClassName(): string;
  59871. /**
  59872. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59873. */
  59874. dispose(disableDepthRender?: boolean): void;
  59875. private _createBlurPostProcess;
  59876. /** @hidden */
  59877. _rebuild(): void;
  59878. private _createSSAOPostProcess;
  59879. private _createSSAOCombinePostProcess;
  59880. private _createRandomTexture;
  59881. }
  59882. }
  59883. declare module "babylonjs/Shaders/standard.fragment" {
  59884. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  59885. /** @hidden */
  59886. export var standardPixelShader: {
  59887. name: string;
  59888. shader: string;
  59889. };
  59890. }
  59891. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59892. import { Nullable } from "babylonjs/types";
  59893. import { IAnimatable } from "babylonjs/Misc/tools";
  59894. import { Camera } from "babylonjs/Cameras/camera";
  59895. import { Texture } from "babylonjs/Materials/Textures/texture";
  59896. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59897. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59898. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59899. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59900. import { IDisposable } from "babylonjs/scene";
  59901. import { SpotLight } from "babylonjs/Lights/spotLight";
  59902. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59903. import { Scene } from "babylonjs/scene";
  59904. import { Animation } from "babylonjs/Animations/animation";
  59905. import "babylonjs/Shaders/standard.fragment";
  59906. /**
  59907. * Standard rendering pipeline
  59908. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59909. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59910. */
  59911. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59912. /**
  59913. * Public members
  59914. */
  59915. /**
  59916. * Post-process which contains the original scene color before the pipeline applies all the effects
  59917. */
  59918. originalPostProcess: Nullable<PostProcess>;
  59919. /**
  59920. * Post-process used to down scale an image x4
  59921. */
  59922. downSampleX4PostProcess: Nullable<PostProcess>;
  59923. /**
  59924. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59925. */
  59926. brightPassPostProcess: Nullable<PostProcess>;
  59927. /**
  59928. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59929. */
  59930. blurHPostProcesses: PostProcess[];
  59931. /**
  59932. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59933. */
  59934. blurVPostProcesses: PostProcess[];
  59935. /**
  59936. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59937. */
  59938. textureAdderPostProcess: Nullable<PostProcess>;
  59939. /**
  59940. * Post-process used to create volumetric lighting effect
  59941. */
  59942. volumetricLightPostProcess: Nullable<PostProcess>;
  59943. /**
  59944. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59945. */
  59946. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59947. /**
  59948. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59949. */
  59950. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59951. /**
  59952. * Post-process used to merge the volumetric light effect and the real scene color
  59953. */
  59954. volumetricLightMergePostProces: Nullable<PostProcess>;
  59955. /**
  59956. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59957. */
  59958. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59959. /**
  59960. * Base post-process used to calculate the average luminance of the final image for HDR
  59961. */
  59962. luminancePostProcess: Nullable<PostProcess>;
  59963. /**
  59964. * Post-processes used to create down sample post-processes in order to get
  59965. * the average luminance of the final image for HDR
  59966. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59967. */
  59968. luminanceDownSamplePostProcesses: PostProcess[];
  59969. /**
  59970. * Post-process used to create a HDR effect (light adaptation)
  59971. */
  59972. hdrPostProcess: Nullable<PostProcess>;
  59973. /**
  59974. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59975. */
  59976. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59977. /**
  59978. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59979. */
  59980. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59981. /**
  59982. * Post-process used to merge the final HDR post-process and the real scene color
  59983. */
  59984. hdrFinalPostProcess: Nullable<PostProcess>;
  59985. /**
  59986. * Post-process used to create a lens flare effect
  59987. */
  59988. lensFlarePostProcess: Nullable<PostProcess>;
  59989. /**
  59990. * Post-process that merges the result of the lens flare post-process and the real scene color
  59991. */
  59992. lensFlareComposePostProcess: Nullable<PostProcess>;
  59993. /**
  59994. * Post-process used to create a motion blur effect
  59995. */
  59996. motionBlurPostProcess: Nullable<PostProcess>;
  59997. /**
  59998. * Post-process used to create a depth of field effect
  59999. */
  60000. depthOfFieldPostProcess: Nullable<PostProcess>;
  60001. /**
  60002. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60003. */
  60004. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60005. /**
  60006. * Represents the brightness threshold in order to configure the illuminated surfaces
  60007. */
  60008. brightThreshold: number;
  60009. /**
  60010. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60011. */
  60012. blurWidth: number;
  60013. /**
  60014. * Sets if the blur for highlighted surfaces must be only horizontal
  60015. */
  60016. horizontalBlur: boolean;
  60017. /**
  60018. * Gets the overall exposure used by the pipeline
  60019. */
  60020. /**
  60021. * Sets the overall exposure used by the pipeline
  60022. */
  60023. exposure: number;
  60024. /**
  60025. * Texture used typically to simulate "dirty" on camera lens
  60026. */
  60027. lensTexture: Nullable<Texture>;
  60028. /**
  60029. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60030. */
  60031. volumetricLightCoefficient: number;
  60032. /**
  60033. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60034. */
  60035. volumetricLightPower: number;
  60036. /**
  60037. * Used the set the blur intensity to smooth the volumetric lights
  60038. */
  60039. volumetricLightBlurScale: number;
  60040. /**
  60041. * Light (spot or directional) used to generate the volumetric lights rays
  60042. * The source light must have a shadow generate so the pipeline can get its
  60043. * depth map
  60044. */
  60045. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60046. /**
  60047. * For eye adaptation, represents the minimum luminance the eye can see
  60048. */
  60049. hdrMinimumLuminance: number;
  60050. /**
  60051. * For eye adaptation, represents the decrease luminance speed
  60052. */
  60053. hdrDecreaseRate: number;
  60054. /**
  60055. * For eye adaptation, represents the increase luminance speed
  60056. */
  60057. hdrIncreaseRate: number;
  60058. /**
  60059. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60060. */
  60061. /**
  60062. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60063. */
  60064. hdrAutoExposure: boolean;
  60065. /**
  60066. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60067. */
  60068. lensColorTexture: Nullable<Texture>;
  60069. /**
  60070. * The overall strengh for the lens flare effect
  60071. */
  60072. lensFlareStrength: number;
  60073. /**
  60074. * Dispersion coefficient for lens flare ghosts
  60075. */
  60076. lensFlareGhostDispersal: number;
  60077. /**
  60078. * Main lens flare halo width
  60079. */
  60080. lensFlareHaloWidth: number;
  60081. /**
  60082. * Based on the lens distortion effect, defines how much the lens flare result
  60083. * is distorted
  60084. */
  60085. lensFlareDistortionStrength: number;
  60086. /**
  60087. * Lens star texture must be used to simulate rays on the flares and is available
  60088. * in the documentation
  60089. */
  60090. lensStarTexture: Nullable<Texture>;
  60091. /**
  60092. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60093. * flare effect by taking account of the dirt texture
  60094. */
  60095. lensFlareDirtTexture: Nullable<Texture>;
  60096. /**
  60097. * Represents the focal length for the depth of field effect
  60098. */
  60099. depthOfFieldDistance: number;
  60100. /**
  60101. * Represents the blur intensity for the blurred part of the depth of field effect
  60102. */
  60103. depthOfFieldBlurWidth: number;
  60104. /**
  60105. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60106. */
  60107. /**
  60108. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60109. */
  60110. motionStrength: number;
  60111. /**
  60112. * Gets wether or not the motion blur post-process is object based or screen based.
  60113. */
  60114. /**
  60115. * Sets wether or not the motion blur post-process should be object based or screen based
  60116. */
  60117. objectBasedMotionBlur: boolean;
  60118. /**
  60119. * List of animations for the pipeline (IAnimatable implementation)
  60120. */
  60121. animations: Animation[];
  60122. /**
  60123. * Private members
  60124. */
  60125. private _scene;
  60126. private _currentDepthOfFieldSource;
  60127. private _basePostProcess;
  60128. private _fixedExposure;
  60129. private _currentExposure;
  60130. private _hdrAutoExposure;
  60131. private _hdrCurrentLuminance;
  60132. private _motionStrength;
  60133. private _isObjectBasedMotionBlur;
  60134. private _floatTextureType;
  60135. private _ratio;
  60136. private _bloomEnabled;
  60137. private _depthOfFieldEnabled;
  60138. private _vlsEnabled;
  60139. private _lensFlareEnabled;
  60140. private _hdrEnabled;
  60141. private _motionBlurEnabled;
  60142. private _fxaaEnabled;
  60143. private _motionBlurSamples;
  60144. private _volumetricLightStepsCount;
  60145. private _samples;
  60146. /**
  60147. * @ignore
  60148. * Specifies if the bloom pipeline is enabled
  60149. */
  60150. BloomEnabled: boolean;
  60151. /**
  60152. * @ignore
  60153. * Specifies if the depth of field pipeline is enabed
  60154. */
  60155. DepthOfFieldEnabled: boolean;
  60156. /**
  60157. * @ignore
  60158. * Specifies if the lens flare pipeline is enabed
  60159. */
  60160. LensFlareEnabled: boolean;
  60161. /**
  60162. * @ignore
  60163. * Specifies if the HDR pipeline is enabled
  60164. */
  60165. HDREnabled: boolean;
  60166. /**
  60167. * @ignore
  60168. * Specifies if the volumetric lights scattering effect is enabled
  60169. */
  60170. VLSEnabled: boolean;
  60171. /**
  60172. * @ignore
  60173. * Specifies if the motion blur effect is enabled
  60174. */
  60175. MotionBlurEnabled: boolean;
  60176. /**
  60177. * Specifies if anti-aliasing is enabled
  60178. */
  60179. fxaaEnabled: boolean;
  60180. /**
  60181. * Specifies the number of steps used to calculate the volumetric lights
  60182. * Typically in interval [50, 200]
  60183. */
  60184. volumetricLightStepsCount: number;
  60185. /**
  60186. * Specifies the number of samples used for the motion blur effect
  60187. * Typically in interval [16, 64]
  60188. */
  60189. motionBlurSamples: number;
  60190. /**
  60191. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60192. */
  60193. samples: number;
  60194. /**
  60195. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60196. * @constructor
  60197. * @param name The rendering pipeline name
  60198. * @param scene The scene linked to this pipeline
  60199. * @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)
  60200. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60201. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60202. */
  60203. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60204. private _buildPipeline;
  60205. private _createDownSampleX4PostProcess;
  60206. private _createBrightPassPostProcess;
  60207. private _createBlurPostProcesses;
  60208. private _createTextureAdderPostProcess;
  60209. private _createVolumetricLightPostProcess;
  60210. private _createLuminancePostProcesses;
  60211. private _createHdrPostProcess;
  60212. private _createLensFlarePostProcess;
  60213. private _createDepthOfFieldPostProcess;
  60214. private _createMotionBlurPostProcess;
  60215. private _getDepthTexture;
  60216. private _disposePostProcesses;
  60217. /**
  60218. * Dispose of the pipeline and stop all post processes
  60219. */
  60220. dispose(): void;
  60221. /**
  60222. * Serialize the rendering pipeline (Used when exporting)
  60223. * @returns the serialized object
  60224. */
  60225. serialize(): any;
  60226. /**
  60227. * Parse the serialized pipeline
  60228. * @param source Source pipeline.
  60229. * @param scene The scene to load the pipeline to.
  60230. * @param rootUrl The URL of the serialized pipeline.
  60231. * @returns An instantiated pipeline from the serialized object.
  60232. */
  60233. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60234. /**
  60235. * Luminance steps
  60236. */
  60237. static LuminanceSteps: number;
  60238. }
  60239. }
  60240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60241. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60242. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60243. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60244. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60245. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60246. }
  60247. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60248. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60249. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60250. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60251. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60252. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60253. }
  60254. declare module "babylonjs/Shaders/tonemap.fragment" {
  60255. /** @hidden */
  60256. export var tonemapPixelShader: {
  60257. name: string;
  60258. shader: string;
  60259. };
  60260. }
  60261. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60262. import { Camera } from "babylonjs/Cameras/camera";
  60263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60264. import "babylonjs/Shaders/tonemap.fragment";
  60265. import { Engine } from "babylonjs/Engines/engine";
  60266. /** Defines operator used for tonemapping */
  60267. export enum TonemappingOperator {
  60268. /** Hable */
  60269. Hable = 0,
  60270. /** Reinhard */
  60271. Reinhard = 1,
  60272. /** HejiDawson */
  60273. HejiDawson = 2,
  60274. /** Photographic */
  60275. Photographic = 3
  60276. }
  60277. /**
  60278. * Defines a post process to apply tone mapping
  60279. */
  60280. export class TonemapPostProcess extends PostProcess {
  60281. private _operator;
  60282. /** Defines the required exposure adjustement */
  60283. exposureAdjustment: number;
  60284. /**
  60285. * Creates a new TonemapPostProcess
  60286. * @param name defines the name of the postprocess
  60287. * @param _operator defines the operator to use
  60288. * @param exposureAdjustment defines the required exposure adjustement
  60289. * @param camera defines the camera to use (can be null)
  60290. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60291. * @param engine defines the hosting engine (can be ignore if camera is set)
  60292. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60293. */
  60294. constructor(name: string, _operator: TonemappingOperator,
  60295. /** Defines the required exposure adjustement */
  60296. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60297. }
  60298. }
  60299. declare module "babylonjs/Shaders/depth.vertex" {
  60300. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60301. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60302. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60303. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60304. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60305. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60306. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60307. /** @hidden */
  60308. export var depthVertexShader: {
  60309. name: string;
  60310. shader: string;
  60311. };
  60312. }
  60313. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60314. /** @hidden */
  60315. export var volumetricLightScatteringPixelShader: {
  60316. name: string;
  60317. shader: string;
  60318. };
  60319. }
  60320. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60321. /** @hidden */
  60322. export var volumetricLightScatteringPassPixelShader: {
  60323. name: string;
  60324. shader: string;
  60325. };
  60326. }
  60327. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60328. import { Vector3 } from "babylonjs/Maths/math";
  60329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60330. import { Mesh } from "babylonjs/Meshes/mesh";
  60331. import { Camera } from "babylonjs/Cameras/camera";
  60332. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60334. import { Scene } from "babylonjs/scene";
  60335. import "babylonjs/Meshes/Builders/planeBuilder";
  60336. import "babylonjs/Shaders/depth.vertex";
  60337. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60338. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60339. import { Engine } from "babylonjs/Engines/engine";
  60340. /**
  60341. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60342. */
  60343. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60344. private _volumetricLightScatteringPass;
  60345. private _volumetricLightScatteringRTT;
  60346. private _viewPort;
  60347. private _screenCoordinates;
  60348. private _cachedDefines;
  60349. /**
  60350. * If not undefined, the mesh position is computed from the attached node position
  60351. */
  60352. attachedNode: {
  60353. position: Vector3;
  60354. };
  60355. /**
  60356. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60357. */
  60358. customMeshPosition: Vector3;
  60359. /**
  60360. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60361. */
  60362. useCustomMeshPosition: boolean;
  60363. /**
  60364. * If the post-process should inverse the light scattering direction
  60365. */
  60366. invert: boolean;
  60367. /**
  60368. * The internal mesh used by the post-process
  60369. */
  60370. mesh: Mesh;
  60371. /**
  60372. * @hidden
  60373. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60374. */
  60375. useDiffuseColor: boolean;
  60376. /**
  60377. * Array containing the excluded meshes not rendered in the internal pass
  60378. */
  60379. excludedMeshes: AbstractMesh[];
  60380. /**
  60381. * Controls the overall intensity of the post-process
  60382. */
  60383. exposure: number;
  60384. /**
  60385. * Dissipates each sample's contribution in range [0, 1]
  60386. */
  60387. decay: number;
  60388. /**
  60389. * Controls the overall intensity of each sample
  60390. */
  60391. weight: number;
  60392. /**
  60393. * Controls the density of each sample
  60394. */
  60395. density: number;
  60396. /**
  60397. * @constructor
  60398. * @param name The post-process name
  60399. * @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)
  60400. * @param camera The camera that the post-process will be attached to
  60401. * @param mesh The mesh used to create the light scattering
  60402. * @param samples The post-process quality, default 100
  60403. * @param samplingModeThe post-process filtering mode
  60404. * @param engine The babylon engine
  60405. * @param reusable If the post-process is reusable
  60406. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60407. */
  60408. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60409. /**
  60410. * Returns the string "VolumetricLightScatteringPostProcess"
  60411. * @returns "VolumetricLightScatteringPostProcess"
  60412. */
  60413. getClassName(): string;
  60414. private _isReady;
  60415. /**
  60416. * Sets the new light position for light scattering effect
  60417. * @param position The new custom light position
  60418. */
  60419. setCustomMeshPosition(position: Vector3): void;
  60420. /**
  60421. * Returns the light position for light scattering effect
  60422. * @return Vector3 The custom light position
  60423. */
  60424. getCustomMeshPosition(): Vector3;
  60425. /**
  60426. * Disposes the internal assets and detaches the post-process from the camera
  60427. */
  60428. dispose(camera: Camera): void;
  60429. /**
  60430. * Returns the render target texture used by the post-process
  60431. * @return the render target texture used by the post-process
  60432. */
  60433. getPass(): RenderTargetTexture;
  60434. private _meshExcluded;
  60435. private _createPass;
  60436. private _updateMeshScreenCoordinates;
  60437. /**
  60438. * Creates a default mesh for the Volumeric Light Scattering post-process
  60439. * @param name The mesh name
  60440. * @param scene The scene where to create the mesh
  60441. * @return the default mesh
  60442. */
  60443. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60444. }
  60445. }
  60446. declare module "babylonjs/PostProcesses/index" {
  60447. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60448. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60449. export * from "babylonjs/PostProcesses/bloomEffect";
  60450. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60451. export * from "babylonjs/PostProcesses/blurPostProcess";
  60452. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60453. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60454. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60455. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60456. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60457. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60458. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60459. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60460. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60461. export * from "babylonjs/PostProcesses/filterPostProcess";
  60462. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60463. export * from "babylonjs/PostProcesses/grainPostProcess";
  60464. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60465. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60466. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60467. export * from "babylonjs/PostProcesses/passPostProcess";
  60468. export * from "babylonjs/PostProcesses/postProcess";
  60469. export * from "babylonjs/PostProcesses/postProcessManager";
  60470. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60471. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60472. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60473. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60474. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60475. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60476. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60477. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60478. }
  60479. declare module "babylonjs/Probes/index" {
  60480. export * from "babylonjs/Probes/reflectionProbe";
  60481. }
  60482. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60483. import { Scene } from "babylonjs/scene";
  60484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60485. import { Color3 } from "babylonjs/Maths/math";
  60486. import { SmartArray } from "babylonjs/Misc/smartArray";
  60487. import { ISceneComponent } from "babylonjs/sceneComponent";
  60488. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60489. import "babylonjs/Meshes/Builders/boxBuilder";
  60490. import "babylonjs/Shaders/color.fragment";
  60491. import "babylonjs/Shaders/color.vertex";
  60492. module "babylonjs/scene" {
  60493. interface Scene {
  60494. /** @hidden (Backing field) */
  60495. _boundingBoxRenderer: BoundingBoxRenderer;
  60496. /** @hidden (Backing field) */
  60497. _forceShowBoundingBoxes: boolean;
  60498. /**
  60499. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60500. */
  60501. forceShowBoundingBoxes: boolean;
  60502. /**
  60503. * Gets the bounding box renderer associated with the scene
  60504. * @returns a BoundingBoxRenderer
  60505. */
  60506. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60507. }
  60508. }
  60509. module "babylonjs/Meshes/abstractMesh" {
  60510. interface AbstractMesh {
  60511. /** @hidden (Backing field) */
  60512. _showBoundingBox: boolean;
  60513. /**
  60514. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60515. */
  60516. showBoundingBox: boolean;
  60517. }
  60518. }
  60519. /**
  60520. * Component responsible of rendering the bounding box of the meshes in a scene.
  60521. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60522. */
  60523. export class BoundingBoxRenderer implements ISceneComponent {
  60524. /**
  60525. * The component name helpfull to identify the component in the list of scene components.
  60526. */
  60527. readonly name: string;
  60528. /**
  60529. * The scene the component belongs to.
  60530. */
  60531. scene: Scene;
  60532. /**
  60533. * Color of the bounding box lines placed in front of an object
  60534. */
  60535. frontColor: Color3;
  60536. /**
  60537. * Color of the bounding box lines placed behind an object
  60538. */
  60539. backColor: Color3;
  60540. /**
  60541. * Defines if the renderer should show the back lines or not
  60542. */
  60543. showBackLines: boolean;
  60544. /**
  60545. * @hidden
  60546. */
  60547. renderList: SmartArray<BoundingBox>;
  60548. private _colorShader;
  60549. private _vertexBuffers;
  60550. private _indexBuffer;
  60551. private _fillIndexBuffer;
  60552. private _fillIndexData;
  60553. /**
  60554. * Instantiates a new bounding box renderer in a scene.
  60555. * @param scene the scene the renderer renders in
  60556. */
  60557. constructor(scene: Scene);
  60558. /**
  60559. * Registers the component in a given scene
  60560. */
  60561. register(): void;
  60562. private _evaluateSubMesh;
  60563. private _activeMesh;
  60564. private _prepareRessources;
  60565. private _createIndexBuffer;
  60566. /**
  60567. * Rebuilds the elements related to this component in case of
  60568. * context lost for instance.
  60569. */
  60570. rebuild(): void;
  60571. /**
  60572. * @hidden
  60573. */
  60574. reset(): void;
  60575. /**
  60576. * Render the bounding boxes of a specific rendering group
  60577. * @param renderingGroupId defines the rendering group to render
  60578. */
  60579. render(renderingGroupId: number): void;
  60580. /**
  60581. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60582. * @param mesh Define the mesh to render the occlusion bounding box for
  60583. */
  60584. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60585. /**
  60586. * Dispose and release the resources attached to this renderer.
  60587. */
  60588. dispose(): void;
  60589. }
  60590. }
  60591. declare module "babylonjs/Shaders/depth.fragment" {
  60592. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60593. /** @hidden */
  60594. export var depthPixelShader: {
  60595. name: string;
  60596. shader: string;
  60597. };
  60598. }
  60599. declare module "babylonjs/Rendering/depthRenderer" {
  60600. import { Nullable } from "babylonjs/types";
  60601. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60602. import { Scene } from "babylonjs/scene";
  60603. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60604. import { Camera } from "babylonjs/Cameras/camera";
  60605. import "babylonjs/Shaders/depth.fragment";
  60606. import "babylonjs/Shaders/depth.vertex";
  60607. /**
  60608. * This represents a depth renderer in Babylon.
  60609. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60610. */
  60611. export class DepthRenderer {
  60612. private _scene;
  60613. private _depthMap;
  60614. private _effect;
  60615. private readonly _storeNonLinearDepth;
  60616. private readonly _clearColor;
  60617. /** Get if the depth renderer is using packed depth or not */
  60618. readonly isPacked: boolean;
  60619. private _cachedDefines;
  60620. private _camera;
  60621. /**
  60622. * Specifiess that the depth renderer will only be used within
  60623. * the camera it is created for.
  60624. * This can help forcing its rendering during the camera processing.
  60625. */
  60626. useOnlyInActiveCamera: boolean;
  60627. /** @hidden */
  60628. static _SceneComponentInitialization: (scene: Scene) => void;
  60629. /**
  60630. * Instantiates a depth renderer
  60631. * @param scene The scene the renderer belongs to
  60632. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60633. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60634. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60635. */
  60636. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60637. /**
  60638. * Creates the depth rendering effect and checks if the effect is ready.
  60639. * @param subMesh The submesh to be used to render the depth map of
  60640. * @param useInstances If multiple world instances should be used
  60641. * @returns if the depth renderer is ready to render the depth map
  60642. */
  60643. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60644. /**
  60645. * Gets the texture which the depth map will be written to.
  60646. * @returns The depth map texture
  60647. */
  60648. getDepthMap(): RenderTargetTexture;
  60649. /**
  60650. * Disposes of the depth renderer.
  60651. */
  60652. dispose(): void;
  60653. }
  60654. }
  60655. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60656. import { Nullable } from "babylonjs/types";
  60657. import { Scene } from "babylonjs/scene";
  60658. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60659. import { Camera } from "babylonjs/Cameras/camera";
  60660. import { ISceneComponent } from "babylonjs/sceneComponent";
  60661. module "babylonjs/scene" {
  60662. interface Scene {
  60663. /** @hidden (Backing field) */
  60664. _depthRenderer: {
  60665. [id: string]: DepthRenderer;
  60666. };
  60667. /**
  60668. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60669. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60670. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60671. * @returns the created depth renderer
  60672. */
  60673. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60674. /**
  60675. * Disables a depth renderer for a given camera
  60676. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60677. */
  60678. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60679. }
  60680. }
  60681. /**
  60682. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60683. * in several rendering techniques.
  60684. */
  60685. export class DepthRendererSceneComponent implements ISceneComponent {
  60686. /**
  60687. * The component name helpfull to identify the component in the list of scene components.
  60688. */
  60689. readonly name: string;
  60690. /**
  60691. * The scene the component belongs to.
  60692. */
  60693. scene: Scene;
  60694. /**
  60695. * Creates a new instance of the component for the given scene
  60696. * @param scene Defines the scene to register the component in
  60697. */
  60698. constructor(scene: Scene);
  60699. /**
  60700. * Registers the component in a given scene
  60701. */
  60702. register(): void;
  60703. /**
  60704. * Rebuilds the elements related to this component in case of
  60705. * context lost for instance.
  60706. */
  60707. rebuild(): void;
  60708. /**
  60709. * Disposes the component and the associated ressources
  60710. */
  60711. dispose(): void;
  60712. private _gatherRenderTargets;
  60713. private _gatherActiveCameraRenderTargets;
  60714. }
  60715. }
  60716. declare module "babylonjs/Shaders/outline.fragment" {
  60717. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60718. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60719. /** @hidden */
  60720. export var outlinePixelShader: {
  60721. name: string;
  60722. shader: string;
  60723. };
  60724. }
  60725. declare module "babylonjs/Shaders/outline.vertex" {
  60726. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60727. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60728. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60729. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60730. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60731. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60732. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60733. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60734. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60735. /** @hidden */
  60736. export var outlineVertexShader: {
  60737. name: string;
  60738. shader: string;
  60739. };
  60740. }
  60741. declare module "babylonjs/Rendering/outlineRenderer" {
  60742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60743. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60744. import { Scene } from "babylonjs/scene";
  60745. import { ISceneComponent } from "babylonjs/sceneComponent";
  60746. import "babylonjs/Shaders/outline.fragment";
  60747. import "babylonjs/Shaders/outline.vertex";
  60748. module "babylonjs/scene" {
  60749. interface Scene {
  60750. /** @hidden */
  60751. _outlineRenderer: OutlineRenderer;
  60752. /**
  60753. * Gets the outline renderer associated with the scene
  60754. * @returns a OutlineRenderer
  60755. */
  60756. getOutlineRenderer(): OutlineRenderer;
  60757. }
  60758. }
  60759. module "babylonjs/Meshes/abstractMesh" {
  60760. interface AbstractMesh {
  60761. /** @hidden (Backing field) */
  60762. _renderOutline: boolean;
  60763. /**
  60764. * Gets or sets a boolean indicating if the outline must be rendered as well
  60765. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60766. */
  60767. renderOutline: boolean;
  60768. /** @hidden (Backing field) */
  60769. _renderOverlay: boolean;
  60770. /**
  60771. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60772. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60773. */
  60774. renderOverlay: boolean;
  60775. }
  60776. }
  60777. /**
  60778. * This class is responsible to draw bothe outline/overlay of meshes.
  60779. * It should not be used directly but through the available method on mesh.
  60780. */
  60781. export class OutlineRenderer implements ISceneComponent {
  60782. /**
  60783. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60784. */
  60785. private static _StencilReference;
  60786. /**
  60787. * The name of the component. Each component must have a unique name.
  60788. */
  60789. name: string;
  60790. /**
  60791. * The scene the component belongs to.
  60792. */
  60793. scene: Scene;
  60794. /**
  60795. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60796. */
  60797. zOffset: number;
  60798. private _engine;
  60799. private _effect;
  60800. private _cachedDefines;
  60801. private _savedDepthWrite;
  60802. /**
  60803. * Instantiates a new outline renderer. (There could be only one per scene).
  60804. * @param scene Defines the scene it belongs to
  60805. */
  60806. constructor(scene: Scene);
  60807. /**
  60808. * Register the component to one instance of a scene.
  60809. */
  60810. register(): void;
  60811. /**
  60812. * Rebuilds the elements related to this component in case of
  60813. * context lost for instance.
  60814. */
  60815. rebuild(): void;
  60816. /**
  60817. * Disposes the component and the associated ressources.
  60818. */
  60819. dispose(): void;
  60820. /**
  60821. * Renders the outline in the canvas.
  60822. * @param subMesh Defines the sumesh to render
  60823. * @param batch Defines the batch of meshes in case of instances
  60824. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60825. */
  60826. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60827. /**
  60828. * Returns whether or not the outline renderer is ready for a given submesh.
  60829. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60830. * @param subMesh Defines the submesh to check readyness for
  60831. * @param useInstances Defines wheter wee are trying to render instances or not
  60832. * @returns true if ready otherwise false
  60833. */
  60834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60835. private _beforeRenderingMesh;
  60836. private _afterRenderingMesh;
  60837. }
  60838. }
  60839. declare module "babylonjs/Rendering/index" {
  60840. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60841. export * from "babylonjs/Rendering/depthRenderer";
  60842. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60843. export * from "babylonjs/Rendering/edgesRenderer";
  60844. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60845. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60846. export * from "babylonjs/Rendering/outlineRenderer";
  60847. export * from "babylonjs/Rendering/renderingGroup";
  60848. export * from "babylonjs/Rendering/renderingManager";
  60849. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60850. }
  60851. declare module "babylonjs/Sprites/index" {
  60852. export * from "babylonjs/Sprites/sprite";
  60853. export * from "babylonjs/Sprites/spriteManager";
  60854. export * from "babylonjs/Sprites/spriteSceneComponent";
  60855. }
  60856. declare module "babylonjs/Misc/assetsManager" {
  60857. import { Scene } from "babylonjs/scene";
  60858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60859. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60860. import { Skeleton } from "babylonjs/Bones/skeleton";
  60861. import { Observable } from "babylonjs/Misc/observable";
  60862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60863. import { Texture } from "babylonjs/Materials/Textures/texture";
  60864. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60865. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60866. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60867. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60868. /**
  60869. * Defines the list of states available for a task inside a AssetsManager
  60870. */
  60871. export enum AssetTaskState {
  60872. /**
  60873. * Initialization
  60874. */
  60875. INIT = 0,
  60876. /**
  60877. * Running
  60878. */
  60879. RUNNING = 1,
  60880. /**
  60881. * Done
  60882. */
  60883. DONE = 2,
  60884. /**
  60885. * Error
  60886. */
  60887. ERROR = 3
  60888. }
  60889. /**
  60890. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60891. */
  60892. export abstract class AbstractAssetTask {
  60893. /**
  60894. * Task name
  60895. */ name: string;
  60896. /**
  60897. * Callback called when the task is successful
  60898. */
  60899. onSuccess: (task: any) => void;
  60900. /**
  60901. * Callback called when the task is not successful
  60902. */
  60903. onError: (task: any, message?: string, exception?: any) => void;
  60904. /**
  60905. * Creates a new AssetsManager
  60906. * @param name defines the name of the task
  60907. */
  60908. constructor(
  60909. /**
  60910. * Task name
  60911. */ name: string);
  60912. private _isCompleted;
  60913. private _taskState;
  60914. private _errorObject;
  60915. /**
  60916. * Get if the task is completed
  60917. */
  60918. readonly isCompleted: boolean;
  60919. /**
  60920. * Gets the current state of the task
  60921. */
  60922. readonly taskState: AssetTaskState;
  60923. /**
  60924. * Gets the current error object (if task is in error)
  60925. */
  60926. readonly errorObject: {
  60927. message?: string;
  60928. exception?: any;
  60929. };
  60930. /**
  60931. * Internal only
  60932. * @hidden
  60933. */
  60934. _setErrorObject(message?: string, exception?: any): void;
  60935. /**
  60936. * Execute the current task
  60937. * @param scene defines the scene where you want your assets to be loaded
  60938. * @param onSuccess is a callback called when the task is successfully executed
  60939. * @param onError is a callback called if an error occurs
  60940. */
  60941. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60942. /**
  60943. * Execute the current task
  60944. * @param scene defines the scene where you want your assets to be loaded
  60945. * @param onSuccess is a callback called when the task is successfully executed
  60946. * @param onError is a callback called if an error occurs
  60947. */
  60948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60949. /**
  60950. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60951. * This can be used with failed tasks that have the reason for failure fixed.
  60952. */
  60953. reset(): void;
  60954. private onErrorCallback;
  60955. private onDoneCallback;
  60956. }
  60957. /**
  60958. * Define the interface used by progress events raised during assets loading
  60959. */
  60960. export interface IAssetsProgressEvent {
  60961. /**
  60962. * Defines the number of remaining tasks to process
  60963. */
  60964. remainingCount: number;
  60965. /**
  60966. * Defines the total number of tasks
  60967. */
  60968. totalCount: number;
  60969. /**
  60970. * Defines the task that was just processed
  60971. */
  60972. task: AbstractAssetTask;
  60973. }
  60974. /**
  60975. * Class used to share progress information about assets loading
  60976. */
  60977. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60978. /**
  60979. * Defines the number of remaining tasks to process
  60980. */
  60981. remainingCount: number;
  60982. /**
  60983. * Defines the total number of tasks
  60984. */
  60985. totalCount: number;
  60986. /**
  60987. * Defines the task that was just processed
  60988. */
  60989. task: AbstractAssetTask;
  60990. /**
  60991. * Creates a AssetsProgressEvent
  60992. * @param remainingCount defines the number of remaining tasks to process
  60993. * @param totalCount defines the total number of tasks
  60994. * @param task defines the task that was just processed
  60995. */
  60996. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60997. }
  60998. /**
  60999. * Define a task used by AssetsManager to load meshes
  61000. */
  61001. export class MeshAssetTask extends AbstractAssetTask {
  61002. /**
  61003. * Defines the name of the task
  61004. */
  61005. name: string;
  61006. /**
  61007. * Defines the list of mesh's names you want to load
  61008. */
  61009. meshesNames: any;
  61010. /**
  61011. * Defines the root url to use as a base to load your meshes and associated resources
  61012. */
  61013. rootUrl: string;
  61014. /**
  61015. * Defines the filename of the scene to load from
  61016. */
  61017. sceneFilename: string;
  61018. /**
  61019. * Gets the list of loaded meshes
  61020. */
  61021. loadedMeshes: Array<AbstractMesh>;
  61022. /**
  61023. * Gets the list of loaded particle systems
  61024. */
  61025. loadedParticleSystems: Array<IParticleSystem>;
  61026. /**
  61027. * Gets the list of loaded skeletons
  61028. */
  61029. loadedSkeletons: Array<Skeleton>;
  61030. /**
  61031. * Gets the list of loaded animation groups
  61032. */
  61033. loadedAnimationGroups: Array<AnimationGroup>;
  61034. /**
  61035. * Callback called when the task is successful
  61036. */
  61037. onSuccess: (task: MeshAssetTask) => void;
  61038. /**
  61039. * Callback called when the task is successful
  61040. */
  61041. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61042. /**
  61043. * Creates a new MeshAssetTask
  61044. * @param name defines the name of the task
  61045. * @param meshesNames defines the list of mesh's names you want to load
  61046. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61047. * @param sceneFilename defines the filename of the scene to load from
  61048. */
  61049. constructor(
  61050. /**
  61051. * Defines the name of the task
  61052. */
  61053. name: string,
  61054. /**
  61055. * Defines the list of mesh's names you want to load
  61056. */
  61057. meshesNames: any,
  61058. /**
  61059. * Defines the root url to use as a base to load your meshes and associated resources
  61060. */
  61061. rootUrl: string,
  61062. /**
  61063. * Defines the filename of the scene to load from
  61064. */
  61065. sceneFilename: string);
  61066. /**
  61067. * Execute the current task
  61068. * @param scene defines the scene where you want your assets to be loaded
  61069. * @param onSuccess is a callback called when the task is successfully executed
  61070. * @param onError is a callback called if an error occurs
  61071. */
  61072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61073. }
  61074. /**
  61075. * Define a task used by AssetsManager to load text content
  61076. */
  61077. export class TextFileAssetTask extends AbstractAssetTask {
  61078. /**
  61079. * Defines the name of the task
  61080. */
  61081. name: string;
  61082. /**
  61083. * Defines the location of the file to load
  61084. */
  61085. url: string;
  61086. /**
  61087. * Gets the loaded text string
  61088. */
  61089. text: string;
  61090. /**
  61091. * Callback called when the task is successful
  61092. */
  61093. onSuccess: (task: TextFileAssetTask) => void;
  61094. /**
  61095. * Callback called when the task is successful
  61096. */
  61097. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61098. /**
  61099. * Creates a new TextFileAssetTask object
  61100. * @param name defines the name of the task
  61101. * @param url defines the location of the file to load
  61102. */
  61103. constructor(
  61104. /**
  61105. * Defines the name of the task
  61106. */
  61107. name: string,
  61108. /**
  61109. * Defines the location of the file to load
  61110. */
  61111. url: string);
  61112. /**
  61113. * Execute the current task
  61114. * @param scene defines the scene where you want your assets to be loaded
  61115. * @param onSuccess is a callback called when the task is successfully executed
  61116. * @param onError is a callback called if an error occurs
  61117. */
  61118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61119. }
  61120. /**
  61121. * Define a task used by AssetsManager to load binary data
  61122. */
  61123. export class BinaryFileAssetTask extends AbstractAssetTask {
  61124. /**
  61125. * Defines the name of the task
  61126. */
  61127. name: string;
  61128. /**
  61129. * Defines the location of the file to load
  61130. */
  61131. url: string;
  61132. /**
  61133. * Gets the lodaded data (as an array buffer)
  61134. */
  61135. data: ArrayBuffer;
  61136. /**
  61137. * Callback called when the task is successful
  61138. */
  61139. onSuccess: (task: BinaryFileAssetTask) => void;
  61140. /**
  61141. * Callback called when the task is successful
  61142. */
  61143. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61144. /**
  61145. * Creates a new BinaryFileAssetTask object
  61146. * @param name defines the name of the new task
  61147. * @param url defines the location of the file to load
  61148. */
  61149. constructor(
  61150. /**
  61151. * Defines the name of the task
  61152. */
  61153. name: string,
  61154. /**
  61155. * Defines the location of the file to load
  61156. */
  61157. url: string);
  61158. /**
  61159. * Execute the current task
  61160. * @param scene defines the scene where you want your assets to be loaded
  61161. * @param onSuccess is a callback called when the task is successfully executed
  61162. * @param onError is a callback called if an error occurs
  61163. */
  61164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61165. }
  61166. /**
  61167. * Define a task used by AssetsManager to load images
  61168. */
  61169. export class ImageAssetTask extends AbstractAssetTask {
  61170. /**
  61171. * Defines the name of the task
  61172. */
  61173. name: string;
  61174. /**
  61175. * Defines the location of the image to load
  61176. */
  61177. url: string;
  61178. /**
  61179. * Gets the loaded images
  61180. */
  61181. image: HTMLImageElement;
  61182. /**
  61183. * Callback called when the task is successful
  61184. */
  61185. onSuccess: (task: ImageAssetTask) => void;
  61186. /**
  61187. * Callback called when the task is successful
  61188. */
  61189. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61190. /**
  61191. * Creates a new ImageAssetTask
  61192. * @param name defines the name of the task
  61193. * @param url defines the location of the image to load
  61194. */
  61195. constructor(
  61196. /**
  61197. * Defines the name of the task
  61198. */
  61199. name: string,
  61200. /**
  61201. * Defines the location of the image to load
  61202. */
  61203. url: string);
  61204. /**
  61205. * Execute the current task
  61206. * @param scene defines the scene where you want your assets to be loaded
  61207. * @param onSuccess is a callback called when the task is successfully executed
  61208. * @param onError is a callback called if an error occurs
  61209. */
  61210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61211. }
  61212. /**
  61213. * Defines the interface used by texture loading tasks
  61214. */
  61215. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61216. /**
  61217. * Gets the loaded texture
  61218. */
  61219. texture: TEX;
  61220. }
  61221. /**
  61222. * Define a task used by AssetsManager to load 2D textures
  61223. */
  61224. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61225. /**
  61226. * Defines the name of the task
  61227. */
  61228. name: string;
  61229. /**
  61230. * Defines the location of the file to load
  61231. */
  61232. url: string;
  61233. /**
  61234. * Defines if mipmap should not be generated (default is false)
  61235. */
  61236. noMipmap?: boolean | undefined;
  61237. /**
  61238. * Defines if texture must be inverted on Y axis (default is false)
  61239. */
  61240. invertY?: boolean | undefined;
  61241. /**
  61242. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61243. */
  61244. samplingMode: number;
  61245. /**
  61246. * Gets the loaded texture
  61247. */
  61248. texture: Texture;
  61249. /**
  61250. * Callback called when the task is successful
  61251. */
  61252. onSuccess: (task: TextureAssetTask) => void;
  61253. /**
  61254. * Callback called when the task is successful
  61255. */
  61256. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61257. /**
  61258. * Creates a new TextureAssetTask object
  61259. * @param name defines the name of the task
  61260. * @param url defines the location of the file to load
  61261. * @param noMipmap defines if mipmap should not be generated (default is false)
  61262. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61263. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61264. */
  61265. constructor(
  61266. /**
  61267. * Defines the name of the task
  61268. */
  61269. name: string,
  61270. /**
  61271. * Defines the location of the file to load
  61272. */
  61273. url: string,
  61274. /**
  61275. * Defines if mipmap should not be generated (default is false)
  61276. */
  61277. noMipmap?: boolean | undefined,
  61278. /**
  61279. * Defines if texture must be inverted on Y axis (default is false)
  61280. */
  61281. invertY?: boolean | undefined,
  61282. /**
  61283. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61284. */
  61285. samplingMode?: number);
  61286. /**
  61287. * Execute the current task
  61288. * @param scene defines the scene where you want your assets to be loaded
  61289. * @param onSuccess is a callback called when the task is successfully executed
  61290. * @param onError is a callback called if an error occurs
  61291. */
  61292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61293. }
  61294. /**
  61295. * Define a task used by AssetsManager to load cube textures
  61296. */
  61297. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61298. /**
  61299. * Defines the name of the task
  61300. */
  61301. name: string;
  61302. /**
  61303. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61304. */
  61305. url: string;
  61306. /**
  61307. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61308. */
  61309. extensions?: string[] | undefined;
  61310. /**
  61311. * Defines if mipmaps should not be generated (default is false)
  61312. */
  61313. noMipmap?: boolean | undefined;
  61314. /**
  61315. * Defines the explicit list of files (undefined by default)
  61316. */
  61317. files?: string[] | undefined;
  61318. /**
  61319. * Gets the loaded texture
  61320. */
  61321. texture: CubeTexture;
  61322. /**
  61323. * Callback called when the task is successful
  61324. */
  61325. onSuccess: (task: CubeTextureAssetTask) => void;
  61326. /**
  61327. * Callback called when the task is successful
  61328. */
  61329. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61330. /**
  61331. * Creates a new CubeTextureAssetTask
  61332. * @param name defines the name of the task
  61333. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61334. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61335. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61336. * @param files defines the explicit list of files (undefined by default)
  61337. */
  61338. constructor(
  61339. /**
  61340. * Defines the name of the task
  61341. */
  61342. name: string,
  61343. /**
  61344. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61345. */
  61346. url: string,
  61347. /**
  61348. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61349. */
  61350. extensions?: string[] | undefined,
  61351. /**
  61352. * Defines if mipmaps should not be generated (default is false)
  61353. */
  61354. noMipmap?: boolean | undefined,
  61355. /**
  61356. * Defines the explicit list of files (undefined by default)
  61357. */
  61358. files?: string[] | undefined);
  61359. /**
  61360. * Execute the current task
  61361. * @param scene defines the scene where you want your assets to be loaded
  61362. * @param onSuccess is a callback called when the task is successfully executed
  61363. * @param onError is a callback called if an error occurs
  61364. */
  61365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61366. }
  61367. /**
  61368. * Define a task used by AssetsManager to load HDR cube textures
  61369. */
  61370. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61371. /**
  61372. * Defines the name of the task
  61373. */
  61374. name: string;
  61375. /**
  61376. * Defines the location of the file to load
  61377. */
  61378. url: string;
  61379. /**
  61380. * Defines the desired size (the more it increases the longer the generation will be)
  61381. */
  61382. size: number;
  61383. /**
  61384. * Defines if mipmaps should not be generated (default is false)
  61385. */
  61386. noMipmap: boolean;
  61387. /**
  61388. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61389. */
  61390. generateHarmonics: boolean;
  61391. /**
  61392. * 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)
  61393. */
  61394. gammaSpace: boolean;
  61395. /**
  61396. * Internal Use Only
  61397. */
  61398. reserved: boolean;
  61399. /**
  61400. * Gets the loaded texture
  61401. */
  61402. texture: HDRCubeTexture;
  61403. /**
  61404. * Callback called when the task is successful
  61405. */
  61406. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61407. /**
  61408. * Callback called when the task is successful
  61409. */
  61410. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61411. /**
  61412. * Creates a new HDRCubeTextureAssetTask object
  61413. * @param name defines the name of the task
  61414. * @param url defines the location of the file to load
  61415. * @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.
  61416. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61417. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61418. * @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)
  61419. * @param reserved Internal use only
  61420. */
  61421. constructor(
  61422. /**
  61423. * Defines the name of the task
  61424. */
  61425. name: string,
  61426. /**
  61427. * Defines the location of the file to load
  61428. */
  61429. url: string,
  61430. /**
  61431. * Defines the desired size (the more it increases the longer the generation will be)
  61432. */
  61433. size: number,
  61434. /**
  61435. * Defines if mipmaps should not be generated (default is false)
  61436. */
  61437. noMipmap?: boolean,
  61438. /**
  61439. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61440. */
  61441. generateHarmonics?: boolean,
  61442. /**
  61443. * 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)
  61444. */
  61445. gammaSpace?: boolean,
  61446. /**
  61447. * Internal Use Only
  61448. */
  61449. reserved?: boolean);
  61450. /**
  61451. * Execute the current task
  61452. * @param scene defines the scene where you want your assets to be loaded
  61453. * @param onSuccess is a callback called when the task is successfully executed
  61454. * @param onError is a callback called if an error occurs
  61455. */
  61456. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61457. }
  61458. /**
  61459. * Define a task used by AssetsManager to load Equirectangular cube textures
  61460. */
  61461. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61462. /**
  61463. * Defines the name of the task
  61464. */
  61465. name: string;
  61466. /**
  61467. * Defines the location of the file to load
  61468. */
  61469. url: string;
  61470. /**
  61471. * Defines the desired size (the more it increases the longer the generation will be)
  61472. */
  61473. size: number;
  61474. /**
  61475. * Defines if mipmaps should not be generated (default is false)
  61476. */
  61477. noMipmap: boolean;
  61478. /**
  61479. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61480. * but the standard material would require them in Gamma space) (default is true)
  61481. */
  61482. gammaSpace: boolean;
  61483. /**
  61484. * Gets the loaded texture
  61485. */
  61486. texture: EquiRectangularCubeTexture;
  61487. /**
  61488. * Callback called when the task is successful
  61489. */
  61490. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61491. /**
  61492. * Callback called when the task is successful
  61493. */
  61494. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61495. /**
  61496. * Creates a new EquiRectangularCubeTextureAssetTask object
  61497. * @param name defines the name of the task
  61498. * @param url defines the location of the file to load
  61499. * @param size defines the desired size (the more it increases the longer the generation will be)
  61500. * If the size is omitted this implies you are using a preprocessed cubemap.
  61501. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61502. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61503. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61504. * (default is true)
  61505. */
  61506. constructor(
  61507. /**
  61508. * Defines the name of the task
  61509. */
  61510. name: string,
  61511. /**
  61512. * Defines the location of the file to load
  61513. */
  61514. url: string,
  61515. /**
  61516. * Defines the desired size (the more it increases the longer the generation will be)
  61517. */
  61518. size: number,
  61519. /**
  61520. * Defines if mipmaps should not be generated (default is false)
  61521. */
  61522. noMipmap?: boolean,
  61523. /**
  61524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61525. * but the standard material would require them in Gamma space) (default is true)
  61526. */
  61527. gammaSpace?: boolean);
  61528. /**
  61529. * Execute the current task
  61530. * @param scene defines the scene where you want your assets to be loaded
  61531. * @param onSuccess is a callback called when the task is successfully executed
  61532. * @param onError is a callback called if an error occurs
  61533. */
  61534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61535. }
  61536. /**
  61537. * This class can be used to easily import assets into a scene
  61538. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61539. */
  61540. export class AssetsManager {
  61541. private _scene;
  61542. private _isLoading;
  61543. protected _tasks: AbstractAssetTask[];
  61544. protected _waitingTasksCount: number;
  61545. protected _totalTasksCount: number;
  61546. /**
  61547. * Callback called when all tasks are processed
  61548. */
  61549. onFinish: (tasks: AbstractAssetTask[]) => void;
  61550. /**
  61551. * Callback called when a task is successful
  61552. */
  61553. onTaskSuccess: (task: AbstractAssetTask) => void;
  61554. /**
  61555. * Callback called when a task had an error
  61556. */
  61557. onTaskError: (task: AbstractAssetTask) => void;
  61558. /**
  61559. * Callback called when a task is done (whatever the result is)
  61560. */
  61561. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61562. /**
  61563. * Observable called when all tasks are processed
  61564. */
  61565. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61566. /**
  61567. * Observable called when a task had an error
  61568. */
  61569. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61570. /**
  61571. * Observable called when all tasks were executed
  61572. */
  61573. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61574. /**
  61575. * Observable called when a task is done (whatever the result is)
  61576. */
  61577. onProgressObservable: Observable<IAssetsProgressEvent>;
  61578. /**
  61579. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61580. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61581. */
  61582. useDefaultLoadingScreen: boolean;
  61583. /**
  61584. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61585. * when all assets have been downloaded.
  61586. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61587. */
  61588. autoHideLoadingUI: boolean;
  61589. /**
  61590. * Creates a new AssetsManager
  61591. * @param scene defines the scene to work on
  61592. */
  61593. constructor(scene: Scene);
  61594. /**
  61595. * Add a MeshAssetTask to the list of active tasks
  61596. * @param taskName defines the name of the new task
  61597. * @param meshesNames defines the name of meshes to load
  61598. * @param rootUrl defines the root url to use to locate files
  61599. * @param sceneFilename defines the filename of the scene file
  61600. * @returns a new MeshAssetTask object
  61601. */
  61602. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61603. /**
  61604. * Add a TextFileAssetTask to the list of active tasks
  61605. * @param taskName defines the name of the new task
  61606. * @param url defines the url of the file to load
  61607. * @returns a new TextFileAssetTask object
  61608. */
  61609. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61610. /**
  61611. * Add a BinaryFileAssetTask to the list of active tasks
  61612. * @param taskName defines the name of the new task
  61613. * @param url defines the url of the file to load
  61614. * @returns a new BinaryFileAssetTask object
  61615. */
  61616. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61617. /**
  61618. * Add a ImageAssetTask to the list of active tasks
  61619. * @param taskName defines the name of the new task
  61620. * @param url defines the url of the file to load
  61621. * @returns a new ImageAssetTask object
  61622. */
  61623. addImageTask(taskName: string, url: string): ImageAssetTask;
  61624. /**
  61625. * Add a TextureAssetTask to the list of active tasks
  61626. * @param taskName defines the name of the new task
  61627. * @param url defines the url of the file to load
  61628. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61629. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61630. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61631. * @returns a new TextureAssetTask object
  61632. */
  61633. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61634. /**
  61635. * Add a CubeTextureAssetTask to the list of active tasks
  61636. * @param taskName defines the name of the new task
  61637. * @param url defines the url of the file to load
  61638. * @param extensions defines the extension to use to load the cube map (can be null)
  61639. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61640. * @param files defines the list of files to load (can be null)
  61641. * @returns a new CubeTextureAssetTask object
  61642. */
  61643. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61644. /**
  61645. *
  61646. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61647. * @param taskName defines the name of the new task
  61648. * @param url defines the url of the file to load
  61649. * @param size defines the size you want for the cubemap (can be null)
  61650. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61651. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61652. * @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)
  61653. * @param reserved Internal use only
  61654. * @returns a new HDRCubeTextureAssetTask object
  61655. */
  61656. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61657. /**
  61658. *
  61659. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61660. * @param taskName defines the name of the new task
  61661. * @param url defines the url of the file to load
  61662. * @param size defines the size you want for the cubemap (can be null)
  61663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61664. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61665. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61666. * @returns a new EquiRectangularCubeTextureAssetTask object
  61667. */
  61668. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61669. /**
  61670. * Remove a task from the assets manager.
  61671. * @param task the task to remove
  61672. */
  61673. removeTask(task: AbstractAssetTask): void;
  61674. private _decreaseWaitingTasksCount;
  61675. private _runTask;
  61676. /**
  61677. * Reset the AssetsManager and remove all tasks
  61678. * @return the current instance of the AssetsManager
  61679. */
  61680. reset(): AssetsManager;
  61681. /**
  61682. * Start the loading process
  61683. * @return the current instance of the AssetsManager
  61684. */
  61685. load(): AssetsManager;
  61686. /**
  61687. * Start the loading process as an async operation
  61688. * @return a promise returning the list of failed tasks
  61689. */
  61690. loadAsync(): Promise<void>;
  61691. }
  61692. }
  61693. declare module "babylonjs/Misc/deferred" {
  61694. /**
  61695. * Wrapper class for promise with external resolve and reject.
  61696. */
  61697. export class Deferred<T> {
  61698. /**
  61699. * The promise associated with this deferred object.
  61700. */
  61701. readonly promise: Promise<T>;
  61702. private _resolve;
  61703. private _reject;
  61704. /**
  61705. * The resolve method of the promise associated with this deferred object.
  61706. */
  61707. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61708. /**
  61709. * The reject method of the promise associated with this deferred object.
  61710. */
  61711. readonly reject: (reason?: any) => void;
  61712. /**
  61713. * Constructor for this deferred object.
  61714. */
  61715. constructor();
  61716. }
  61717. }
  61718. declare module "babylonjs/Misc/meshExploder" {
  61719. import { Mesh } from "babylonjs/Meshes/mesh";
  61720. /**
  61721. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61722. */
  61723. export class MeshExploder {
  61724. private _centerMesh;
  61725. private _meshes;
  61726. private _meshesOrigins;
  61727. private _toCenterVectors;
  61728. private _scaledDirection;
  61729. private _newPosition;
  61730. private _centerPosition;
  61731. /**
  61732. * Explodes meshes from a center mesh.
  61733. * @param meshes The meshes to explode.
  61734. * @param centerMesh The mesh to be center of explosion.
  61735. */
  61736. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61737. private _setCenterMesh;
  61738. /**
  61739. * Get class name
  61740. * @returns "MeshExploder"
  61741. */
  61742. getClassName(): string;
  61743. /**
  61744. * "Exploded meshes"
  61745. * @returns Array of meshes with the centerMesh at index 0.
  61746. */
  61747. getMeshes(): Array<Mesh>;
  61748. /**
  61749. * Explodes meshes giving a specific direction
  61750. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61751. */
  61752. explode(direction?: number): void;
  61753. }
  61754. }
  61755. declare module "babylonjs/Misc/filesInput" {
  61756. import { Engine } from "babylonjs/Engines/engine";
  61757. import { Scene } from "babylonjs/scene";
  61758. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61759. /**
  61760. * Class used to help managing file picking and drag'n'drop
  61761. */
  61762. export class FilesInput {
  61763. /**
  61764. * List of files ready to be loaded
  61765. */
  61766. static readonly FilesToLoad: {
  61767. [key: string]: File;
  61768. };
  61769. /**
  61770. * Callback called when a file is processed
  61771. */
  61772. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61773. private _engine;
  61774. private _currentScene;
  61775. private _sceneLoadedCallback;
  61776. private _progressCallback;
  61777. private _additionalRenderLoopLogicCallback;
  61778. private _textureLoadingCallback;
  61779. private _startingProcessingFilesCallback;
  61780. private _onReloadCallback;
  61781. private _errorCallback;
  61782. private _elementToMonitor;
  61783. private _sceneFileToLoad;
  61784. private _filesToLoad;
  61785. /**
  61786. * Creates a new FilesInput
  61787. * @param engine defines the rendering engine
  61788. * @param scene defines the hosting scene
  61789. * @param sceneLoadedCallback callback called when scene is loaded
  61790. * @param progressCallback callback called to track progress
  61791. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61792. * @param textureLoadingCallback callback called when a texture is loading
  61793. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61794. * @param onReloadCallback callback called when a reload is requested
  61795. * @param errorCallback callback call if an error occurs
  61796. */
  61797. 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);
  61798. private _dragEnterHandler;
  61799. private _dragOverHandler;
  61800. private _dropHandler;
  61801. /**
  61802. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61803. * @param elementToMonitor defines the DOM element to track
  61804. */
  61805. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61806. /**
  61807. * Release all associated resources
  61808. */
  61809. dispose(): void;
  61810. private renderFunction;
  61811. private drag;
  61812. private drop;
  61813. private _traverseFolder;
  61814. private _processFiles;
  61815. /**
  61816. * Load files from a drop event
  61817. * @param event defines the drop event to use as source
  61818. */
  61819. loadFiles(event: any): void;
  61820. private _processReload;
  61821. /**
  61822. * Reload the current scene from the loaded files
  61823. */
  61824. reload(): void;
  61825. }
  61826. }
  61827. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61828. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61829. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61830. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61831. }
  61832. declare module "babylonjs/Misc/sceneOptimizer" {
  61833. import { Scene, IDisposable } from "babylonjs/scene";
  61834. import { Observable } from "babylonjs/Misc/observable";
  61835. /**
  61836. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61838. */
  61839. export class SceneOptimization {
  61840. /**
  61841. * Defines the priority of this optimization (0 by default which means first in the list)
  61842. */
  61843. priority: number;
  61844. /**
  61845. * Gets a string describing the action executed by the current optimization
  61846. * @returns description string
  61847. */
  61848. getDescription(): string;
  61849. /**
  61850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61851. * @param scene defines the current scene where to apply this optimization
  61852. * @param optimizer defines the current optimizer
  61853. * @returns true if everything that can be done was applied
  61854. */
  61855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61856. /**
  61857. * Creates the SceneOptimization object
  61858. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61859. * @param desc defines the description associated with the optimization
  61860. */
  61861. constructor(
  61862. /**
  61863. * Defines the priority of this optimization (0 by default which means first in the list)
  61864. */
  61865. priority?: number);
  61866. }
  61867. /**
  61868. * Defines an optimization used to reduce the size of render target textures
  61869. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61870. */
  61871. export class TextureOptimization extends SceneOptimization {
  61872. /**
  61873. * Defines the priority of this optimization (0 by default which means first in the list)
  61874. */
  61875. priority: number;
  61876. /**
  61877. * 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
  61878. */
  61879. maximumSize: number;
  61880. /**
  61881. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61882. */
  61883. step: number;
  61884. /**
  61885. * Gets a string describing the action executed by the current optimization
  61886. * @returns description string
  61887. */
  61888. getDescription(): string;
  61889. /**
  61890. * Creates the TextureOptimization object
  61891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61892. * @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
  61893. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61894. */
  61895. constructor(
  61896. /**
  61897. * Defines the priority of this optimization (0 by default which means first in the list)
  61898. */
  61899. priority?: number,
  61900. /**
  61901. * 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
  61902. */
  61903. maximumSize?: number,
  61904. /**
  61905. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61906. */
  61907. step?: number);
  61908. /**
  61909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61910. * @param scene defines the current scene where to apply this optimization
  61911. * @param optimizer defines the current optimizer
  61912. * @returns true if everything that can be done was applied
  61913. */
  61914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61915. }
  61916. /**
  61917. * Defines an optimization used to increase or decrease the rendering resolution
  61918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61919. */
  61920. export class HardwareScalingOptimization extends SceneOptimization {
  61921. /**
  61922. * Defines the priority of this optimization (0 by default which means first in the list)
  61923. */
  61924. priority: number;
  61925. /**
  61926. * Defines the maximum scale to use (2 by default)
  61927. */
  61928. maximumScale: number;
  61929. /**
  61930. * Defines the step to use between two passes (0.5 by default)
  61931. */
  61932. step: number;
  61933. private _currentScale;
  61934. private _directionOffset;
  61935. /**
  61936. * Gets a string describing the action executed by the current optimization
  61937. * @return description string
  61938. */
  61939. getDescription(): string;
  61940. /**
  61941. * Creates the HardwareScalingOptimization object
  61942. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61943. * @param maximumScale defines the maximum scale to use (2 by default)
  61944. * @param step defines the step to use between two passes (0.5 by default)
  61945. */
  61946. constructor(
  61947. /**
  61948. * Defines the priority of this optimization (0 by default which means first in the list)
  61949. */
  61950. priority?: number,
  61951. /**
  61952. * Defines the maximum scale to use (2 by default)
  61953. */
  61954. maximumScale?: number,
  61955. /**
  61956. * Defines the step to use between two passes (0.5 by default)
  61957. */
  61958. step?: number);
  61959. /**
  61960. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61961. * @param scene defines the current scene where to apply this optimization
  61962. * @param optimizer defines the current optimizer
  61963. * @returns true if everything that can be done was applied
  61964. */
  61965. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61966. }
  61967. /**
  61968. * Defines an optimization used to remove shadows
  61969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61970. */
  61971. export class ShadowsOptimization extends SceneOptimization {
  61972. /**
  61973. * Gets a string describing the action executed by the current optimization
  61974. * @return description string
  61975. */
  61976. getDescription(): string;
  61977. /**
  61978. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61979. * @param scene defines the current scene where to apply this optimization
  61980. * @param optimizer defines the current optimizer
  61981. * @returns true if everything that can be done was applied
  61982. */
  61983. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61984. }
  61985. /**
  61986. * Defines an optimization used to turn post-processes off
  61987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61988. */
  61989. export class PostProcessesOptimization extends SceneOptimization {
  61990. /**
  61991. * Gets a string describing the action executed by the current optimization
  61992. * @return description string
  61993. */
  61994. getDescription(): string;
  61995. /**
  61996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61997. * @param scene defines the current scene where to apply this optimization
  61998. * @param optimizer defines the current optimizer
  61999. * @returns true if everything that can be done was applied
  62000. */
  62001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62002. }
  62003. /**
  62004. * Defines an optimization used to turn lens flares off
  62005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62006. */
  62007. export class LensFlaresOptimization extends SceneOptimization {
  62008. /**
  62009. * Gets a string describing the action executed by the current optimization
  62010. * @return description string
  62011. */
  62012. getDescription(): string;
  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. * @returns true if everything that can be done was applied
  62018. */
  62019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62020. }
  62021. /**
  62022. * Defines an optimization based on user defined callback.
  62023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62024. */
  62025. export class CustomOptimization extends SceneOptimization {
  62026. /**
  62027. * Callback called to apply the custom optimization.
  62028. */
  62029. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62030. /**
  62031. * Callback called to get custom description
  62032. */
  62033. onGetDescription: () => string;
  62034. /**
  62035. * Gets a string describing the action executed by the current optimization
  62036. * @returns description string
  62037. */
  62038. getDescription(): string;
  62039. /**
  62040. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62041. * @param scene defines the current scene where to apply this optimization
  62042. * @param optimizer defines the current optimizer
  62043. * @returns true if everything that can be done was applied
  62044. */
  62045. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62046. }
  62047. /**
  62048. * Defines an optimization used to turn particles off
  62049. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62050. */
  62051. export class ParticlesOptimization extends SceneOptimization {
  62052. /**
  62053. * Gets a string describing the action executed by the current optimization
  62054. * @return description string
  62055. */
  62056. getDescription(): string;
  62057. /**
  62058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62059. * @param scene defines the current scene where to apply this optimization
  62060. * @param optimizer defines the current optimizer
  62061. * @returns true if everything that can be done was applied
  62062. */
  62063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62064. }
  62065. /**
  62066. * Defines an optimization used to turn render targets off
  62067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62068. */
  62069. export class RenderTargetsOptimization extends SceneOptimization {
  62070. /**
  62071. * Gets a string describing the action executed by the current optimization
  62072. * @return description string
  62073. */
  62074. getDescription(): string;
  62075. /**
  62076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62077. * @param scene defines the current scene where to apply this optimization
  62078. * @param optimizer defines the current optimizer
  62079. * @returns true if everything that can be done was applied
  62080. */
  62081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62082. }
  62083. /**
  62084. * Defines an optimization used to merge meshes with compatible materials
  62085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62086. */
  62087. export class MergeMeshesOptimization extends SceneOptimization {
  62088. private static _UpdateSelectionTree;
  62089. /**
  62090. * Gets or sets a boolean which defines if optimization octree has to be updated
  62091. */
  62092. /**
  62093. * Gets or sets a boolean which defines if optimization octree has to be updated
  62094. */
  62095. static UpdateSelectionTree: boolean;
  62096. /**
  62097. * Gets a string describing the action executed by the current optimization
  62098. * @return description string
  62099. */
  62100. getDescription(): string;
  62101. private _canBeMerged;
  62102. /**
  62103. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62104. * @param scene defines the current scene where to apply this optimization
  62105. * @param optimizer defines the current optimizer
  62106. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62107. * @returns true if everything that can be done was applied
  62108. */
  62109. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62110. }
  62111. /**
  62112. * Defines a list of options used by SceneOptimizer
  62113. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62114. */
  62115. export class SceneOptimizerOptions {
  62116. /**
  62117. * Defines the target frame rate to reach (60 by default)
  62118. */
  62119. targetFrameRate: number;
  62120. /**
  62121. * Defines the interval between two checkes (2000ms by default)
  62122. */
  62123. trackerDuration: number;
  62124. /**
  62125. * Gets the list of optimizations to apply
  62126. */
  62127. optimizations: SceneOptimization[];
  62128. /**
  62129. * Creates a new list of options used by SceneOptimizer
  62130. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62131. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62132. */
  62133. constructor(
  62134. /**
  62135. * Defines the target frame rate to reach (60 by default)
  62136. */
  62137. targetFrameRate?: number,
  62138. /**
  62139. * Defines the interval between two checkes (2000ms by default)
  62140. */
  62141. trackerDuration?: number);
  62142. /**
  62143. * Add a new optimization
  62144. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62145. * @returns the current SceneOptimizerOptions
  62146. */
  62147. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62148. /**
  62149. * Add a new custom optimization
  62150. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62151. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62152. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62153. * @returns the current SceneOptimizerOptions
  62154. */
  62155. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62156. /**
  62157. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62158. * @param targetFrameRate defines the target frame rate (60 by default)
  62159. * @returns a SceneOptimizerOptions object
  62160. */
  62161. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62162. /**
  62163. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62164. * @param targetFrameRate defines the target frame rate (60 by default)
  62165. * @returns a SceneOptimizerOptions object
  62166. */
  62167. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62168. /**
  62169. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62170. * @param targetFrameRate defines the target frame rate (60 by default)
  62171. * @returns a SceneOptimizerOptions object
  62172. */
  62173. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62174. }
  62175. /**
  62176. * Class used to run optimizations in order to reach a target frame rate
  62177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62178. */
  62179. export class SceneOptimizer implements IDisposable {
  62180. private _isRunning;
  62181. private _options;
  62182. private _scene;
  62183. private _currentPriorityLevel;
  62184. private _targetFrameRate;
  62185. private _trackerDuration;
  62186. private _currentFrameRate;
  62187. private _sceneDisposeObserver;
  62188. private _improvementMode;
  62189. /**
  62190. * Defines an observable called when the optimizer reaches the target frame rate
  62191. */
  62192. onSuccessObservable: Observable<SceneOptimizer>;
  62193. /**
  62194. * Defines an observable called when the optimizer enables an optimization
  62195. */
  62196. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62197. /**
  62198. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62199. */
  62200. onFailureObservable: Observable<SceneOptimizer>;
  62201. /**
  62202. * Gets a boolean indicating if the optimizer is in improvement mode
  62203. */
  62204. readonly isInImprovementMode: boolean;
  62205. /**
  62206. * Gets the current priority level (0 at start)
  62207. */
  62208. readonly currentPriorityLevel: number;
  62209. /**
  62210. * Gets the current frame rate checked by the SceneOptimizer
  62211. */
  62212. readonly currentFrameRate: number;
  62213. /**
  62214. * Gets or sets the current target frame rate (60 by default)
  62215. */
  62216. /**
  62217. * Gets or sets the current target frame rate (60 by default)
  62218. */
  62219. targetFrameRate: number;
  62220. /**
  62221. * Gets or sets the current interval between two checks (every 2000ms by default)
  62222. */
  62223. /**
  62224. * Gets or sets the current interval between two checks (every 2000ms by default)
  62225. */
  62226. trackerDuration: number;
  62227. /**
  62228. * Gets the list of active optimizations
  62229. */
  62230. readonly optimizations: SceneOptimization[];
  62231. /**
  62232. * Creates a new SceneOptimizer
  62233. * @param scene defines the scene to work on
  62234. * @param options defines the options to use with the SceneOptimizer
  62235. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62236. * @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)
  62237. */
  62238. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62239. /**
  62240. * Stops the current optimizer
  62241. */
  62242. stop(): void;
  62243. /**
  62244. * Reset the optimizer to initial step (current priority level = 0)
  62245. */
  62246. reset(): void;
  62247. /**
  62248. * Start the optimizer. By default it will try to reach a specific framerate
  62249. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62250. */
  62251. start(): void;
  62252. private _checkCurrentState;
  62253. /**
  62254. * Release all resources
  62255. */
  62256. dispose(): void;
  62257. /**
  62258. * Helper function to create a SceneOptimizer with one single line of code
  62259. * @param scene defines the scene to work on
  62260. * @param options defines the options to use with the SceneOptimizer
  62261. * @param onSuccess defines a callback to call on success
  62262. * @param onFailure defines a callback to call on failure
  62263. * @returns the new SceneOptimizer object
  62264. */
  62265. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62266. }
  62267. }
  62268. declare module "babylonjs/Misc/sceneSerializer" {
  62269. import { Scene } from "babylonjs/scene";
  62270. /**
  62271. * Class used to serialize a scene into a string
  62272. */
  62273. export class SceneSerializer {
  62274. /**
  62275. * Clear cache used by a previous serialization
  62276. */
  62277. static ClearCache(): void;
  62278. /**
  62279. * Serialize a scene into a JSON compatible object
  62280. * @param scene defines the scene to serialize
  62281. * @returns a JSON compatible object
  62282. */
  62283. static Serialize(scene: Scene): any;
  62284. /**
  62285. * Serialize a mesh into a JSON compatible object
  62286. * @param toSerialize defines the mesh to serialize
  62287. * @param withParents defines if parents must be serialized as well
  62288. * @param withChildren defines if children must be serialized as well
  62289. * @returns a JSON compatible object
  62290. */
  62291. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62292. }
  62293. }
  62294. declare module "babylonjs/Misc/textureTools" {
  62295. import { Texture } from "babylonjs/Materials/Textures/texture";
  62296. /**
  62297. * Class used to host texture specific utilities
  62298. */
  62299. export class TextureTools {
  62300. /**
  62301. * Uses the GPU to create a copy texture rescaled at a given size
  62302. * @param texture Texture to copy from
  62303. * @param width defines the desired width
  62304. * @param height defines the desired height
  62305. * @param useBilinearMode defines if bilinear mode has to be used
  62306. * @return the generated texture
  62307. */
  62308. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62309. }
  62310. }
  62311. declare module "babylonjs/Misc/videoRecorder" {
  62312. import { Nullable } from "babylonjs/types";
  62313. import { Engine } from "babylonjs/Engines/engine";
  62314. /**
  62315. * This represents the different options available for the video capture.
  62316. */
  62317. export interface VideoRecorderOptions {
  62318. /** Defines the mime type of the video. */
  62319. mimeType: string;
  62320. /** Defines the FPS the video should be recorded at. */
  62321. fps: number;
  62322. /** Defines the chunk size for the recording data. */
  62323. recordChunckSize: number;
  62324. /** The audio tracks to attach to the recording. */
  62325. audioTracks?: MediaStreamTrack[];
  62326. }
  62327. /**
  62328. * This can help with recording videos from BabylonJS.
  62329. * This is based on the available WebRTC functionalities of the browser.
  62330. *
  62331. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62332. */
  62333. export class VideoRecorder {
  62334. private static readonly _defaultOptions;
  62335. /**
  62336. * Returns whether or not the VideoRecorder is available in your browser.
  62337. * @param engine Defines the Babylon Engine.
  62338. * @returns true if supported otherwise false.
  62339. */
  62340. static IsSupported(engine: Engine): boolean;
  62341. private readonly _options;
  62342. private _canvas;
  62343. private _mediaRecorder;
  62344. private _recordedChunks;
  62345. private _fileName;
  62346. private _resolve;
  62347. private _reject;
  62348. /**
  62349. * True when a recording is already in progress.
  62350. */
  62351. readonly isRecording: boolean;
  62352. /**
  62353. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62354. * @param engine Defines the BabylonJS Engine you wish to record.
  62355. * @param options Defines options that can be used to customize the capture.
  62356. */
  62357. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62358. /**
  62359. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62360. */
  62361. stopRecording(): void;
  62362. /**
  62363. * Starts recording the canvas for a max duration specified in parameters.
  62364. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62365. * If null no automatic download will start and you can rely on the promise to get the data back.
  62366. * @param maxDuration Defines the maximum recording time in seconds.
  62367. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62368. * @return A promise callback at the end of the recording with the video data in Blob.
  62369. */
  62370. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62371. /**
  62372. * Releases internal resources used during the recording.
  62373. */
  62374. dispose(): void;
  62375. private _handleDataAvailable;
  62376. private _handleError;
  62377. private _handleStop;
  62378. }
  62379. }
  62380. declare module "babylonjs/Misc/screenshotTools" {
  62381. import { Camera } from "babylonjs/Cameras/camera";
  62382. import { Engine } from "babylonjs/Engines/engine";
  62383. /**
  62384. * Class containing a set of static utilities functions for screenshots
  62385. */
  62386. export class ScreenshotTools {
  62387. /**
  62388. * Captures a screenshot of the current rendering
  62389. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62390. * @param engine defines the rendering engine
  62391. * @param camera defines the source camera
  62392. * @param size This parameter can be set to a single number or to an object with the
  62393. * following (optional) properties: precision, width, height. If a single number is passed,
  62394. * it will be used for both width and height. If an object is passed, the screenshot size
  62395. * will be derived from the parameters. The precision property is a multiplier allowing
  62396. * rendering at a higher or lower resolution
  62397. * @param successCallback defines the callback receives a single parameter which contains the
  62398. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62399. * src parameter of an <img> to display it
  62400. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62401. * Check your browser for supported MIME types
  62402. */
  62403. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62404. /**
  62405. * Generates an image screenshot from the specified camera.
  62406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62407. * @param engine The engine to use for rendering
  62408. * @param camera The camera to use for rendering
  62409. * @param size This parameter can be set to a single number or to an object with the
  62410. * following (optional) properties: precision, width, height. If a single number is passed,
  62411. * it will be used for both width and height. If an object is passed, the screenshot size
  62412. * will be derived from the parameters. The precision property is a multiplier allowing
  62413. * rendering at a higher or lower resolution
  62414. * @param successCallback The callback receives a single parameter which contains the
  62415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62416. * src parameter of an <img> to display it
  62417. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62418. * Check your browser for supported MIME types
  62419. * @param samples Texture samples (default: 1)
  62420. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62421. * @param fileName A name for for the downloaded file.
  62422. */
  62423. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62424. }
  62425. }
  62426. declare module "babylonjs/Misc/index" {
  62427. export * from "babylonjs/Misc/andOrNotEvaluator";
  62428. export * from "babylonjs/Misc/assetsManager";
  62429. export * from "babylonjs/Misc/dds";
  62430. export * from "babylonjs/Misc/decorators";
  62431. export * from "babylonjs/Misc/deferred";
  62432. export * from "babylonjs/Misc/environmentTextureTools";
  62433. export * from "babylonjs/Misc/meshExploder";
  62434. export * from "babylonjs/Misc/filesInput";
  62435. export * from "babylonjs/Misc/HighDynamicRange/index";
  62436. export * from "babylonjs/Misc/khronosTextureContainer";
  62437. export * from "babylonjs/Misc/observable";
  62438. export * from "babylonjs/Misc/performanceMonitor";
  62439. export * from "babylonjs/Misc/promise";
  62440. export * from "babylonjs/Misc/sceneOptimizer";
  62441. export * from "babylonjs/Misc/sceneSerializer";
  62442. export * from "babylonjs/Misc/smartArray";
  62443. export * from "babylonjs/Misc/stringDictionary";
  62444. export * from "babylonjs/Misc/tags";
  62445. export * from "babylonjs/Misc/textureTools";
  62446. export * from "babylonjs/Misc/tga";
  62447. export * from "babylonjs/Misc/tools";
  62448. export * from "babylonjs/Misc/videoRecorder";
  62449. export * from "babylonjs/Misc/virtualJoystick";
  62450. export * from "babylonjs/Misc/workerPool";
  62451. export * from "babylonjs/Misc/logger";
  62452. export * from "babylonjs/Misc/typeStore";
  62453. export * from "babylonjs/Misc/filesInputStore";
  62454. export * from "babylonjs/Misc/deepCopier";
  62455. export * from "babylonjs/Misc/pivotTools";
  62456. export * from "babylonjs/Misc/precisionDate";
  62457. export * from "babylonjs/Misc/screenshotTools";
  62458. export * from "babylonjs/Misc/typeStore";
  62459. export * from "babylonjs/Misc/webRequest";
  62460. export * from "babylonjs/Misc/iInspectable";
  62461. export * from "babylonjs/Misc/brdfTextureTools";
  62462. }
  62463. declare module "babylonjs/index" {
  62464. export * from "babylonjs/abstractScene";
  62465. export * from "babylonjs/Actions/index";
  62466. export * from "babylonjs/Animations/index";
  62467. export * from "babylonjs/assetContainer";
  62468. export * from "babylonjs/Audio/index";
  62469. export * from "babylonjs/Behaviors/index";
  62470. export * from "babylonjs/Bones/index";
  62471. export * from "babylonjs/Cameras/index";
  62472. export * from "babylonjs/Collisions/index";
  62473. export * from "babylonjs/Culling/index";
  62474. export * from "babylonjs/Debug/index";
  62475. export * from "babylonjs/Engines/index";
  62476. export * from "babylonjs/Events/index";
  62477. export * from "babylonjs/Gamepads/index";
  62478. export * from "babylonjs/Gizmos/index";
  62479. export * from "babylonjs/Helpers/index";
  62480. export * from "babylonjs/Instrumentation/index";
  62481. export * from "babylonjs/Layers/index";
  62482. export * from "babylonjs/LensFlares/index";
  62483. export * from "babylonjs/Lights/index";
  62484. export * from "babylonjs/Loading/index";
  62485. export * from "babylonjs/Materials/index";
  62486. export * from "babylonjs/Maths/index";
  62487. export * from "babylonjs/Meshes/index";
  62488. export * from "babylonjs/Morph/index";
  62489. export * from "babylonjs/node";
  62490. export * from "babylonjs/Offline/index";
  62491. export * from "babylonjs/Particles/index";
  62492. export * from "babylonjs/Physics/index";
  62493. export * from "babylonjs/PostProcesses/index";
  62494. export * from "babylonjs/Probes/index";
  62495. export * from "babylonjs/Rendering/index";
  62496. export * from "babylonjs/scene";
  62497. export * from "babylonjs/sceneComponent";
  62498. export * from "babylonjs/Sprites/index";
  62499. export * from "babylonjs/States/index";
  62500. export * from "babylonjs/Misc/index";
  62501. export * from "babylonjs/types";
  62502. }
  62503. declare module "babylonjs/Animations/pathCursor" {
  62504. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62505. /**
  62506. * A cursor which tracks a point on a path
  62507. */
  62508. export class PathCursor {
  62509. private path;
  62510. /**
  62511. * Stores path cursor callbacks for when an onchange event is triggered
  62512. */
  62513. private _onchange;
  62514. /**
  62515. * The value of the path cursor
  62516. */
  62517. value: number;
  62518. /**
  62519. * The animation array of the path cursor
  62520. */
  62521. animations: Animation[];
  62522. /**
  62523. * Initializes the path cursor
  62524. * @param path The path to track
  62525. */
  62526. constructor(path: Path2);
  62527. /**
  62528. * Gets the cursor point on the path
  62529. * @returns A point on the path cursor at the cursor location
  62530. */
  62531. getPoint(): Vector3;
  62532. /**
  62533. * Moves the cursor ahead by the step amount
  62534. * @param step The amount to move the cursor forward
  62535. * @returns This path cursor
  62536. */
  62537. moveAhead(step?: number): PathCursor;
  62538. /**
  62539. * Moves the cursor behind by the step amount
  62540. * @param step The amount to move the cursor back
  62541. * @returns This path cursor
  62542. */
  62543. moveBack(step?: number): PathCursor;
  62544. /**
  62545. * Moves the cursor by the step amount
  62546. * If the step amount is greater than one, an exception is thrown
  62547. * @param step The amount to move the cursor
  62548. * @returns This path cursor
  62549. */
  62550. move(step: number): PathCursor;
  62551. /**
  62552. * Ensures that the value is limited between zero and one
  62553. * @returns This path cursor
  62554. */
  62555. private ensureLimits;
  62556. /**
  62557. * Runs onchange callbacks on change (used by the animation engine)
  62558. * @returns This path cursor
  62559. */
  62560. private raiseOnChange;
  62561. /**
  62562. * Executes a function on change
  62563. * @param f A path cursor onchange callback
  62564. * @returns This path cursor
  62565. */
  62566. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62567. }
  62568. }
  62569. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62570. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62571. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62572. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62573. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62574. }
  62575. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62576. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62577. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62578. }
  62579. declare module "babylonjs/Engines/Processors/index" {
  62580. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62581. export * from "babylonjs/Engines/Processors/Expressions/index";
  62582. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62583. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62584. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62585. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62586. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62587. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62588. }
  62589. declare module "babylonjs/Legacy/legacy" {
  62590. import * as Babylon from "babylonjs/index";
  62591. export * from "babylonjs/index";
  62592. }
  62593. declare module "babylonjs/Shaders/blur.fragment" {
  62594. /** @hidden */
  62595. export var blurPixelShader: {
  62596. name: string;
  62597. shader: string;
  62598. };
  62599. }
  62600. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62601. /** @hidden */
  62602. export var pointCloudVertexDeclaration: {
  62603. name: string;
  62604. shader: string;
  62605. };
  62606. }
  62607. declare module "babylonjs" {
  62608. export * from "babylonjs/Legacy/legacy";
  62609. }
  62610. declare module BABYLON {
  62611. /** Alias type for value that can be null */
  62612. export type Nullable<T> = T | null;
  62613. /**
  62614. * Alias type for number that are floats
  62615. * @ignorenaming
  62616. */
  62617. export type float = number;
  62618. /**
  62619. * Alias type for number that are doubles.
  62620. * @ignorenaming
  62621. */
  62622. export type double = number;
  62623. /**
  62624. * Alias type for number that are integer
  62625. * @ignorenaming
  62626. */
  62627. export type int = number;
  62628. /** Alias type for number array or Float32Array */
  62629. export type FloatArray = number[] | Float32Array;
  62630. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62631. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62632. /**
  62633. * Alias for types that can be used by a Buffer or VertexBuffer.
  62634. */
  62635. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62636. /**
  62637. * Alias type for primitive types
  62638. * @ignorenaming
  62639. */
  62640. type Primitive = undefined | null | boolean | string | number | Function;
  62641. /**
  62642. * Type modifier to make all the properties of an object Readonly
  62643. */
  62644. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62645. /**
  62646. * Type modifier to make all the properties of an object Readonly recursively
  62647. */
  62648. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62649. /** @hidden */
  62650. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62651. }
  62652. /** @hidden */
  62653. /** @hidden */
  62654. type DeepImmutableObject<T> = {
  62655. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62656. };
  62657. }
  62658. declare module BABYLON {
  62659. /**
  62660. * Class containing a set of static utilities functions for arrays.
  62661. */
  62662. export class ArrayTools {
  62663. /**
  62664. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62665. * @param size the number of element to construct and put in the array
  62666. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62667. * @returns a new array filled with new objects
  62668. */
  62669. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62670. }
  62671. }
  62672. declare module BABYLON {
  62673. /**
  62674. * Scalar computation library
  62675. */
  62676. export class Scalar {
  62677. /**
  62678. * Two pi constants convenient for computation.
  62679. */
  62680. static TwoPi: number;
  62681. /**
  62682. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62683. * @param a number
  62684. * @param b number
  62685. * @param epsilon (default = 1.401298E-45)
  62686. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62687. */
  62688. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62689. /**
  62690. * Returns a string : the upper case translation of the number i to hexadecimal.
  62691. * @param i number
  62692. * @returns the upper case translation of the number i to hexadecimal.
  62693. */
  62694. static ToHex(i: number): string;
  62695. /**
  62696. * Returns -1 if value is negative and +1 is value is positive.
  62697. * @param value the value
  62698. * @returns the value itself if it's equal to zero.
  62699. */
  62700. static Sign(value: number): number;
  62701. /**
  62702. * Returns the value itself if it's between min and max.
  62703. * Returns min if the value is lower than min.
  62704. * Returns max if the value is greater than max.
  62705. * @param value the value to clmap
  62706. * @param min the min value to clamp to (default: 0)
  62707. * @param max the max value to clamp to (default: 1)
  62708. * @returns the clamped value
  62709. */
  62710. static Clamp(value: number, min?: number, max?: number): number;
  62711. /**
  62712. * the log2 of value.
  62713. * @param value the value to compute log2 of
  62714. * @returns the log2 of value.
  62715. */
  62716. static Log2(value: number): number;
  62717. /**
  62718. * Loops the value, so that it is never larger than length and never smaller than 0.
  62719. *
  62720. * This is similar to the modulo operator but it works with floating point numbers.
  62721. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62722. * With t = 5 and length = 2.5, the result would be 0.0.
  62723. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62724. * @param value the value
  62725. * @param length the length
  62726. * @returns the looped value
  62727. */
  62728. static Repeat(value: number, length: number): number;
  62729. /**
  62730. * Normalize the value between 0.0 and 1.0 using min and max values
  62731. * @param value value to normalize
  62732. * @param min max to normalize between
  62733. * @param max min to normalize between
  62734. * @returns the normalized value
  62735. */
  62736. static Normalize(value: number, min: number, max: number): number;
  62737. /**
  62738. * Denormalize the value from 0.0 and 1.0 using min and max values
  62739. * @param normalized value to denormalize
  62740. * @param min max to denormalize between
  62741. * @param max min to denormalize between
  62742. * @returns the denormalized value
  62743. */
  62744. static Denormalize(normalized: number, min: number, max: number): number;
  62745. /**
  62746. * Calculates the shortest difference between two given angles given in degrees.
  62747. * @param current current angle in degrees
  62748. * @param target target angle in degrees
  62749. * @returns the delta
  62750. */
  62751. static DeltaAngle(current: number, target: number): number;
  62752. /**
  62753. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62754. * @param tx value
  62755. * @param length length
  62756. * @returns The returned value will move back and forth between 0 and length
  62757. */
  62758. static PingPong(tx: number, length: number): number;
  62759. /**
  62760. * Interpolates between min and max with smoothing at the limits.
  62761. *
  62762. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62763. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62764. * @param from from
  62765. * @param to to
  62766. * @param tx value
  62767. * @returns the smooth stepped value
  62768. */
  62769. static SmoothStep(from: number, to: number, tx: number): number;
  62770. /**
  62771. * Moves a value current towards target.
  62772. *
  62773. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62774. * Negative values of maxDelta pushes the value away from target.
  62775. * @param current current value
  62776. * @param target target value
  62777. * @param maxDelta max distance to move
  62778. * @returns resulting value
  62779. */
  62780. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62781. /**
  62782. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62783. *
  62784. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62785. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62786. * @param current current value
  62787. * @param target target value
  62788. * @param maxDelta max distance to move
  62789. * @returns resulting angle
  62790. */
  62791. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62792. /**
  62793. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62794. * @param start start value
  62795. * @param end target value
  62796. * @param amount amount to lerp between
  62797. * @returns the lerped value
  62798. */
  62799. static Lerp(start: number, end: number, amount: number): number;
  62800. /**
  62801. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62802. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62803. * @param start start value
  62804. * @param end target value
  62805. * @param amount amount to lerp between
  62806. * @returns the lerped value
  62807. */
  62808. static LerpAngle(start: number, end: number, amount: number): number;
  62809. /**
  62810. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62811. * @param a start value
  62812. * @param b target value
  62813. * @param value value between a and b
  62814. * @returns the inverseLerp value
  62815. */
  62816. static InverseLerp(a: number, b: number, value: number): number;
  62817. /**
  62818. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62819. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62820. * @param value1 spline value
  62821. * @param tangent1 spline value
  62822. * @param value2 spline value
  62823. * @param tangent2 spline value
  62824. * @param amount input value
  62825. * @returns hermite result
  62826. */
  62827. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62828. /**
  62829. * Returns a random float number between and min and max values
  62830. * @param min min value of random
  62831. * @param max max value of random
  62832. * @returns random value
  62833. */
  62834. static RandomRange(min: number, max: number): number;
  62835. /**
  62836. * This function returns percentage of a number in a given range.
  62837. *
  62838. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62839. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62840. * @param number to convert to percentage
  62841. * @param min min range
  62842. * @param max max range
  62843. * @returns the percentage
  62844. */
  62845. static RangeToPercent(number: number, min: number, max: number): number;
  62846. /**
  62847. * This function returns number that corresponds to the percentage in a given range.
  62848. *
  62849. * PercentToRange(0.34,0,100) will return 34.
  62850. * @param percent to convert to number
  62851. * @param min min range
  62852. * @param max max range
  62853. * @returns the number
  62854. */
  62855. static PercentToRange(percent: number, min: number, max: number): number;
  62856. /**
  62857. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62858. * @param angle The angle to normalize in radian.
  62859. * @return The converted angle.
  62860. */
  62861. static NormalizeRadians(angle: number): number;
  62862. }
  62863. }
  62864. declare module BABYLON {
  62865. /**
  62866. * Constant used to convert a value to gamma space
  62867. * @ignorenaming
  62868. */
  62869. export const ToGammaSpace: number;
  62870. /**
  62871. * Constant used to convert a value to linear space
  62872. * @ignorenaming
  62873. */
  62874. export const ToLinearSpace = 2.2;
  62875. /**
  62876. * Constant used to define the minimal number value in Babylon.js
  62877. * @ignorenaming
  62878. */
  62879. let Epsilon: number;
  62880. /**
  62881. * Class used to hold a RBG color
  62882. */
  62883. export class Color3 {
  62884. /**
  62885. * Defines the red component (between 0 and 1, default is 0)
  62886. */
  62887. r: number;
  62888. /**
  62889. * Defines the green component (between 0 and 1, default is 0)
  62890. */
  62891. g: number;
  62892. /**
  62893. * Defines the blue component (between 0 and 1, default is 0)
  62894. */
  62895. b: number;
  62896. /**
  62897. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62898. * @param r defines the red component (between 0 and 1, default is 0)
  62899. * @param g defines the green component (between 0 and 1, default is 0)
  62900. * @param b defines the blue component (between 0 and 1, default is 0)
  62901. */
  62902. constructor(
  62903. /**
  62904. * Defines the red component (between 0 and 1, default is 0)
  62905. */
  62906. r?: number,
  62907. /**
  62908. * Defines the green component (between 0 and 1, default is 0)
  62909. */
  62910. g?: number,
  62911. /**
  62912. * Defines the blue component (between 0 and 1, default is 0)
  62913. */
  62914. b?: number);
  62915. /**
  62916. * Creates a string with the Color3 current values
  62917. * @returns the string representation of the Color3 object
  62918. */
  62919. toString(): string;
  62920. /**
  62921. * Returns the string "Color3"
  62922. * @returns "Color3"
  62923. */
  62924. getClassName(): string;
  62925. /**
  62926. * Compute the Color3 hash code
  62927. * @returns an unique number that can be used to hash Color3 objects
  62928. */
  62929. getHashCode(): number;
  62930. /**
  62931. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62932. * @param array defines the array where to store the r,g,b components
  62933. * @param index defines an optional index in the target array to define where to start storing values
  62934. * @returns the current Color3 object
  62935. */
  62936. toArray(array: FloatArray, index?: number): Color3;
  62937. /**
  62938. * Returns a new Color4 object from the current Color3 and the given alpha
  62939. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62940. * @returns a new Color4 object
  62941. */
  62942. toColor4(alpha?: number): Color4;
  62943. /**
  62944. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62945. * @returns the new array
  62946. */
  62947. asArray(): number[];
  62948. /**
  62949. * Returns the luminance value
  62950. * @returns a float value
  62951. */
  62952. toLuminance(): number;
  62953. /**
  62954. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62955. * @param otherColor defines the second operand
  62956. * @returns the new Color3 object
  62957. */
  62958. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62959. /**
  62960. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62961. * @param otherColor defines the second operand
  62962. * @param result defines the Color3 object where to store the result
  62963. * @returns the current Color3
  62964. */
  62965. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62966. /**
  62967. * Determines equality between Color3 objects
  62968. * @param otherColor defines the second operand
  62969. * @returns true if the rgb values are equal to the given ones
  62970. */
  62971. equals(otherColor: DeepImmutable<Color3>): boolean;
  62972. /**
  62973. * Determines equality between the current Color3 object and a set of r,b,g values
  62974. * @param r defines the red component to check
  62975. * @param g defines the green component to check
  62976. * @param b defines the blue component to check
  62977. * @returns true if the rgb values are equal to the given ones
  62978. */
  62979. equalsFloats(r: number, g: number, b: number): boolean;
  62980. /**
  62981. * Multiplies in place each rgb value by scale
  62982. * @param scale defines the scaling factor
  62983. * @returns the updated Color3
  62984. */
  62985. scale(scale: number): Color3;
  62986. /**
  62987. * Multiplies the rgb values by scale and stores the result into "result"
  62988. * @param scale defines the scaling factor
  62989. * @param result defines the Color3 object where to store the result
  62990. * @returns the unmodified current Color3
  62991. */
  62992. scaleToRef(scale: number, result: Color3): Color3;
  62993. /**
  62994. * Scale the current Color3 values by a factor and add the result to a given Color3
  62995. * @param scale defines the scale factor
  62996. * @param result defines color to store the result into
  62997. * @returns the unmodified current Color3
  62998. */
  62999. scaleAndAddToRef(scale: number, result: Color3): Color3;
  63000. /**
  63001. * Clamps the rgb values by the min and max values and stores the result into "result"
  63002. * @param min defines minimum clamping value (default is 0)
  63003. * @param max defines maximum clamping value (default is 1)
  63004. * @param result defines color to store the result into
  63005. * @returns the original Color3
  63006. */
  63007. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  63008. /**
  63009. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  63010. * @param otherColor defines the second operand
  63011. * @returns the new Color3
  63012. */
  63013. add(otherColor: DeepImmutable<Color3>): Color3;
  63014. /**
  63015. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  63016. * @param otherColor defines the second operand
  63017. * @param result defines Color3 object to store the result into
  63018. * @returns the unmodified current Color3
  63019. */
  63020. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63021. /**
  63022. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  63023. * @param otherColor defines the second operand
  63024. * @returns the new Color3
  63025. */
  63026. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63027. /**
  63028. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63029. * @param otherColor defines the second operand
  63030. * @param result defines Color3 object to store the result into
  63031. * @returns the unmodified current Color3
  63032. */
  63033. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63034. /**
  63035. * Copy the current object
  63036. * @returns a new Color3 copied the current one
  63037. */
  63038. clone(): Color3;
  63039. /**
  63040. * Copies the rgb values from the source in the current Color3
  63041. * @param source defines the source Color3 object
  63042. * @returns the updated Color3 object
  63043. */
  63044. copyFrom(source: DeepImmutable<Color3>): Color3;
  63045. /**
  63046. * Updates the Color3 rgb values from the given floats
  63047. * @param r defines the red component to read from
  63048. * @param g defines the green component to read from
  63049. * @param b defines the blue component to read from
  63050. * @returns the current Color3 object
  63051. */
  63052. copyFromFloats(r: number, g: number, b: number): Color3;
  63053. /**
  63054. * Updates the Color3 rgb values from the given floats
  63055. * @param r defines the red component to read from
  63056. * @param g defines the green component to read from
  63057. * @param b defines the blue component to read from
  63058. * @returns the current Color3 object
  63059. */
  63060. set(r: number, g: number, b: number): Color3;
  63061. /**
  63062. * Compute the Color3 hexadecimal code as a string
  63063. * @returns a string containing the hexadecimal representation of the Color3 object
  63064. */
  63065. toHexString(): string;
  63066. /**
  63067. * Computes a new Color3 converted from the current one to linear space
  63068. * @returns a new Color3 object
  63069. */
  63070. toLinearSpace(): Color3;
  63071. /**
  63072. * Converts current color in rgb space to HSV values
  63073. * @returns a new color3 representing the HSV values
  63074. */
  63075. toHSV(): Color3;
  63076. /**
  63077. * Converts current color in rgb space to HSV values
  63078. * @param result defines the Color3 where to store the HSV values
  63079. */
  63080. toHSVToRef(result: Color3): void;
  63081. /**
  63082. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63083. * @param convertedColor defines the Color3 object where to store the linear space version
  63084. * @returns the unmodified Color3
  63085. */
  63086. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63087. /**
  63088. * Computes a new Color3 converted from the current one to gamma space
  63089. * @returns a new Color3 object
  63090. */
  63091. toGammaSpace(): Color3;
  63092. /**
  63093. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63094. * @param convertedColor defines the Color3 object where to store the gamma space version
  63095. * @returns the unmodified Color3
  63096. */
  63097. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63098. private static _BlackReadOnly;
  63099. /**
  63100. * Convert Hue, saturation and value to a Color3 (RGB)
  63101. * @param hue defines the hue
  63102. * @param saturation defines the saturation
  63103. * @param value defines the value
  63104. * @param result defines the Color3 where to store the RGB values
  63105. */
  63106. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63107. /**
  63108. * Creates a new Color3 from the string containing valid hexadecimal values
  63109. * @param hex defines a string containing valid hexadecimal values
  63110. * @returns a new Color3 object
  63111. */
  63112. static FromHexString(hex: string): Color3;
  63113. /**
  63114. * Creates a new Color3 from the starting index of the given array
  63115. * @param array defines the source array
  63116. * @param offset defines an offset in the source array
  63117. * @returns a new Color3 object
  63118. */
  63119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63120. /**
  63121. * Creates a new Color3 from integer values (< 256)
  63122. * @param r defines the red component to read from (value between 0 and 255)
  63123. * @param g defines the green component to read from (value between 0 and 255)
  63124. * @param b defines the blue component to read from (value between 0 and 255)
  63125. * @returns a new Color3 object
  63126. */
  63127. static FromInts(r: number, g: number, b: number): Color3;
  63128. /**
  63129. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63130. * @param start defines the start Color3 value
  63131. * @param end defines the end Color3 value
  63132. * @param amount defines the gradient value between start and end
  63133. * @returns a new Color3 object
  63134. */
  63135. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63136. /**
  63137. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63138. * @param left defines the start value
  63139. * @param right defines the end value
  63140. * @param amount defines the gradient factor
  63141. * @param result defines the Color3 object where to store the result
  63142. */
  63143. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63144. /**
  63145. * Returns a Color3 value containing a red color
  63146. * @returns a new Color3 object
  63147. */
  63148. static Red(): Color3;
  63149. /**
  63150. * Returns a Color3 value containing a green color
  63151. * @returns a new Color3 object
  63152. */
  63153. static Green(): Color3;
  63154. /**
  63155. * Returns a Color3 value containing a blue color
  63156. * @returns a new Color3 object
  63157. */
  63158. static Blue(): Color3;
  63159. /**
  63160. * Returns a Color3 value containing a black color
  63161. * @returns a new Color3 object
  63162. */
  63163. static Black(): Color3;
  63164. /**
  63165. * Gets a Color3 value containing a black color that must not be updated
  63166. */
  63167. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63168. /**
  63169. * Returns a Color3 value containing a white color
  63170. * @returns a new Color3 object
  63171. */
  63172. static White(): Color3;
  63173. /**
  63174. * Returns a Color3 value containing a purple color
  63175. * @returns a new Color3 object
  63176. */
  63177. static Purple(): Color3;
  63178. /**
  63179. * Returns a Color3 value containing a magenta color
  63180. * @returns a new Color3 object
  63181. */
  63182. static Magenta(): Color3;
  63183. /**
  63184. * Returns a Color3 value containing a yellow color
  63185. * @returns a new Color3 object
  63186. */
  63187. static Yellow(): Color3;
  63188. /**
  63189. * Returns a Color3 value containing a gray color
  63190. * @returns a new Color3 object
  63191. */
  63192. static Gray(): Color3;
  63193. /**
  63194. * Returns a Color3 value containing a teal color
  63195. * @returns a new Color3 object
  63196. */
  63197. static Teal(): Color3;
  63198. /**
  63199. * Returns a Color3 value containing a random color
  63200. * @returns a new Color3 object
  63201. */
  63202. static Random(): Color3;
  63203. }
  63204. /**
  63205. * Class used to hold a RBGA color
  63206. */
  63207. export class Color4 {
  63208. /**
  63209. * Defines the red component (between 0 and 1, default is 0)
  63210. */
  63211. r: number;
  63212. /**
  63213. * Defines the green component (between 0 and 1, default is 0)
  63214. */
  63215. g: number;
  63216. /**
  63217. * Defines the blue component (between 0 and 1, default is 0)
  63218. */
  63219. b: number;
  63220. /**
  63221. * Defines the alpha component (between 0 and 1, default is 1)
  63222. */
  63223. a: number;
  63224. /**
  63225. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63226. * @param r defines the red component (between 0 and 1, default is 0)
  63227. * @param g defines the green component (between 0 and 1, default is 0)
  63228. * @param b defines the blue component (between 0 and 1, default is 0)
  63229. * @param a defines the alpha component (between 0 and 1, default is 1)
  63230. */
  63231. constructor(
  63232. /**
  63233. * Defines the red component (between 0 and 1, default is 0)
  63234. */
  63235. r?: number,
  63236. /**
  63237. * Defines the green component (between 0 and 1, default is 0)
  63238. */
  63239. g?: number,
  63240. /**
  63241. * Defines the blue component (between 0 and 1, default is 0)
  63242. */
  63243. b?: number,
  63244. /**
  63245. * Defines the alpha component (between 0 and 1, default is 1)
  63246. */
  63247. a?: number);
  63248. /**
  63249. * Adds in place the given Color4 values to the current Color4 object
  63250. * @param right defines the second operand
  63251. * @returns the current updated Color4 object
  63252. */
  63253. addInPlace(right: DeepImmutable<Color4>): Color4;
  63254. /**
  63255. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63256. * @returns the new array
  63257. */
  63258. asArray(): number[];
  63259. /**
  63260. * Stores from the starting index in the given array the Color4 successive values
  63261. * @param array defines the array where to store the r,g,b components
  63262. * @param index defines an optional index in the target array to define where to start storing values
  63263. * @returns the current Color4 object
  63264. */
  63265. toArray(array: number[], index?: number): Color4;
  63266. /**
  63267. * Determines equality between Color4 objects
  63268. * @param otherColor defines the second operand
  63269. * @returns true if the rgba values are equal to the given ones
  63270. */
  63271. equals(otherColor: DeepImmutable<Color4>): boolean;
  63272. /**
  63273. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63274. * @param right defines the second operand
  63275. * @returns a new Color4 object
  63276. */
  63277. add(right: DeepImmutable<Color4>): Color4;
  63278. /**
  63279. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63280. * @param right defines the second operand
  63281. * @returns a new Color4 object
  63282. */
  63283. subtract(right: DeepImmutable<Color4>): Color4;
  63284. /**
  63285. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63286. * @param right defines the second operand
  63287. * @param result defines the Color4 object where to store the result
  63288. * @returns the current Color4 object
  63289. */
  63290. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63291. /**
  63292. * Creates a new Color4 with the current Color4 values multiplied by scale
  63293. * @param scale defines the scaling factor to apply
  63294. * @returns a new Color4 object
  63295. */
  63296. scale(scale: number): Color4;
  63297. /**
  63298. * Multiplies the current Color4 values by scale and stores the result in "result"
  63299. * @param scale defines the scaling factor to apply
  63300. * @param result defines the Color4 object where to store the result
  63301. * @returns the current unmodified Color4
  63302. */
  63303. scaleToRef(scale: number, result: Color4): Color4;
  63304. /**
  63305. * Scale the current Color4 values by a factor and add the result to a given Color4
  63306. * @param scale defines the scale factor
  63307. * @param result defines the Color4 object where to store the result
  63308. * @returns the unmodified current Color4
  63309. */
  63310. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63311. /**
  63312. * Clamps the rgb values by the min and max values and stores the result into "result"
  63313. * @param min defines minimum clamping value (default is 0)
  63314. * @param max defines maximum clamping value (default is 1)
  63315. * @param result defines color to store the result into.
  63316. * @returns the cuurent Color4
  63317. */
  63318. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63319. /**
  63320. * Multipy an Color4 value by another and return a new Color4 object
  63321. * @param color defines the Color4 value to multiply by
  63322. * @returns a new Color4 object
  63323. */
  63324. multiply(color: Color4): Color4;
  63325. /**
  63326. * Multipy a Color4 value by another and push the result in a reference value
  63327. * @param color defines the Color4 value to multiply by
  63328. * @param result defines the Color4 to fill the result in
  63329. * @returns the result Color4
  63330. */
  63331. multiplyToRef(color: Color4, result: Color4): Color4;
  63332. /**
  63333. * Creates a string with the Color4 current values
  63334. * @returns the string representation of the Color4 object
  63335. */
  63336. toString(): string;
  63337. /**
  63338. * Returns the string "Color4"
  63339. * @returns "Color4"
  63340. */
  63341. getClassName(): string;
  63342. /**
  63343. * Compute the Color4 hash code
  63344. * @returns an unique number that can be used to hash Color4 objects
  63345. */
  63346. getHashCode(): number;
  63347. /**
  63348. * Creates a new Color4 copied from the current one
  63349. * @returns a new Color4 object
  63350. */
  63351. clone(): Color4;
  63352. /**
  63353. * Copies the given Color4 values into the current one
  63354. * @param source defines the source Color4 object
  63355. * @returns the current updated Color4 object
  63356. */
  63357. copyFrom(source: Color4): Color4;
  63358. /**
  63359. * Copies the given float values into the current one
  63360. * @param r defines the red component to read from
  63361. * @param g defines the green component to read from
  63362. * @param b defines the blue component to read from
  63363. * @param a defines the alpha component to read from
  63364. * @returns the current updated Color4 object
  63365. */
  63366. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63367. /**
  63368. * Copies the given float values into the current one
  63369. * @param r defines the red component to read from
  63370. * @param g defines the green component to read from
  63371. * @param b defines the blue component to read from
  63372. * @param a defines the alpha component to read from
  63373. * @returns the current updated Color4 object
  63374. */
  63375. set(r: number, g: number, b: number, a: number): Color4;
  63376. /**
  63377. * Compute the Color4 hexadecimal code as a string
  63378. * @returns a string containing the hexadecimal representation of the Color4 object
  63379. */
  63380. toHexString(): string;
  63381. /**
  63382. * Computes a new Color4 converted from the current one to linear space
  63383. * @returns a new Color4 object
  63384. */
  63385. toLinearSpace(): Color4;
  63386. /**
  63387. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63388. * @param convertedColor defines the Color4 object where to store the linear space version
  63389. * @returns the unmodified Color4
  63390. */
  63391. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63392. /**
  63393. * Computes a new Color4 converted from the current one to gamma space
  63394. * @returns a new Color4 object
  63395. */
  63396. toGammaSpace(): Color4;
  63397. /**
  63398. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63399. * @param convertedColor defines the Color4 object where to store the gamma space version
  63400. * @returns the unmodified Color4
  63401. */
  63402. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63403. /**
  63404. * Creates a new Color4 from the string containing valid hexadecimal values
  63405. * @param hex defines a string containing valid hexadecimal values
  63406. * @returns a new Color4 object
  63407. */
  63408. static FromHexString(hex: string): Color4;
  63409. /**
  63410. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63411. * @param left defines the start value
  63412. * @param right defines the end value
  63413. * @param amount defines the gradient factor
  63414. * @returns a new Color4 object
  63415. */
  63416. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63417. /**
  63418. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63419. * @param left defines the start value
  63420. * @param right defines the end value
  63421. * @param amount defines the gradient factor
  63422. * @param result defines the Color4 object where to store data
  63423. */
  63424. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63425. /**
  63426. * Creates a new Color4 from a Color3 and an alpha value
  63427. * @param color3 defines the source Color3 to read from
  63428. * @param alpha defines the alpha component (1.0 by default)
  63429. * @returns a new Color4 object
  63430. */
  63431. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63432. /**
  63433. * Creates a new Color4 from the starting index element of the given array
  63434. * @param array defines the source array to read from
  63435. * @param offset defines the offset in the source array
  63436. * @returns a new Color4 object
  63437. */
  63438. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63439. /**
  63440. * Creates a new Color3 from integer values (< 256)
  63441. * @param r defines the red component to read from (value between 0 and 255)
  63442. * @param g defines the green component to read from (value between 0 and 255)
  63443. * @param b defines the blue component to read from (value between 0 and 255)
  63444. * @param a defines the alpha component to read from (value between 0 and 255)
  63445. * @returns a new Color3 object
  63446. */
  63447. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63448. /**
  63449. * Check the content of a given array and convert it to an array containing RGBA data
  63450. * If the original array was already containing count * 4 values then it is returned directly
  63451. * @param colors defines the array to check
  63452. * @param count defines the number of RGBA data to expect
  63453. * @returns an array containing count * 4 values (RGBA)
  63454. */
  63455. static CheckColors4(colors: number[], count: number): number[];
  63456. }
  63457. /**
  63458. * Class representing a vector containing 2 coordinates
  63459. */
  63460. export class Vector2 {
  63461. /** defines the first coordinate */
  63462. x: number;
  63463. /** defines the second coordinate */
  63464. y: number;
  63465. /**
  63466. * Creates a new Vector2 from the given x and y coordinates
  63467. * @param x defines the first coordinate
  63468. * @param y defines the second coordinate
  63469. */
  63470. constructor(
  63471. /** defines the first coordinate */
  63472. x?: number,
  63473. /** defines the second coordinate */
  63474. y?: number);
  63475. /**
  63476. * Gets a string with the Vector2 coordinates
  63477. * @returns a string with the Vector2 coordinates
  63478. */
  63479. toString(): string;
  63480. /**
  63481. * Gets class name
  63482. * @returns the string "Vector2"
  63483. */
  63484. getClassName(): string;
  63485. /**
  63486. * Gets current vector hash code
  63487. * @returns the Vector2 hash code as a number
  63488. */
  63489. getHashCode(): number;
  63490. /**
  63491. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63492. * @param array defines the source array
  63493. * @param index defines the offset in source array
  63494. * @returns the current Vector2
  63495. */
  63496. toArray(array: FloatArray, index?: number): Vector2;
  63497. /**
  63498. * Copy the current vector to an array
  63499. * @returns a new array with 2 elements: the Vector2 coordinates.
  63500. */
  63501. asArray(): number[];
  63502. /**
  63503. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63504. * @param source defines the source Vector2
  63505. * @returns the current updated Vector2
  63506. */
  63507. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63508. /**
  63509. * Sets the Vector2 coordinates with the given floats
  63510. * @param x defines the first coordinate
  63511. * @param y defines the second coordinate
  63512. * @returns the current updated Vector2
  63513. */
  63514. copyFromFloats(x: number, y: number): Vector2;
  63515. /**
  63516. * Sets the Vector2 coordinates with the given floats
  63517. * @param x defines the first coordinate
  63518. * @param y defines the second coordinate
  63519. * @returns the current updated Vector2
  63520. */
  63521. set(x: number, y: number): Vector2;
  63522. /**
  63523. * Add another vector with the current one
  63524. * @param otherVector defines the other vector
  63525. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63526. */
  63527. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63528. /**
  63529. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63530. * @param otherVector defines the other vector
  63531. * @param result defines the target vector
  63532. * @returns the unmodified current Vector2
  63533. */
  63534. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63535. /**
  63536. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63537. * @param otherVector defines the other vector
  63538. * @returns the current updated Vector2
  63539. */
  63540. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63541. /**
  63542. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63543. * @param otherVector defines the other vector
  63544. * @returns a new Vector2
  63545. */
  63546. addVector3(otherVector: Vector3): Vector2;
  63547. /**
  63548. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63549. * @param otherVector defines the other vector
  63550. * @returns a new Vector2
  63551. */
  63552. subtract(otherVector: Vector2): Vector2;
  63553. /**
  63554. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63555. * @param otherVector defines the other vector
  63556. * @param result defines the target vector
  63557. * @returns the unmodified current Vector2
  63558. */
  63559. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63560. /**
  63561. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63562. * @param otherVector defines the other vector
  63563. * @returns the current updated Vector2
  63564. */
  63565. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63566. /**
  63567. * Multiplies in place the current Vector2 coordinates by the given ones
  63568. * @param otherVector defines the other vector
  63569. * @returns the current updated Vector2
  63570. */
  63571. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63572. /**
  63573. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63574. * @param otherVector defines the other vector
  63575. * @returns a new Vector2
  63576. */
  63577. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63578. /**
  63579. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63580. * @param otherVector defines the other vector
  63581. * @param result defines the target vector
  63582. * @returns the unmodified current Vector2
  63583. */
  63584. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63585. /**
  63586. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63587. * @param x defines the first coordinate
  63588. * @param y defines the second coordinate
  63589. * @returns a new Vector2
  63590. */
  63591. multiplyByFloats(x: number, y: number): Vector2;
  63592. /**
  63593. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63594. * @param otherVector defines the other vector
  63595. * @returns a new Vector2
  63596. */
  63597. divide(otherVector: Vector2): Vector2;
  63598. /**
  63599. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63600. * @param otherVector defines the other vector
  63601. * @param result defines the target vector
  63602. * @returns the unmodified current Vector2
  63603. */
  63604. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63605. /**
  63606. * Divides the current Vector2 coordinates by the given ones
  63607. * @param otherVector defines the other vector
  63608. * @returns the current updated Vector2
  63609. */
  63610. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63611. /**
  63612. * Gets a new Vector2 with current Vector2 negated coordinates
  63613. * @returns a new Vector2
  63614. */
  63615. negate(): Vector2;
  63616. /**
  63617. * Multiply the Vector2 coordinates by scale
  63618. * @param scale defines the scaling factor
  63619. * @returns the current updated Vector2
  63620. */
  63621. scaleInPlace(scale: number): Vector2;
  63622. /**
  63623. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63624. * @param scale defines the scaling factor
  63625. * @returns a new Vector2
  63626. */
  63627. scale(scale: number): Vector2;
  63628. /**
  63629. * Scale the current Vector2 values by a factor to a given Vector2
  63630. * @param scale defines the scale factor
  63631. * @param result defines the Vector2 object where to store the result
  63632. * @returns the unmodified current Vector2
  63633. */
  63634. scaleToRef(scale: number, result: Vector2): Vector2;
  63635. /**
  63636. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63637. * @param scale defines the scale factor
  63638. * @param result defines the Vector2 object where to store the result
  63639. * @returns the unmodified current Vector2
  63640. */
  63641. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63642. /**
  63643. * Gets a boolean if two vectors are equals
  63644. * @param otherVector defines the other vector
  63645. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63646. */
  63647. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63648. /**
  63649. * Gets a boolean if two vectors are equals (using an epsilon value)
  63650. * @param otherVector defines the other vector
  63651. * @param epsilon defines the minimal distance to consider equality
  63652. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63653. */
  63654. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63655. /**
  63656. * Gets a new Vector2 from current Vector2 floored values
  63657. * @returns a new Vector2
  63658. */
  63659. floor(): Vector2;
  63660. /**
  63661. * Gets a new Vector2 from current Vector2 floored values
  63662. * @returns a new Vector2
  63663. */
  63664. fract(): Vector2;
  63665. /**
  63666. * Gets the length of the vector
  63667. * @returns the vector length (float)
  63668. */
  63669. length(): number;
  63670. /**
  63671. * Gets the vector squared length
  63672. * @returns the vector squared length (float)
  63673. */
  63674. lengthSquared(): number;
  63675. /**
  63676. * Normalize the vector
  63677. * @returns the current updated Vector2
  63678. */
  63679. normalize(): Vector2;
  63680. /**
  63681. * Gets a new Vector2 copied from the Vector2
  63682. * @returns a new Vector2
  63683. */
  63684. clone(): Vector2;
  63685. /**
  63686. * Gets a new Vector2(0, 0)
  63687. * @returns a new Vector2
  63688. */
  63689. static Zero(): Vector2;
  63690. /**
  63691. * Gets a new Vector2(1, 1)
  63692. * @returns a new Vector2
  63693. */
  63694. static One(): Vector2;
  63695. /**
  63696. * Gets a new Vector2 set from the given index element of the given array
  63697. * @param array defines the data source
  63698. * @param offset defines the offset in the data source
  63699. * @returns a new Vector2
  63700. */
  63701. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63702. /**
  63703. * Sets "result" from the given index element of the given array
  63704. * @param array defines the data source
  63705. * @param offset defines the offset in the data source
  63706. * @param result defines the target vector
  63707. */
  63708. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63709. /**
  63710. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63711. * @param value1 defines 1st point of control
  63712. * @param value2 defines 2nd point of control
  63713. * @param value3 defines 3rd point of control
  63714. * @param value4 defines 4th point of control
  63715. * @param amount defines the interpolation factor
  63716. * @returns a new Vector2
  63717. */
  63718. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63719. /**
  63720. * 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".
  63721. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63722. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63723. * @param value defines the value to clamp
  63724. * @param min defines the lower limit
  63725. * @param max defines the upper limit
  63726. * @returns a new Vector2
  63727. */
  63728. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63729. /**
  63730. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63731. * @param value1 defines the 1st control point
  63732. * @param tangent1 defines the outgoing tangent
  63733. * @param value2 defines the 2nd control point
  63734. * @param tangent2 defines the incoming tangent
  63735. * @param amount defines the interpolation factor
  63736. * @returns a new Vector2
  63737. */
  63738. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63739. /**
  63740. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63741. * @param start defines the start vector
  63742. * @param end defines the end vector
  63743. * @param amount defines the interpolation factor
  63744. * @returns a new Vector2
  63745. */
  63746. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63747. /**
  63748. * Gets the dot product of the vector "left" and the vector "right"
  63749. * @param left defines first vector
  63750. * @param right defines second vector
  63751. * @returns the dot product (float)
  63752. */
  63753. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63754. /**
  63755. * Returns a new Vector2 equal to the normalized given vector
  63756. * @param vector defines the vector to normalize
  63757. * @returns a new Vector2
  63758. */
  63759. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63760. /**
  63761. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63762. * @param left defines 1st vector
  63763. * @param right defines 2nd vector
  63764. * @returns a new Vector2
  63765. */
  63766. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63767. /**
  63768. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63769. * @param left defines 1st vector
  63770. * @param right defines 2nd vector
  63771. * @returns a new Vector2
  63772. */
  63773. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63774. /**
  63775. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63776. * @param vector defines the vector to transform
  63777. * @param transformation defines the matrix to apply
  63778. * @returns a new Vector2
  63779. */
  63780. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63781. /**
  63782. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63783. * @param vector defines the vector to transform
  63784. * @param transformation defines the matrix to apply
  63785. * @param result defines the target vector
  63786. */
  63787. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63788. /**
  63789. * Determines if a given vector is included in a triangle
  63790. * @param p defines the vector to test
  63791. * @param p0 defines 1st triangle point
  63792. * @param p1 defines 2nd triangle point
  63793. * @param p2 defines 3rd triangle point
  63794. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63795. */
  63796. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63797. /**
  63798. * Gets the distance between the vectors "value1" and "value2"
  63799. * @param value1 defines first vector
  63800. * @param value2 defines second vector
  63801. * @returns the distance between vectors
  63802. */
  63803. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63804. /**
  63805. * Returns the squared distance between the vectors "value1" and "value2"
  63806. * @param value1 defines first vector
  63807. * @param value2 defines second vector
  63808. * @returns the squared distance between vectors
  63809. */
  63810. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63811. /**
  63812. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63813. * @param value1 defines first vector
  63814. * @param value2 defines second vector
  63815. * @returns a new Vector2
  63816. */
  63817. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63818. /**
  63819. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63820. * @param p defines the middle point
  63821. * @param segA defines one point of the segment
  63822. * @param segB defines the other point of the segment
  63823. * @returns the shortest distance
  63824. */
  63825. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63826. }
  63827. /**
  63828. * Classed used to store (x,y,z) vector representation
  63829. * A Vector3 is the main object used in 3D geometry
  63830. * It can represent etiher the coordinates of a point the space, either a direction
  63831. * Reminder: js uses a left handed forward facing system
  63832. */
  63833. export class Vector3 {
  63834. /**
  63835. * Defines the first coordinates (on X axis)
  63836. */
  63837. x: number;
  63838. /**
  63839. * Defines the second coordinates (on Y axis)
  63840. */
  63841. y: number;
  63842. /**
  63843. * Defines the third coordinates (on Z axis)
  63844. */
  63845. z: number;
  63846. private static _UpReadOnly;
  63847. private static _ZeroReadOnly;
  63848. /**
  63849. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63850. * @param x defines the first coordinates (on X axis)
  63851. * @param y defines the second coordinates (on Y axis)
  63852. * @param z defines the third coordinates (on Z axis)
  63853. */
  63854. constructor(
  63855. /**
  63856. * Defines the first coordinates (on X axis)
  63857. */
  63858. x?: number,
  63859. /**
  63860. * Defines the second coordinates (on Y axis)
  63861. */
  63862. y?: number,
  63863. /**
  63864. * Defines the third coordinates (on Z axis)
  63865. */
  63866. z?: number);
  63867. /**
  63868. * Creates a string representation of the Vector3
  63869. * @returns a string with the Vector3 coordinates.
  63870. */
  63871. toString(): string;
  63872. /**
  63873. * Gets the class name
  63874. * @returns the string "Vector3"
  63875. */
  63876. getClassName(): string;
  63877. /**
  63878. * Creates the Vector3 hash code
  63879. * @returns a number which tends to be unique between Vector3 instances
  63880. */
  63881. getHashCode(): number;
  63882. /**
  63883. * Creates an array containing three elements : the coordinates of the Vector3
  63884. * @returns a new array of numbers
  63885. */
  63886. asArray(): number[];
  63887. /**
  63888. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63889. * @param array defines the destination array
  63890. * @param index defines the offset in the destination array
  63891. * @returns the current Vector3
  63892. */
  63893. toArray(array: FloatArray, index?: number): Vector3;
  63894. /**
  63895. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63896. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63897. */
  63898. toQuaternion(): Quaternion;
  63899. /**
  63900. * Adds the given vector to the current Vector3
  63901. * @param otherVector defines the second operand
  63902. * @returns the current updated Vector3
  63903. */
  63904. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63905. /**
  63906. * Adds the given coordinates to the current Vector3
  63907. * @param x defines the x coordinate of the operand
  63908. * @param y defines the y coordinate of the operand
  63909. * @param z defines the z coordinate of the operand
  63910. * @returns the current updated Vector3
  63911. */
  63912. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63913. /**
  63914. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63915. * @param otherVector defines the second operand
  63916. * @returns the resulting Vector3
  63917. */
  63918. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63919. /**
  63920. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63921. * @param otherVector defines the second operand
  63922. * @param result defines the Vector3 object where to store the result
  63923. * @returns the current Vector3
  63924. */
  63925. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63926. /**
  63927. * Subtract the given vector from the current Vector3
  63928. * @param otherVector defines the second operand
  63929. * @returns the current updated Vector3
  63930. */
  63931. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63932. /**
  63933. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63934. * @param otherVector defines the second operand
  63935. * @returns the resulting Vector3
  63936. */
  63937. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63938. /**
  63939. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63940. * @param otherVector defines the second operand
  63941. * @param result defines the Vector3 object where to store the result
  63942. * @returns the current Vector3
  63943. */
  63944. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63945. /**
  63946. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63947. * @param x defines the x coordinate of the operand
  63948. * @param y defines the y coordinate of the operand
  63949. * @param z defines the z coordinate of the operand
  63950. * @returns the resulting Vector3
  63951. */
  63952. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63953. /**
  63954. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63955. * @param x defines the x coordinate of the operand
  63956. * @param y defines the y coordinate of the operand
  63957. * @param z defines the z coordinate of the operand
  63958. * @param result defines the Vector3 object where to store the result
  63959. * @returns the current Vector3
  63960. */
  63961. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63962. /**
  63963. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63964. * @returns a new Vector3
  63965. */
  63966. negate(): Vector3;
  63967. /**
  63968. * Multiplies the Vector3 coordinates by the float "scale"
  63969. * @param scale defines the multiplier factor
  63970. * @returns the current updated Vector3
  63971. */
  63972. scaleInPlace(scale: number): Vector3;
  63973. /**
  63974. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63975. * @param scale defines the multiplier factor
  63976. * @returns a new Vector3
  63977. */
  63978. scale(scale: number): Vector3;
  63979. /**
  63980. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63981. * @param scale defines the multiplier factor
  63982. * @param result defines the Vector3 object where to store the result
  63983. * @returns the current Vector3
  63984. */
  63985. scaleToRef(scale: number, result: Vector3): Vector3;
  63986. /**
  63987. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63988. * @param scale defines the scale factor
  63989. * @param result defines the Vector3 object where to store the result
  63990. * @returns the unmodified current Vector3
  63991. */
  63992. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63993. /**
  63994. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63995. * @param otherVector defines the second operand
  63996. * @returns true if both vectors are equals
  63997. */
  63998. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63999. /**
  64000. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  64001. * @param otherVector defines the second operand
  64002. * @param epsilon defines the minimal distance to define values as equals
  64003. * @returns true if both vectors are distant less than epsilon
  64004. */
  64005. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  64006. /**
  64007. * Returns true if the current Vector3 coordinates equals the given floats
  64008. * @param x defines the x coordinate of the operand
  64009. * @param y defines the y coordinate of the operand
  64010. * @param z defines the z coordinate of the operand
  64011. * @returns true if both vectors are equals
  64012. */
  64013. equalsToFloats(x: number, y: number, z: number): boolean;
  64014. /**
  64015. * Multiplies the current Vector3 coordinates by the given ones
  64016. * @param otherVector defines the second operand
  64017. * @returns the current updated Vector3
  64018. */
  64019. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  64020. /**
  64021. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  64022. * @param otherVector defines the second operand
  64023. * @returns the new Vector3
  64024. */
  64025. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64026. /**
  64027. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64028. * @param otherVector defines the second operand
  64029. * @param result defines the Vector3 object where to store the result
  64030. * @returns the current Vector3
  64031. */
  64032. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64033. /**
  64034. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64035. * @param x defines the x coordinate of the operand
  64036. * @param y defines the y coordinate of the operand
  64037. * @param z defines the z coordinate of the operand
  64038. * @returns the new Vector3
  64039. */
  64040. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64041. /**
  64042. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64043. * @param otherVector defines the second operand
  64044. * @returns the new Vector3
  64045. */
  64046. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64047. /**
  64048. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64049. * @param otherVector defines the second operand
  64050. * @param result defines the Vector3 object where to store the result
  64051. * @returns the current Vector3
  64052. */
  64053. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64054. /**
  64055. * Divides the current Vector3 coordinates by the given ones.
  64056. * @param otherVector defines the second operand
  64057. * @returns the current updated Vector3
  64058. */
  64059. divideInPlace(otherVector: Vector3): Vector3;
  64060. /**
  64061. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64062. * @param other defines the second operand
  64063. * @returns the current updated Vector3
  64064. */
  64065. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64066. /**
  64067. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64068. * @param other defines the second operand
  64069. * @returns the current updated Vector3
  64070. */
  64071. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64072. /**
  64073. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64074. * @param x defines the x coordinate of the operand
  64075. * @param y defines the y coordinate of the operand
  64076. * @param z defines the z coordinate of the operand
  64077. * @returns the current updated Vector3
  64078. */
  64079. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64080. /**
  64081. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64082. * @param x defines the x coordinate of the operand
  64083. * @param y defines the y coordinate of the operand
  64084. * @param z defines the z coordinate of the operand
  64085. * @returns the current updated Vector3
  64086. */
  64087. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64088. /**
  64089. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64090. * Check if is non uniform within a certain amount of decimal places to account for this
  64091. * @param epsilon the amount the values can differ
  64092. * @returns if the the vector is non uniform to a certain number of decimal places
  64093. */
  64094. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64095. /**
  64096. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64097. */
  64098. readonly isNonUniform: boolean;
  64099. /**
  64100. * Gets a new Vector3 from current Vector3 floored values
  64101. * @returns a new Vector3
  64102. */
  64103. floor(): Vector3;
  64104. /**
  64105. * Gets a new Vector3 from current Vector3 floored values
  64106. * @returns a new Vector3
  64107. */
  64108. fract(): Vector3;
  64109. /**
  64110. * Gets the length of the Vector3
  64111. * @returns the length of the Vector3
  64112. */
  64113. length(): number;
  64114. /**
  64115. * Gets the squared length of the Vector3
  64116. * @returns squared length of the Vector3
  64117. */
  64118. lengthSquared(): number;
  64119. /**
  64120. * Normalize the current Vector3.
  64121. * Please note that this is an in place operation.
  64122. * @returns the current updated Vector3
  64123. */
  64124. normalize(): Vector3;
  64125. /**
  64126. * Reorders the x y z properties of the vector in place
  64127. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64128. * @returns the current updated vector
  64129. */
  64130. reorderInPlace(order: string): this;
  64131. /**
  64132. * Rotates the vector around 0,0,0 by a quaternion
  64133. * @param quaternion the rotation quaternion
  64134. * @param result vector to store the result
  64135. * @returns the resulting vector
  64136. */
  64137. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64138. /**
  64139. * Rotates a vector around a given point
  64140. * @param quaternion the rotation quaternion
  64141. * @param point the point to rotate around
  64142. * @param result vector to store the result
  64143. * @returns the resulting vector
  64144. */
  64145. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64146. /**
  64147. * Normalize the current Vector3 with the given input length.
  64148. * Please note that this is an in place operation.
  64149. * @param len the length of the vector
  64150. * @returns the current updated Vector3
  64151. */
  64152. normalizeFromLength(len: number): Vector3;
  64153. /**
  64154. * Normalize the current Vector3 to a new vector
  64155. * @returns the new Vector3
  64156. */
  64157. normalizeToNew(): Vector3;
  64158. /**
  64159. * Normalize the current Vector3 to the reference
  64160. * @param reference define the Vector3 to update
  64161. * @returns the updated Vector3
  64162. */
  64163. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64164. /**
  64165. * Creates a new Vector3 copied from the current Vector3
  64166. * @returns the new Vector3
  64167. */
  64168. clone(): Vector3;
  64169. /**
  64170. * Copies the given vector coordinates to the current Vector3 ones
  64171. * @param source defines the source Vector3
  64172. * @returns the current updated Vector3
  64173. */
  64174. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64175. /**
  64176. * Copies the given floats to the current Vector3 coordinates
  64177. * @param x defines the x coordinate of the operand
  64178. * @param y defines the y coordinate of the operand
  64179. * @param z defines the z coordinate of the operand
  64180. * @returns the current updated Vector3
  64181. */
  64182. copyFromFloats(x: number, y: number, z: number): Vector3;
  64183. /**
  64184. * Copies the given floats to the current Vector3 coordinates
  64185. * @param x defines the x coordinate of the operand
  64186. * @param y defines the y coordinate of the operand
  64187. * @param z defines the z coordinate of the operand
  64188. * @returns the current updated Vector3
  64189. */
  64190. set(x: number, y: number, z: number): Vector3;
  64191. /**
  64192. * Copies the given float to the current Vector3 coordinates
  64193. * @param v defines the x, y and z coordinates of the operand
  64194. * @returns the current updated Vector3
  64195. */
  64196. setAll(v: number): Vector3;
  64197. /**
  64198. * Get the clip factor between two vectors
  64199. * @param vector0 defines the first operand
  64200. * @param vector1 defines the second operand
  64201. * @param axis defines the axis to use
  64202. * @param size defines the size along the axis
  64203. * @returns the clip factor
  64204. */
  64205. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64206. /**
  64207. * Get angle between two vectors
  64208. * @param vector0 angle between vector0 and vector1
  64209. * @param vector1 angle between vector0 and vector1
  64210. * @param normal direction of the normal
  64211. * @return the angle between vector0 and vector1
  64212. */
  64213. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64214. /**
  64215. * Returns a new Vector3 set from the index "offset" of the given array
  64216. * @param array defines the source array
  64217. * @param offset defines the offset in the source array
  64218. * @returns the new Vector3
  64219. */
  64220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64221. /**
  64222. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64223. * This function is deprecated. Use FromArray instead
  64224. * @param array defines the source array
  64225. * @param offset defines the offset in the source array
  64226. * @returns the new Vector3
  64227. */
  64228. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64229. /**
  64230. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64231. * @param array defines the source array
  64232. * @param offset defines the offset in the source array
  64233. * @param result defines the Vector3 where to store the result
  64234. */
  64235. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64236. /**
  64237. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64238. * This function is deprecated. Use FromArrayToRef instead.
  64239. * @param array defines the source array
  64240. * @param offset defines the offset in the source array
  64241. * @param result defines the Vector3 where to store the result
  64242. */
  64243. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64244. /**
  64245. * Sets the given vector "result" with the given floats.
  64246. * @param x defines the x coordinate of the source
  64247. * @param y defines the y coordinate of the source
  64248. * @param z defines the z coordinate of the source
  64249. * @param result defines the Vector3 where to store the result
  64250. */
  64251. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64252. /**
  64253. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64254. * @returns a new empty Vector3
  64255. */
  64256. static Zero(): Vector3;
  64257. /**
  64258. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64259. * @returns a new unit Vector3
  64260. */
  64261. static One(): Vector3;
  64262. /**
  64263. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64264. * @returns a new up Vector3
  64265. */
  64266. static Up(): Vector3;
  64267. /**
  64268. * Gets a up Vector3 that must not be updated
  64269. */
  64270. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64271. /**
  64272. * Gets a zero Vector3 that must not be updated
  64273. */
  64274. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64275. /**
  64276. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64277. * @returns a new down Vector3
  64278. */
  64279. static Down(): Vector3;
  64280. /**
  64281. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64282. * @returns a new forward Vector3
  64283. */
  64284. static Forward(): Vector3;
  64285. /**
  64286. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64287. * @returns a new forward Vector3
  64288. */
  64289. static Backward(): Vector3;
  64290. /**
  64291. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64292. * @returns a new right Vector3
  64293. */
  64294. static Right(): Vector3;
  64295. /**
  64296. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64297. * @returns a new left Vector3
  64298. */
  64299. static Left(): Vector3;
  64300. /**
  64301. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64302. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64303. * @param vector defines the Vector3 to transform
  64304. * @param transformation defines the transformation matrix
  64305. * @returns the transformed Vector3
  64306. */
  64307. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64308. /**
  64309. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64310. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64311. * @param vector defines the Vector3 to transform
  64312. * @param transformation defines the transformation matrix
  64313. * @param result defines the Vector3 where to store the result
  64314. */
  64315. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64316. /**
  64317. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64318. * This method computes tranformed coordinates only, not transformed direction vectors
  64319. * @param x define the x coordinate of the source vector
  64320. * @param y define the y coordinate of the source vector
  64321. * @param z define the z coordinate of the source vector
  64322. * @param transformation defines the transformation matrix
  64323. * @param result defines the Vector3 where to store the result
  64324. */
  64325. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64326. /**
  64327. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64328. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64329. * @param vector defines the Vector3 to transform
  64330. * @param transformation defines the transformation matrix
  64331. * @returns the new Vector3
  64332. */
  64333. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64334. /**
  64335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64336. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64337. * @param vector defines the Vector3 to transform
  64338. * @param transformation defines the transformation matrix
  64339. * @param result defines the Vector3 where to store the result
  64340. */
  64341. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64342. /**
  64343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64344. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64345. * @param x define the x coordinate of the source vector
  64346. * @param y define the y coordinate of the source vector
  64347. * @param z define the z coordinate of the source vector
  64348. * @param transformation defines the transformation matrix
  64349. * @param result defines the Vector3 where to store the result
  64350. */
  64351. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64352. /**
  64353. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64354. * @param value1 defines the first control point
  64355. * @param value2 defines the second control point
  64356. * @param value3 defines the third control point
  64357. * @param value4 defines the fourth control point
  64358. * @param amount defines the amount on the spline to use
  64359. * @returns the new Vector3
  64360. */
  64361. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64362. /**
  64363. * 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"
  64364. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64365. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64366. * @param value defines the current value
  64367. * @param min defines the lower range value
  64368. * @param max defines the upper range value
  64369. * @returns the new Vector3
  64370. */
  64371. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64372. /**
  64373. * 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"
  64374. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64375. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64376. * @param value defines the current value
  64377. * @param min defines the lower range value
  64378. * @param max defines the upper range value
  64379. * @param result defines the Vector3 where to store the result
  64380. */
  64381. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64382. /**
  64383. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64384. * @param value1 defines the first control point
  64385. * @param tangent1 defines the first tangent vector
  64386. * @param value2 defines the second control point
  64387. * @param tangent2 defines the second tangent vector
  64388. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64389. * @returns the new Vector3
  64390. */
  64391. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64392. /**
  64393. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64394. * @param start defines the start value
  64395. * @param end defines the end value
  64396. * @param amount max defines amount between both (between 0 and 1)
  64397. * @returns the new Vector3
  64398. */
  64399. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64400. /**
  64401. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64402. * @param start defines the start value
  64403. * @param end defines the end value
  64404. * @param amount max defines amount between both (between 0 and 1)
  64405. * @param result defines the Vector3 where to store the result
  64406. */
  64407. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64408. /**
  64409. * Returns the dot product (float) between the vectors "left" and "right"
  64410. * @param left defines the left operand
  64411. * @param right defines the right operand
  64412. * @returns the dot product
  64413. */
  64414. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64415. /**
  64416. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64417. * The cross product is then orthogonal to both "left" and "right"
  64418. * @param left defines the left operand
  64419. * @param right defines the right operand
  64420. * @returns the cross product
  64421. */
  64422. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64423. /**
  64424. * Sets the given vector "result" with the cross product of "left" and "right"
  64425. * The cross product is then orthogonal to both "left" and "right"
  64426. * @param left defines the left operand
  64427. * @param right defines the right operand
  64428. * @param result defines the Vector3 where to store the result
  64429. */
  64430. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64431. /**
  64432. * Returns a new Vector3 as the normalization of the given vector
  64433. * @param vector defines the Vector3 to normalize
  64434. * @returns the new Vector3
  64435. */
  64436. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64437. /**
  64438. * Sets the given vector "result" with the normalization of the given first vector
  64439. * @param vector defines the Vector3 to normalize
  64440. * @param result defines the Vector3 where to store the result
  64441. */
  64442. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64443. /**
  64444. * Project a Vector3 onto screen space
  64445. * @param vector defines the Vector3 to project
  64446. * @param world defines the world matrix to use
  64447. * @param transform defines the transform (view x projection) matrix to use
  64448. * @param viewport defines the screen viewport to use
  64449. * @returns the new Vector3
  64450. */
  64451. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64452. /** @hidden */
  64453. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64454. /**
  64455. * Unproject from screen space to object space
  64456. * @param source defines the screen space Vector3 to use
  64457. * @param viewportWidth defines the current width of the viewport
  64458. * @param viewportHeight defines the current height of the viewport
  64459. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64460. * @param transform defines the transform (view x projection) matrix to use
  64461. * @returns the new Vector3
  64462. */
  64463. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64464. /**
  64465. * Unproject from screen space to object space
  64466. * @param source defines the screen space Vector3 to use
  64467. * @param viewportWidth defines the current width of the viewport
  64468. * @param viewportHeight defines the current height of the viewport
  64469. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64470. * @param view defines the view matrix to use
  64471. * @param projection defines the projection matrix to use
  64472. * @returns the new Vector3
  64473. */
  64474. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64475. /**
  64476. * Unproject from screen space to object space
  64477. * @param source defines the screen space Vector3 to use
  64478. * @param viewportWidth defines the current width of the viewport
  64479. * @param viewportHeight defines the current height of the viewport
  64480. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64481. * @param view defines the view matrix to use
  64482. * @param projection defines the projection matrix to use
  64483. * @param result defines the Vector3 where to store the result
  64484. */
  64485. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64486. /**
  64487. * Unproject from screen space to object space
  64488. * @param sourceX defines the screen space x coordinate to use
  64489. * @param sourceY defines the screen space y coordinate to use
  64490. * @param sourceZ defines the screen space z coordinate to use
  64491. * @param viewportWidth defines the current width of the viewport
  64492. * @param viewportHeight defines the current height of the viewport
  64493. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64494. * @param view defines the view matrix to use
  64495. * @param projection defines the projection matrix to use
  64496. * @param result defines the Vector3 where to store the result
  64497. */
  64498. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64499. /**
  64500. * Gets the minimal coordinate values between two Vector3
  64501. * @param left defines the first operand
  64502. * @param right defines the second operand
  64503. * @returns the new Vector3
  64504. */
  64505. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64506. /**
  64507. * Gets the maximal coordinate values between two Vector3
  64508. * @param left defines the first operand
  64509. * @param right defines the second operand
  64510. * @returns the new Vector3
  64511. */
  64512. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64513. /**
  64514. * Returns the distance between the vectors "value1" and "value2"
  64515. * @param value1 defines the first operand
  64516. * @param value2 defines the second operand
  64517. * @returns the distance
  64518. */
  64519. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64520. /**
  64521. * Returns the squared distance between the vectors "value1" and "value2"
  64522. * @param value1 defines the first operand
  64523. * @param value2 defines the second operand
  64524. * @returns the squared distance
  64525. */
  64526. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64527. /**
  64528. * Returns a new Vector3 located at the center between "value1" and "value2"
  64529. * @param value1 defines the first operand
  64530. * @param value2 defines the second operand
  64531. * @returns the new Vector3
  64532. */
  64533. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64534. /**
  64535. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64536. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64537. * to something in order to rotate it from its local system to the given target system
  64538. * Note: axis1, axis2 and axis3 are normalized during this operation
  64539. * @param axis1 defines the first axis
  64540. * @param axis2 defines the second axis
  64541. * @param axis3 defines the third axis
  64542. * @returns a new Vector3
  64543. */
  64544. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64545. /**
  64546. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64547. * @param axis1 defines the first axis
  64548. * @param axis2 defines the second axis
  64549. * @param axis3 defines the third axis
  64550. * @param ref defines the Vector3 where to store the result
  64551. */
  64552. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64553. }
  64554. /**
  64555. * Vector4 class created for EulerAngle class conversion to Quaternion
  64556. */
  64557. export class Vector4 {
  64558. /** x value of the vector */
  64559. x: number;
  64560. /** y value of the vector */
  64561. y: number;
  64562. /** z value of the vector */
  64563. z: number;
  64564. /** w value of the vector */
  64565. w: number;
  64566. /**
  64567. * Creates a Vector4 object from the given floats.
  64568. * @param x x value of the vector
  64569. * @param y y value of the vector
  64570. * @param z z value of the vector
  64571. * @param w w value of the vector
  64572. */
  64573. constructor(
  64574. /** x value of the vector */
  64575. x: number,
  64576. /** y value of the vector */
  64577. y: number,
  64578. /** z value of the vector */
  64579. z: number,
  64580. /** w value of the vector */
  64581. w: number);
  64582. /**
  64583. * Returns the string with the Vector4 coordinates.
  64584. * @returns a string containing all the vector values
  64585. */
  64586. toString(): string;
  64587. /**
  64588. * Returns the string "Vector4".
  64589. * @returns "Vector4"
  64590. */
  64591. getClassName(): string;
  64592. /**
  64593. * Returns the Vector4 hash code.
  64594. * @returns a unique hash code
  64595. */
  64596. getHashCode(): number;
  64597. /**
  64598. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64599. * @returns the resulting array
  64600. */
  64601. asArray(): number[];
  64602. /**
  64603. * Populates the given array from the given index with the Vector4 coordinates.
  64604. * @param array array to populate
  64605. * @param index index of the array to start at (default: 0)
  64606. * @returns the Vector4.
  64607. */
  64608. toArray(array: FloatArray, index?: number): Vector4;
  64609. /**
  64610. * Adds the given vector to the current Vector4.
  64611. * @param otherVector the vector to add
  64612. * @returns the updated Vector4.
  64613. */
  64614. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64615. /**
  64616. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64617. * @param otherVector the vector to add
  64618. * @returns the resulting vector
  64619. */
  64620. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64621. /**
  64622. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64623. * @param otherVector the vector to add
  64624. * @param result the vector to store the result
  64625. * @returns the current Vector4.
  64626. */
  64627. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64628. /**
  64629. * Subtract in place the given vector from the current Vector4.
  64630. * @param otherVector the vector to subtract
  64631. * @returns the updated Vector4.
  64632. */
  64633. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64634. /**
  64635. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64636. * @param otherVector the vector to add
  64637. * @returns the new vector with the result
  64638. */
  64639. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64640. /**
  64641. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64642. * @param otherVector the vector to subtract
  64643. * @param result the vector to store the result
  64644. * @returns the current Vector4.
  64645. */
  64646. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64647. /**
  64648. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64649. */
  64650. /**
  64651. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64652. * @param x value to subtract
  64653. * @param y value to subtract
  64654. * @param z value to subtract
  64655. * @param w value to subtract
  64656. * @returns new vector containing the result
  64657. */
  64658. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64659. /**
  64660. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64661. * @param x value to subtract
  64662. * @param y value to subtract
  64663. * @param z value to subtract
  64664. * @param w value to subtract
  64665. * @param result the vector to store the result in
  64666. * @returns the current Vector4.
  64667. */
  64668. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64669. /**
  64670. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64671. * @returns a new vector with the negated values
  64672. */
  64673. negate(): Vector4;
  64674. /**
  64675. * Multiplies the current Vector4 coordinates by scale (float).
  64676. * @param scale the number to scale with
  64677. * @returns the updated Vector4.
  64678. */
  64679. scaleInPlace(scale: number): Vector4;
  64680. /**
  64681. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64682. * @param scale the number to scale with
  64683. * @returns a new vector with the result
  64684. */
  64685. scale(scale: number): Vector4;
  64686. /**
  64687. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64688. * @param scale the number to scale with
  64689. * @param result a vector to store the result in
  64690. * @returns the current Vector4.
  64691. */
  64692. scaleToRef(scale: number, result: Vector4): Vector4;
  64693. /**
  64694. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64695. * @param scale defines the scale factor
  64696. * @param result defines the Vector4 object where to store the result
  64697. * @returns the unmodified current Vector4
  64698. */
  64699. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64700. /**
  64701. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64702. * @param otherVector the vector to compare against
  64703. * @returns true if they are equal
  64704. */
  64705. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64706. /**
  64707. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64708. * @param otherVector vector to compare against
  64709. * @param epsilon (Default: very small number)
  64710. * @returns true if they are equal
  64711. */
  64712. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64713. /**
  64714. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64715. * @param x x value to compare against
  64716. * @param y y value to compare against
  64717. * @param z z value to compare against
  64718. * @param w w value to compare against
  64719. * @returns true if equal
  64720. */
  64721. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64722. /**
  64723. * Multiplies in place the current Vector4 by the given one.
  64724. * @param otherVector vector to multiple with
  64725. * @returns the updated Vector4.
  64726. */
  64727. multiplyInPlace(otherVector: Vector4): Vector4;
  64728. /**
  64729. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64730. * @param otherVector vector to multiple with
  64731. * @returns resulting new vector
  64732. */
  64733. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64734. /**
  64735. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64736. * @param otherVector vector to multiple with
  64737. * @param result vector to store the result
  64738. * @returns the current Vector4.
  64739. */
  64740. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64741. /**
  64742. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64743. * @param x x value multiply with
  64744. * @param y y value multiply with
  64745. * @param z z value multiply with
  64746. * @param w w value multiply with
  64747. * @returns resulting new vector
  64748. */
  64749. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64750. /**
  64751. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64752. * @param otherVector vector to devide with
  64753. * @returns resulting new vector
  64754. */
  64755. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64756. /**
  64757. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64758. * @param otherVector vector to devide with
  64759. * @param result vector to store the result
  64760. * @returns the current Vector4.
  64761. */
  64762. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64763. /**
  64764. * Divides the current Vector3 coordinates by the given ones.
  64765. * @param otherVector vector to devide with
  64766. * @returns the updated Vector3.
  64767. */
  64768. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64769. /**
  64770. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64771. * @param other defines the second operand
  64772. * @returns the current updated Vector4
  64773. */
  64774. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64775. /**
  64776. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64777. * @param other defines the second operand
  64778. * @returns the current updated Vector4
  64779. */
  64780. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64781. /**
  64782. * Gets a new Vector4 from current Vector4 floored values
  64783. * @returns a new Vector4
  64784. */
  64785. floor(): Vector4;
  64786. /**
  64787. * Gets a new Vector4 from current Vector3 floored values
  64788. * @returns a new Vector4
  64789. */
  64790. fract(): Vector4;
  64791. /**
  64792. * Returns the Vector4 length (float).
  64793. * @returns the length
  64794. */
  64795. length(): number;
  64796. /**
  64797. * Returns the Vector4 squared length (float).
  64798. * @returns the length squared
  64799. */
  64800. lengthSquared(): number;
  64801. /**
  64802. * Normalizes in place the Vector4.
  64803. * @returns the updated Vector4.
  64804. */
  64805. normalize(): Vector4;
  64806. /**
  64807. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64808. * @returns this converted to a new vector3
  64809. */
  64810. toVector3(): Vector3;
  64811. /**
  64812. * Returns a new Vector4 copied from the current one.
  64813. * @returns the new cloned vector
  64814. */
  64815. clone(): Vector4;
  64816. /**
  64817. * Updates the current Vector4 with the given one coordinates.
  64818. * @param source the source vector to copy from
  64819. * @returns the updated Vector4.
  64820. */
  64821. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64822. /**
  64823. * Updates the current Vector4 coordinates with the given floats.
  64824. * @param x float to copy from
  64825. * @param y float to copy from
  64826. * @param z float to copy from
  64827. * @param w float to copy from
  64828. * @returns the updated Vector4.
  64829. */
  64830. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64831. /**
  64832. * Updates the current Vector4 coordinates with the given floats.
  64833. * @param x float to set from
  64834. * @param y float to set from
  64835. * @param z float to set from
  64836. * @param w float to set from
  64837. * @returns the updated Vector4.
  64838. */
  64839. set(x: number, y: number, z: number, w: number): Vector4;
  64840. /**
  64841. * Copies the given float to the current Vector3 coordinates
  64842. * @param v defines the x, y, z and w coordinates of the operand
  64843. * @returns the current updated Vector3
  64844. */
  64845. setAll(v: number): Vector4;
  64846. /**
  64847. * Returns a new Vector4 set from the starting index of the given array.
  64848. * @param array the array to pull values from
  64849. * @param offset the offset into the array to start at
  64850. * @returns the new vector
  64851. */
  64852. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64853. /**
  64854. * Updates the given vector "result" from the starting index of the given array.
  64855. * @param array the array to pull values from
  64856. * @param offset the offset into the array to start at
  64857. * @param result the vector to store the result in
  64858. */
  64859. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64860. /**
  64861. * Updates the given vector "result" from the starting index of the given Float32Array.
  64862. * @param array the array to pull values from
  64863. * @param offset the offset into the array to start at
  64864. * @param result the vector to store the result in
  64865. */
  64866. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64867. /**
  64868. * Updates the given vector "result" coordinates from the given floats.
  64869. * @param x float to set from
  64870. * @param y float to set from
  64871. * @param z float to set from
  64872. * @param w float to set from
  64873. * @param result the vector to the floats in
  64874. */
  64875. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64876. /**
  64877. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64878. * @returns the new vector
  64879. */
  64880. static Zero(): Vector4;
  64881. /**
  64882. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64883. * @returns the new vector
  64884. */
  64885. static One(): Vector4;
  64886. /**
  64887. * Returns a new normalized Vector4 from the given one.
  64888. * @param vector the vector to normalize
  64889. * @returns the vector
  64890. */
  64891. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64892. /**
  64893. * Updates the given vector "result" from the normalization of the given one.
  64894. * @param vector the vector to normalize
  64895. * @param result the vector to store the result in
  64896. */
  64897. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64898. /**
  64899. * Returns a vector with the minimum values from the left and right vectors
  64900. * @param left left vector to minimize
  64901. * @param right right vector to minimize
  64902. * @returns a new vector with the minimum of the left and right vector values
  64903. */
  64904. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64905. /**
  64906. * Returns a vector with the maximum values from the left and right vectors
  64907. * @param left left vector to maximize
  64908. * @param right right vector to maximize
  64909. * @returns a new vector with the maximum of the left and right vector values
  64910. */
  64911. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64912. /**
  64913. * Returns the distance (float) between the vectors "value1" and "value2".
  64914. * @param value1 value to calulate the distance between
  64915. * @param value2 value to calulate the distance between
  64916. * @return the distance between the two vectors
  64917. */
  64918. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64919. /**
  64920. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64921. * @param value1 value to calulate the distance between
  64922. * @param value2 value to calulate the distance between
  64923. * @return the distance between the two vectors squared
  64924. */
  64925. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64926. /**
  64927. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64928. * @param value1 value to calulate the center between
  64929. * @param value2 value to calulate the center between
  64930. * @return the center between the two vectors
  64931. */
  64932. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64933. /**
  64934. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64935. * This methods computes transformed normalized direction vectors only.
  64936. * @param vector the vector to transform
  64937. * @param transformation the transformation matrix to apply
  64938. * @returns the new vector
  64939. */
  64940. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64941. /**
  64942. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64943. * This methods computes transformed normalized direction vectors only.
  64944. * @param vector the vector to transform
  64945. * @param transformation the transformation matrix to apply
  64946. * @param result the vector to store the result in
  64947. */
  64948. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64949. /**
  64950. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64951. * This methods computes transformed normalized direction vectors only.
  64952. * @param x value to transform
  64953. * @param y value to transform
  64954. * @param z value to transform
  64955. * @param w value to transform
  64956. * @param transformation the transformation matrix to apply
  64957. * @param result the vector to store the results in
  64958. */
  64959. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64960. /**
  64961. * Creates a new Vector4 from a Vector3
  64962. * @param source defines the source data
  64963. * @param w defines the 4th component (default is 0)
  64964. * @returns a new Vector4
  64965. */
  64966. static FromVector3(source: Vector3, w?: number): Vector4;
  64967. }
  64968. /**
  64969. * Interface for the size containing width and height
  64970. */
  64971. export interface ISize {
  64972. /**
  64973. * Width
  64974. */
  64975. width: number;
  64976. /**
  64977. * Heighht
  64978. */
  64979. height: number;
  64980. }
  64981. /**
  64982. * Size containing widht and height
  64983. */
  64984. export class Size implements ISize {
  64985. /**
  64986. * Width
  64987. */
  64988. width: number;
  64989. /**
  64990. * Height
  64991. */
  64992. height: number;
  64993. /**
  64994. * Creates a Size object from the given width and height (floats).
  64995. * @param width width of the new size
  64996. * @param height height of the new size
  64997. */
  64998. constructor(width: number, height: number);
  64999. /**
  65000. * Returns a string with the Size width and height
  65001. * @returns a string with the Size width and height
  65002. */
  65003. toString(): string;
  65004. /**
  65005. * "Size"
  65006. * @returns the string "Size"
  65007. */
  65008. getClassName(): string;
  65009. /**
  65010. * Returns the Size hash code.
  65011. * @returns a hash code for a unique width and height
  65012. */
  65013. getHashCode(): number;
  65014. /**
  65015. * Updates the current size from the given one.
  65016. * @param src the given size
  65017. */
  65018. copyFrom(src: Size): void;
  65019. /**
  65020. * Updates in place the current Size from the given floats.
  65021. * @param width width of the new size
  65022. * @param height height of the new size
  65023. * @returns the updated Size.
  65024. */
  65025. copyFromFloats(width: number, height: number): Size;
  65026. /**
  65027. * Updates in place the current Size from the given floats.
  65028. * @param width width to set
  65029. * @param height height to set
  65030. * @returns the updated Size.
  65031. */
  65032. set(width: number, height: number): Size;
  65033. /**
  65034. * Multiplies the width and height by numbers
  65035. * @param w factor to multiple the width by
  65036. * @param h factor to multiple the height by
  65037. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65038. */
  65039. multiplyByFloats(w: number, h: number): Size;
  65040. /**
  65041. * Clones the size
  65042. * @returns a new Size copied from the given one.
  65043. */
  65044. clone(): Size;
  65045. /**
  65046. * True if the current Size and the given one width and height are strictly equal.
  65047. * @param other the other size to compare against
  65048. * @returns True if the current Size and the given one width and height are strictly equal.
  65049. */
  65050. equals(other: Size): boolean;
  65051. /**
  65052. * The surface of the Size : width * height (float).
  65053. */
  65054. readonly surface: number;
  65055. /**
  65056. * Create a new size of zero
  65057. * @returns a new Size set to (0.0, 0.0)
  65058. */
  65059. static Zero(): Size;
  65060. /**
  65061. * Sums the width and height of two sizes
  65062. * @param otherSize size to add to this size
  65063. * @returns a new Size set as the addition result of the current Size and the given one.
  65064. */
  65065. add(otherSize: Size): Size;
  65066. /**
  65067. * Subtracts the width and height of two
  65068. * @param otherSize size to subtract to this size
  65069. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65070. */
  65071. subtract(otherSize: Size): Size;
  65072. /**
  65073. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65074. * @param start starting size to lerp between
  65075. * @param end end size to lerp between
  65076. * @param amount amount to lerp between the start and end values
  65077. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65078. */
  65079. static Lerp(start: Size, end: Size, amount: number): Size;
  65080. }
  65081. /**
  65082. * Class used to store quaternion data
  65083. * @see https://en.wikipedia.org/wiki/Quaternion
  65084. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65085. */
  65086. export class Quaternion {
  65087. /** defines the first component (0 by default) */
  65088. x: number;
  65089. /** defines the second component (0 by default) */
  65090. y: number;
  65091. /** defines the third component (0 by default) */
  65092. z: number;
  65093. /** defines the fourth component (1.0 by default) */
  65094. w: number;
  65095. /**
  65096. * Creates a new Quaternion from the given floats
  65097. * @param x defines the first component (0 by default)
  65098. * @param y defines the second component (0 by default)
  65099. * @param z defines the third component (0 by default)
  65100. * @param w defines the fourth component (1.0 by default)
  65101. */
  65102. constructor(
  65103. /** defines the first component (0 by default) */
  65104. x?: number,
  65105. /** defines the second component (0 by default) */
  65106. y?: number,
  65107. /** defines the third component (0 by default) */
  65108. z?: number,
  65109. /** defines the fourth component (1.0 by default) */
  65110. w?: number);
  65111. /**
  65112. * Gets a string representation for the current quaternion
  65113. * @returns a string with the Quaternion coordinates
  65114. */
  65115. toString(): string;
  65116. /**
  65117. * Gets the class name of the quaternion
  65118. * @returns the string "Quaternion"
  65119. */
  65120. getClassName(): string;
  65121. /**
  65122. * Gets a hash code for this quaternion
  65123. * @returns the quaternion hash code
  65124. */
  65125. getHashCode(): number;
  65126. /**
  65127. * Copy the quaternion to an array
  65128. * @returns a new array populated with 4 elements from the quaternion coordinates
  65129. */
  65130. asArray(): number[];
  65131. /**
  65132. * Check if two quaternions are equals
  65133. * @param otherQuaternion defines the second operand
  65134. * @return true if the current quaternion and the given one coordinates are strictly equals
  65135. */
  65136. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65137. /**
  65138. * Clone the current quaternion
  65139. * @returns a new quaternion copied from the current one
  65140. */
  65141. clone(): Quaternion;
  65142. /**
  65143. * Copy a quaternion to the current one
  65144. * @param other defines the other quaternion
  65145. * @returns the updated current quaternion
  65146. */
  65147. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65148. /**
  65149. * Updates the current quaternion with the given float coordinates
  65150. * @param x defines the x coordinate
  65151. * @param y defines the y coordinate
  65152. * @param z defines the z coordinate
  65153. * @param w defines the w coordinate
  65154. * @returns the updated current quaternion
  65155. */
  65156. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65157. /**
  65158. * Updates the current quaternion from the given float coordinates
  65159. * @param x defines the x coordinate
  65160. * @param y defines the y coordinate
  65161. * @param z defines the z coordinate
  65162. * @param w defines the w coordinate
  65163. * @returns the updated current quaternion
  65164. */
  65165. set(x: number, y: number, z: number, w: number): Quaternion;
  65166. /**
  65167. * Adds two quaternions
  65168. * @param other defines the second operand
  65169. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65170. */
  65171. add(other: DeepImmutable<Quaternion>): Quaternion;
  65172. /**
  65173. * Add a quaternion to the current one
  65174. * @param other defines the quaternion to add
  65175. * @returns the current quaternion
  65176. */
  65177. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65178. /**
  65179. * Subtract two quaternions
  65180. * @param other defines the second operand
  65181. * @returns a new quaternion as the subtraction result of the given one from the current one
  65182. */
  65183. subtract(other: Quaternion): Quaternion;
  65184. /**
  65185. * Multiplies the current quaternion by a scale factor
  65186. * @param value defines the scale factor
  65187. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65188. */
  65189. scale(value: number): Quaternion;
  65190. /**
  65191. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65192. * @param scale defines the scale factor
  65193. * @param result defines the Quaternion object where to store the result
  65194. * @returns the unmodified current quaternion
  65195. */
  65196. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65197. /**
  65198. * Multiplies in place the current quaternion by a scale factor
  65199. * @param value defines the scale factor
  65200. * @returns the current modified quaternion
  65201. */
  65202. scaleInPlace(value: number): Quaternion;
  65203. /**
  65204. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65205. * @param scale defines the scale factor
  65206. * @param result defines the Quaternion object where to store the result
  65207. * @returns the unmodified current quaternion
  65208. */
  65209. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65210. /**
  65211. * Multiplies two quaternions
  65212. * @param q1 defines the second operand
  65213. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65214. */
  65215. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65216. /**
  65217. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65218. * @param q1 defines the second operand
  65219. * @param result defines the target quaternion
  65220. * @returns the current quaternion
  65221. */
  65222. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65223. /**
  65224. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65225. * @param q1 defines the second operand
  65226. * @returns the currentupdated quaternion
  65227. */
  65228. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65229. /**
  65230. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65231. * @param ref defines the target quaternion
  65232. * @returns the current quaternion
  65233. */
  65234. conjugateToRef(ref: Quaternion): Quaternion;
  65235. /**
  65236. * Conjugates in place (1-q) the current quaternion
  65237. * @returns the current updated quaternion
  65238. */
  65239. conjugateInPlace(): Quaternion;
  65240. /**
  65241. * Conjugates in place (1-q) the current quaternion
  65242. * @returns a new quaternion
  65243. */
  65244. conjugate(): Quaternion;
  65245. /**
  65246. * Gets length of current quaternion
  65247. * @returns the quaternion length (float)
  65248. */
  65249. length(): number;
  65250. /**
  65251. * Normalize in place the current quaternion
  65252. * @returns the current updated quaternion
  65253. */
  65254. normalize(): Quaternion;
  65255. /**
  65256. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65257. * @param order is a reserved parameter and is ignore for now
  65258. * @returns a new Vector3 containing the Euler angles
  65259. */
  65260. toEulerAngles(order?: string): Vector3;
  65261. /**
  65262. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65263. * @param result defines the vector which will be filled with the Euler angles
  65264. * @param order is a reserved parameter and is ignore for now
  65265. * @returns the current unchanged quaternion
  65266. */
  65267. toEulerAnglesToRef(result: Vector3): Quaternion;
  65268. /**
  65269. * Updates the given rotation matrix with the current quaternion values
  65270. * @param result defines the target matrix
  65271. * @returns the current unchanged quaternion
  65272. */
  65273. toRotationMatrix(result: Matrix): Quaternion;
  65274. /**
  65275. * Updates the current quaternion from the given rotation matrix values
  65276. * @param matrix defines the source matrix
  65277. * @returns the current updated quaternion
  65278. */
  65279. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65280. /**
  65281. * Creates a new quaternion from a rotation matrix
  65282. * @param matrix defines the source matrix
  65283. * @returns a new quaternion created from the given rotation matrix values
  65284. */
  65285. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65286. /**
  65287. * Updates the given quaternion with the given rotation matrix values
  65288. * @param matrix defines the source matrix
  65289. * @param result defines the target quaternion
  65290. */
  65291. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65292. /**
  65293. * Returns the dot product (float) between the quaternions "left" and "right"
  65294. * @param left defines the left operand
  65295. * @param right defines the right operand
  65296. * @returns the dot product
  65297. */
  65298. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65299. /**
  65300. * Checks if the two quaternions are close to each other
  65301. * @param quat0 defines the first quaternion to check
  65302. * @param quat1 defines the second quaternion to check
  65303. * @returns true if the two quaternions are close to each other
  65304. */
  65305. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65306. /**
  65307. * Creates an empty quaternion
  65308. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65309. */
  65310. static Zero(): Quaternion;
  65311. /**
  65312. * Inverse a given quaternion
  65313. * @param q defines the source quaternion
  65314. * @returns a new quaternion as the inverted current quaternion
  65315. */
  65316. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65317. /**
  65318. * Inverse a given quaternion
  65319. * @param q defines the source quaternion
  65320. * @param result the quaternion the result will be stored in
  65321. * @returns the result quaternion
  65322. */
  65323. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65324. /**
  65325. * Creates an identity quaternion
  65326. * @returns the identity quaternion
  65327. */
  65328. static Identity(): Quaternion;
  65329. /**
  65330. * Gets a boolean indicating if the given quaternion is identity
  65331. * @param quaternion defines the quaternion to check
  65332. * @returns true if the quaternion is identity
  65333. */
  65334. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65335. /**
  65336. * Creates a quaternion from a rotation around an axis
  65337. * @param axis defines the axis to use
  65338. * @param angle defines the angle to use
  65339. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65340. */
  65341. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65342. /**
  65343. * Creates a rotation around an axis and stores it into the given quaternion
  65344. * @param axis defines the axis to use
  65345. * @param angle defines the angle to use
  65346. * @param result defines the target quaternion
  65347. * @returns the target quaternion
  65348. */
  65349. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65350. /**
  65351. * Creates a new quaternion from data stored into an array
  65352. * @param array defines the data source
  65353. * @param offset defines the offset in the source array where the data starts
  65354. * @returns a new quaternion
  65355. */
  65356. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65357. /**
  65358. * Create a quaternion from Euler rotation angles
  65359. * @param x Pitch
  65360. * @param y Yaw
  65361. * @param z Roll
  65362. * @returns the new Quaternion
  65363. */
  65364. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65365. /**
  65366. * Updates a quaternion from Euler rotation angles
  65367. * @param x Pitch
  65368. * @param y Yaw
  65369. * @param z Roll
  65370. * @param result the quaternion to store the result
  65371. * @returns the updated quaternion
  65372. */
  65373. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65374. /**
  65375. * Create a quaternion from Euler rotation vector
  65376. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65377. * @returns the new Quaternion
  65378. */
  65379. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65380. /**
  65381. * Updates a quaternion from Euler rotation vector
  65382. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65383. * @param result the quaternion to store the result
  65384. * @returns the updated quaternion
  65385. */
  65386. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65387. /**
  65388. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65389. * @param yaw defines the rotation around Y axis
  65390. * @param pitch defines the rotation around X axis
  65391. * @param roll defines the rotation around Z axis
  65392. * @returns the new quaternion
  65393. */
  65394. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65395. /**
  65396. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65397. * @param yaw defines the rotation around Y axis
  65398. * @param pitch defines the rotation around X axis
  65399. * @param roll defines the rotation around Z axis
  65400. * @param result defines the target quaternion
  65401. */
  65402. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65403. /**
  65404. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65405. * @param alpha defines the rotation around first axis
  65406. * @param beta defines the rotation around second axis
  65407. * @param gamma defines the rotation around third axis
  65408. * @returns the new quaternion
  65409. */
  65410. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65411. /**
  65412. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65413. * @param alpha defines the rotation around first axis
  65414. * @param beta defines the rotation around second axis
  65415. * @param gamma defines the rotation around third axis
  65416. * @param result defines the target quaternion
  65417. */
  65418. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65419. /**
  65420. * 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)
  65421. * @param axis1 defines the first axis
  65422. * @param axis2 defines the second axis
  65423. * @param axis3 defines the third axis
  65424. * @returns the new quaternion
  65425. */
  65426. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65427. /**
  65428. * 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
  65429. * @param axis1 defines the first axis
  65430. * @param axis2 defines the second axis
  65431. * @param axis3 defines the third axis
  65432. * @param ref defines the target quaternion
  65433. */
  65434. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65435. /**
  65436. * Interpolates between two quaternions
  65437. * @param left defines first quaternion
  65438. * @param right defines second quaternion
  65439. * @param amount defines the gradient to use
  65440. * @returns the new interpolated quaternion
  65441. */
  65442. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65443. /**
  65444. * Interpolates between two quaternions and stores it into a target quaternion
  65445. * @param left defines first quaternion
  65446. * @param right defines second quaternion
  65447. * @param amount defines the gradient to use
  65448. * @param result defines the target quaternion
  65449. */
  65450. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65451. /**
  65452. * Interpolate between two quaternions using Hermite interpolation
  65453. * @param value1 defines first quaternion
  65454. * @param tangent1 defines the incoming tangent
  65455. * @param value2 defines second quaternion
  65456. * @param tangent2 defines the outgoing tangent
  65457. * @param amount defines the target quaternion
  65458. * @returns the new interpolated quaternion
  65459. */
  65460. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65461. }
  65462. /**
  65463. * Class used to store matrix data (4x4)
  65464. */
  65465. export class Matrix {
  65466. private static _updateFlagSeed;
  65467. private static _identityReadOnly;
  65468. private _isIdentity;
  65469. private _isIdentityDirty;
  65470. private _isIdentity3x2;
  65471. private _isIdentity3x2Dirty;
  65472. /**
  65473. * Gets the update flag of the matrix which is an unique number for the matrix.
  65474. * It will be incremented every time the matrix data change.
  65475. * You can use it to speed the comparison between two versions of the same matrix.
  65476. */
  65477. updateFlag: number;
  65478. private readonly _m;
  65479. /**
  65480. * Gets the internal data of the matrix
  65481. */
  65482. readonly m: DeepImmutable<Float32Array>;
  65483. /** @hidden */
  65484. _markAsUpdated(): void;
  65485. /** @hidden */
  65486. private _updateIdentityStatus;
  65487. /**
  65488. * Creates an empty matrix (filled with zeros)
  65489. */
  65490. constructor();
  65491. /**
  65492. * Check if the current matrix is identity
  65493. * @returns true is the matrix is the identity matrix
  65494. */
  65495. isIdentity(): boolean;
  65496. /**
  65497. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65498. * @returns true is the matrix is the identity matrix
  65499. */
  65500. isIdentityAs3x2(): boolean;
  65501. /**
  65502. * Gets the determinant of the matrix
  65503. * @returns the matrix determinant
  65504. */
  65505. determinant(): number;
  65506. /**
  65507. * Returns the matrix as a Float32Array
  65508. * @returns the matrix underlying array
  65509. */
  65510. toArray(): DeepImmutable<Float32Array>;
  65511. /**
  65512. * Returns the matrix as a Float32Array
  65513. * @returns the matrix underlying array.
  65514. */
  65515. asArray(): DeepImmutable<Float32Array>;
  65516. /**
  65517. * Inverts the current matrix in place
  65518. * @returns the current inverted matrix
  65519. */
  65520. invert(): Matrix;
  65521. /**
  65522. * Sets all the matrix elements to zero
  65523. * @returns the current matrix
  65524. */
  65525. reset(): Matrix;
  65526. /**
  65527. * Adds the current matrix with a second one
  65528. * @param other defines the matrix to add
  65529. * @returns a new matrix as the addition of the current matrix and the given one
  65530. */
  65531. add(other: DeepImmutable<Matrix>): Matrix;
  65532. /**
  65533. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65534. * @param other defines the matrix to add
  65535. * @param result defines the target matrix
  65536. * @returns the current matrix
  65537. */
  65538. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65539. /**
  65540. * Adds in place the given matrix to the current matrix
  65541. * @param other defines the second operand
  65542. * @returns the current updated matrix
  65543. */
  65544. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65545. /**
  65546. * Sets the given matrix to the current inverted Matrix
  65547. * @param other defines the target matrix
  65548. * @returns the unmodified current matrix
  65549. */
  65550. invertToRef(other: Matrix): Matrix;
  65551. /**
  65552. * add a value at the specified position in the current Matrix
  65553. * @param index the index of the value within the matrix. between 0 and 15.
  65554. * @param value the value to be added
  65555. * @returns the current updated matrix
  65556. */
  65557. addAtIndex(index: number, value: number): Matrix;
  65558. /**
  65559. * mutiply the specified position in the current Matrix by a value
  65560. * @param index the index of the value within the matrix. between 0 and 15.
  65561. * @param value the value to be added
  65562. * @returns the current updated matrix
  65563. */
  65564. multiplyAtIndex(index: number, value: number): Matrix;
  65565. /**
  65566. * Inserts the translation vector (using 3 floats) in the current matrix
  65567. * @param x defines the 1st component of the translation
  65568. * @param y defines the 2nd component of the translation
  65569. * @param z defines the 3rd component of the translation
  65570. * @returns the current updated matrix
  65571. */
  65572. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65573. /**
  65574. * Adds the translation vector (using 3 floats) in the current matrix
  65575. * @param x defines the 1st component of the translation
  65576. * @param y defines the 2nd component of the translation
  65577. * @param z defines the 3rd component of the translation
  65578. * @returns the current updated matrix
  65579. */
  65580. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65581. /**
  65582. * Inserts the translation vector in the current matrix
  65583. * @param vector3 defines the translation to insert
  65584. * @returns the current updated matrix
  65585. */
  65586. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65587. /**
  65588. * Gets the translation value of the current matrix
  65589. * @returns a new Vector3 as the extracted translation from the matrix
  65590. */
  65591. getTranslation(): Vector3;
  65592. /**
  65593. * Fill a Vector3 with the extracted translation from the matrix
  65594. * @param result defines the Vector3 where to store the translation
  65595. * @returns the current matrix
  65596. */
  65597. getTranslationToRef(result: Vector3): Matrix;
  65598. /**
  65599. * Remove rotation and scaling part from the matrix
  65600. * @returns the updated matrix
  65601. */
  65602. removeRotationAndScaling(): Matrix;
  65603. /**
  65604. * Multiply two matrices
  65605. * @param other defines the second operand
  65606. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65607. */
  65608. multiply(other: DeepImmutable<Matrix>): Matrix;
  65609. /**
  65610. * Copy the current matrix from the given one
  65611. * @param other defines the source matrix
  65612. * @returns the current updated matrix
  65613. */
  65614. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65615. /**
  65616. * Populates the given array from the starting index with the current matrix values
  65617. * @param array defines the target array
  65618. * @param offset defines the offset in the target array where to start storing values
  65619. * @returns the current matrix
  65620. */
  65621. copyToArray(array: Float32Array, offset?: number): Matrix;
  65622. /**
  65623. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65624. * @param other defines the second operand
  65625. * @param result defines the matrix where to store the multiplication
  65626. * @returns the current matrix
  65627. */
  65628. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65629. /**
  65630. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65631. * @param other defines the second operand
  65632. * @param result defines the array where to store the multiplication
  65633. * @param offset defines the offset in the target array where to start storing values
  65634. * @returns the current matrix
  65635. */
  65636. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65637. /**
  65638. * Check equality between this matrix and a second one
  65639. * @param value defines the second matrix to compare
  65640. * @returns true is the current matrix and the given one values are strictly equal
  65641. */
  65642. equals(value: DeepImmutable<Matrix>): boolean;
  65643. /**
  65644. * Clone the current matrix
  65645. * @returns a new matrix from the current matrix
  65646. */
  65647. clone(): Matrix;
  65648. /**
  65649. * Returns the name of the current matrix class
  65650. * @returns the string "Matrix"
  65651. */
  65652. getClassName(): string;
  65653. /**
  65654. * Gets the hash code of the current matrix
  65655. * @returns the hash code
  65656. */
  65657. getHashCode(): number;
  65658. /**
  65659. * Decomposes the current Matrix into a translation, rotation and scaling components
  65660. * @param scale defines the scale vector3 given as a reference to update
  65661. * @param rotation defines the rotation quaternion given as a reference to update
  65662. * @param translation defines the translation vector3 given as a reference to update
  65663. * @returns true if operation was successful
  65664. */
  65665. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65666. /**
  65667. * Gets specific row of the matrix
  65668. * @param index defines the number of the row to get
  65669. * @returns the index-th row of the current matrix as a new Vector4
  65670. */
  65671. getRow(index: number): Nullable<Vector4>;
  65672. /**
  65673. * Sets the index-th row of the current matrix to the vector4 values
  65674. * @param index defines the number of the row to set
  65675. * @param row defines the target vector4
  65676. * @returns the updated current matrix
  65677. */
  65678. setRow(index: number, row: Vector4): Matrix;
  65679. /**
  65680. * Compute the transpose of the matrix
  65681. * @returns the new transposed matrix
  65682. */
  65683. transpose(): Matrix;
  65684. /**
  65685. * Compute the transpose of the matrix and store it in a given matrix
  65686. * @param result defines the target matrix
  65687. * @returns the current matrix
  65688. */
  65689. transposeToRef(result: Matrix): Matrix;
  65690. /**
  65691. * Sets the index-th row of the current matrix with the given 4 x float values
  65692. * @param index defines the row index
  65693. * @param x defines the x component to set
  65694. * @param y defines the y component to set
  65695. * @param z defines the z component to set
  65696. * @param w defines the w component to set
  65697. * @returns the updated current matrix
  65698. */
  65699. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65700. /**
  65701. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65702. * @param scale defines the scale factor
  65703. * @returns a new matrix
  65704. */
  65705. scale(scale: number): Matrix;
  65706. /**
  65707. * Scale the current matrix values by a factor to a given result matrix
  65708. * @param scale defines the scale factor
  65709. * @param result defines the matrix to store the result
  65710. * @returns the current matrix
  65711. */
  65712. scaleToRef(scale: number, result: Matrix): Matrix;
  65713. /**
  65714. * Scale the current matrix values by a factor and add the result to a given matrix
  65715. * @param scale defines the scale factor
  65716. * @param result defines the Matrix to store the result
  65717. * @returns the current matrix
  65718. */
  65719. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65720. /**
  65721. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65722. * @param ref matrix to store the result
  65723. */
  65724. toNormalMatrix(ref: Matrix): void;
  65725. /**
  65726. * Gets only rotation part of the current matrix
  65727. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65728. */
  65729. getRotationMatrix(): Matrix;
  65730. /**
  65731. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65732. * @param result defines the target matrix to store data to
  65733. * @returns the current matrix
  65734. */
  65735. getRotationMatrixToRef(result: Matrix): Matrix;
  65736. /**
  65737. * Toggles model matrix from being right handed to left handed in place and vice versa
  65738. */
  65739. toggleModelMatrixHandInPlace(): void;
  65740. /**
  65741. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65742. */
  65743. toggleProjectionMatrixHandInPlace(): void;
  65744. /**
  65745. * Creates a matrix from an array
  65746. * @param array defines the source array
  65747. * @param offset defines an offset in the source array
  65748. * @returns a new Matrix set from the starting index of the given array
  65749. */
  65750. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65751. /**
  65752. * Copy the content of an array into a given matrix
  65753. * @param array defines the source array
  65754. * @param offset defines an offset in the source array
  65755. * @param result defines the target matrix
  65756. */
  65757. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65758. /**
  65759. * Stores an array into a matrix after having multiplied each component by a given factor
  65760. * @param array defines the source array
  65761. * @param offset defines the offset in the source array
  65762. * @param scale defines the scaling factor
  65763. * @param result defines the target matrix
  65764. */
  65765. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65766. /**
  65767. * Gets an identity matrix that must not be updated
  65768. */
  65769. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65770. /**
  65771. * Stores a list of values (16) inside a given matrix
  65772. * @param initialM11 defines 1st value of 1st row
  65773. * @param initialM12 defines 2nd value of 1st row
  65774. * @param initialM13 defines 3rd value of 1st row
  65775. * @param initialM14 defines 4th value of 1st row
  65776. * @param initialM21 defines 1st value of 2nd row
  65777. * @param initialM22 defines 2nd value of 2nd row
  65778. * @param initialM23 defines 3rd value of 2nd row
  65779. * @param initialM24 defines 4th value of 2nd row
  65780. * @param initialM31 defines 1st value of 3rd row
  65781. * @param initialM32 defines 2nd value of 3rd row
  65782. * @param initialM33 defines 3rd value of 3rd row
  65783. * @param initialM34 defines 4th value of 3rd row
  65784. * @param initialM41 defines 1st value of 4th row
  65785. * @param initialM42 defines 2nd value of 4th row
  65786. * @param initialM43 defines 3rd value of 4th row
  65787. * @param initialM44 defines 4th value of 4th row
  65788. * @param result defines the target matrix
  65789. */
  65790. 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;
  65791. /**
  65792. * Creates new matrix from a list of values (16)
  65793. * @param initialM11 defines 1st value of 1st row
  65794. * @param initialM12 defines 2nd value of 1st row
  65795. * @param initialM13 defines 3rd value of 1st row
  65796. * @param initialM14 defines 4th value of 1st row
  65797. * @param initialM21 defines 1st value of 2nd row
  65798. * @param initialM22 defines 2nd value of 2nd row
  65799. * @param initialM23 defines 3rd value of 2nd row
  65800. * @param initialM24 defines 4th value of 2nd row
  65801. * @param initialM31 defines 1st value of 3rd row
  65802. * @param initialM32 defines 2nd value of 3rd row
  65803. * @param initialM33 defines 3rd value of 3rd row
  65804. * @param initialM34 defines 4th value of 3rd row
  65805. * @param initialM41 defines 1st value of 4th row
  65806. * @param initialM42 defines 2nd value of 4th row
  65807. * @param initialM43 defines 3rd value of 4th row
  65808. * @param initialM44 defines 4th value of 4th row
  65809. * @returns the new matrix
  65810. */
  65811. 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;
  65812. /**
  65813. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65814. * @param scale defines the scale vector3
  65815. * @param rotation defines the rotation quaternion
  65816. * @param translation defines the translation vector3
  65817. * @returns a new matrix
  65818. */
  65819. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65820. /**
  65821. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65822. * @param scale defines the scale vector3
  65823. * @param rotation defines the rotation quaternion
  65824. * @param translation defines the translation vector3
  65825. * @param result defines the target matrix
  65826. */
  65827. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65828. /**
  65829. * Creates a new identity matrix
  65830. * @returns a new identity matrix
  65831. */
  65832. static Identity(): Matrix;
  65833. /**
  65834. * Creates a new identity matrix and stores the result in a given matrix
  65835. * @param result defines the target matrix
  65836. */
  65837. static IdentityToRef(result: Matrix): void;
  65838. /**
  65839. * Creates a new zero matrix
  65840. * @returns a new zero matrix
  65841. */
  65842. static Zero(): Matrix;
  65843. /**
  65844. * Creates a new rotation matrix for "angle" radians around the X axis
  65845. * @param angle defines the angle (in radians) to use
  65846. * @return the new matrix
  65847. */
  65848. static RotationX(angle: number): Matrix;
  65849. /**
  65850. * Creates a new matrix as the invert of a given matrix
  65851. * @param source defines the source matrix
  65852. * @returns the new matrix
  65853. */
  65854. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65855. /**
  65856. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65857. * @param angle defines the angle (in radians) to use
  65858. * @param result defines the target matrix
  65859. */
  65860. static RotationXToRef(angle: number, result: Matrix): void;
  65861. /**
  65862. * Creates a new rotation matrix for "angle" radians around the Y axis
  65863. * @param angle defines the angle (in radians) to use
  65864. * @return the new matrix
  65865. */
  65866. static RotationY(angle: number): Matrix;
  65867. /**
  65868. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65869. * @param angle defines the angle (in radians) to use
  65870. * @param result defines the target matrix
  65871. */
  65872. static RotationYToRef(angle: number, result: Matrix): void;
  65873. /**
  65874. * Creates a new rotation matrix for "angle" radians around the Z axis
  65875. * @param angle defines the angle (in radians) to use
  65876. * @return the new matrix
  65877. */
  65878. static RotationZ(angle: number): Matrix;
  65879. /**
  65880. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65881. * @param angle defines the angle (in radians) to use
  65882. * @param result defines the target matrix
  65883. */
  65884. static RotationZToRef(angle: number, result: Matrix): void;
  65885. /**
  65886. * Creates a new rotation matrix for "angle" radians around the given axis
  65887. * @param axis defines the axis to use
  65888. * @param angle defines the angle (in radians) to use
  65889. * @return the new matrix
  65890. */
  65891. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65892. /**
  65893. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65894. * @param axis defines the axis to use
  65895. * @param angle defines the angle (in radians) to use
  65896. * @param result defines the target matrix
  65897. */
  65898. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65899. /**
  65900. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65901. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65902. * @param from defines the vector to align
  65903. * @param to defines the vector to align to
  65904. * @param result defines the target matrix
  65905. */
  65906. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65907. /**
  65908. * Creates a rotation matrix
  65909. * @param yaw defines the yaw angle in radians (Y axis)
  65910. * @param pitch defines the pitch angle in radians (X axis)
  65911. * @param roll defines the roll angle in radians (X axis)
  65912. * @returns the new rotation matrix
  65913. */
  65914. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65915. /**
  65916. * Creates a rotation matrix and stores it in a given matrix
  65917. * @param yaw defines the yaw angle in radians (Y axis)
  65918. * @param pitch defines the pitch angle in radians (X axis)
  65919. * @param roll defines the roll angle in radians (X axis)
  65920. * @param result defines the target matrix
  65921. */
  65922. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65923. /**
  65924. * Creates a scaling matrix
  65925. * @param x defines the scale factor on X axis
  65926. * @param y defines the scale factor on Y axis
  65927. * @param z defines the scale factor on Z axis
  65928. * @returns the new matrix
  65929. */
  65930. static Scaling(x: number, y: number, z: number): Matrix;
  65931. /**
  65932. * Creates a scaling matrix and stores it in a given matrix
  65933. * @param x defines the scale factor on X axis
  65934. * @param y defines the scale factor on Y axis
  65935. * @param z defines the scale factor on Z axis
  65936. * @param result defines the target matrix
  65937. */
  65938. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65939. /**
  65940. * Creates a translation matrix
  65941. * @param x defines the translation on X axis
  65942. * @param y defines the translation on Y axis
  65943. * @param z defines the translationon Z axis
  65944. * @returns the new matrix
  65945. */
  65946. static Translation(x: number, y: number, z: number): Matrix;
  65947. /**
  65948. * Creates a translation matrix and stores it in a given matrix
  65949. * @param x defines the translation on X axis
  65950. * @param y defines the translation on Y axis
  65951. * @param z defines the translationon Z axis
  65952. * @param result defines the target matrix
  65953. */
  65954. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65955. /**
  65956. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65957. * @param startValue defines the start value
  65958. * @param endValue defines the end value
  65959. * @param gradient defines the gradient factor
  65960. * @returns the new matrix
  65961. */
  65962. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65963. /**
  65964. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65965. * @param startValue defines the start value
  65966. * @param endValue defines the end value
  65967. * @param gradient defines the gradient factor
  65968. * @param result defines the Matrix object where to store data
  65969. */
  65970. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65971. /**
  65972. * Builds a new matrix whose values are computed by:
  65973. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65974. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65975. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65976. * @param startValue defines the first matrix
  65977. * @param endValue defines the second matrix
  65978. * @param gradient defines the gradient between the two matrices
  65979. * @returns the new matrix
  65980. */
  65981. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65982. /**
  65983. * Update a matrix to values which are computed by:
  65984. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65985. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65986. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65987. * @param startValue defines the first matrix
  65988. * @param endValue defines the second matrix
  65989. * @param gradient defines the gradient between the two matrices
  65990. * @param result defines the target matrix
  65991. */
  65992. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65993. /**
  65994. * 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"
  65995. * This function works in left handed mode
  65996. * @param eye defines the final position of the entity
  65997. * @param target defines where the entity should look at
  65998. * @param up defines the up vector for the entity
  65999. * @returns the new matrix
  66000. */
  66001. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66002. /**
  66003. * 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".
  66004. * This function works in left handed mode
  66005. * @param eye defines the final position of the entity
  66006. * @param target defines where the entity should look at
  66007. * @param up defines the up vector for the entity
  66008. * @param result defines the target matrix
  66009. */
  66010. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66011. /**
  66012. * 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"
  66013. * This function works in right handed mode
  66014. * @param eye defines the final position of the entity
  66015. * @param target defines where the entity should look at
  66016. * @param up defines the up vector for the entity
  66017. * @returns the new matrix
  66018. */
  66019. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66020. /**
  66021. * 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".
  66022. * This function works in right handed mode
  66023. * @param eye defines the final position of the entity
  66024. * @param target defines where the entity should look at
  66025. * @param up defines the up vector for the entity
  66026. * @param result defines the target matrix
  66027. */
  66028. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66029. /**
  66030. * Create a left-handed orthographic projection matrix
  66031. * @param width defines the viewport width
  66032. * @param height defines the viewport height
  66033. * @param znear defines the near clip plane
  66034. * @param zfar defines the far clip plane
  66035. * @returns a new matrix as a left-handed orthographic projection matrix
  66036. */
  66037. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66038. /**
  66039. * Store a left-handed orthographic projection to a given matrix
  66040. * @param width defines the viewport width
  66041. * @param height defines the viewport height
  66042. * @param znear defines the near clip plane
  66043. * @param zfar defines the far clip plane
  66044. * @param result defines the target matrix
  66045. */
  66046. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66047. /**
  66048. * Create a left-handed orthographic projection matrix
  66049. * @param left defines the viewport left coordinate
  66050. * @param right defines the viewport right coordinate
  66051. * @param bottom defines the viewport bottom coordinate
  66052. * @param top defines the viewport top coordinate
  66053. * @param znear defines the near clip plane
  66054. * @param zfar defines the far clip plane
  66055. * @returns a new matrix as a left-handed orthographic projection matrix
  66056. */
  66057. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66058. /**
  66059. * Stores a left-handed orthographic projection into a given matrix
  66060. * @param left defines the viewport left coordinate
  66061. * @param right defines the viewport right coordinate
  66062. * @param bottom defines the viewport bottom coordinate
  66063. * @param top defines the viewport top coordinate
  66064. * @param znear defines the near clip plane
  66065. * @param zfar defines the far clip plane
  66066. * @param result defines the target matrix
  66067. */
  66068. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66069. /**
  66070. * Creates a right-handed orthographic projection matrix
  66071. * @param left defines the viewport left coordinate
  66072. * @param right defines the viewport right coordinate
  66073. * @param bottom defines the viewport bottom coordinate
  66074. * @param top defines the viewport top coordinate
  66075. * @param znear defines the near clip plane
  66076. * @param zfar defines the far clip plane
  66077. * @returns a new matrix as a right-handed orthographic projection matrix
  66078. */
  66079. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66080. /**
  66081. * Stores a right-handed orthographic projection into a given matrix
  66082. * @param left defines the viewport left coordinate
  66083. * @param right defines the viewport right coordinate
  66084. * @param bottom defines the viewport bottom coordinate
  66085. * @param top defines the viewport top coordinate
  66086. * @param znear defines the near clip plane
  66087. * @param zfar defines the far clip plane
  66088. * @param result defines the target matrix
  66089. */
  66090. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66091. /**
  66092. * Creates a left-handed perspective projection matrix
  66093. * @param width defines the viewport width
  66094. * @param height defines the viewport height
  66095. * @param znear defines the near clip plane
  66096. * @param zfar defines the far clip plane
  66097. * @returns a new matrix as a left-handed perspective projection matrix
  66098. */
  66099. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66100. /**
  66101. * Creates a left-handed perspective projection matrix
  66102. * @param fov defines the horizontal field of view
  66103. * @param aspect defines the aspect ratio
  66104. * @param znear defines the near clip plane
  66105. * @param zfar defines the far clip plane
  66106. * @returns a new matrix as a left-handed perspective projection matrix
  66107. */
  66108. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66109. /**
  66110. * Stores a left-handed perspective projection into a given matrix
  66111. * @param fov defines the horizontal field of view
  66112. * @param aspect defines the aspect ratio
  66113. * @param znear defines the near clip plane
  66114. * @param zfar defines the far clip plane
  66115. * @param result defines the target matrix
  66116. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66117. */
  66118. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66119. /**
  66120. * Creates a right-handed perspective projection matrix
  66121. * @param fov defines the horizontal field of view
  66122. * @param aspect defines the aspect ratio
  66123. * @param znear defines the near clip plane
  66124. * @param zfar defines the far clip plane
  66125. * @returns a new matrix as a right-handed perspective projection matrix
  66126. */
  66127. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66128. /**
  66129. * Stores a right-handed perspective projection into a given matrix
  66130. * @param fov defines the horizontal field of view
  66131. * @param aspect defines the aspect ratio
  66132. * @param znear defines the near clip plane
  66133. * @param zfar defines the far clip plane
  66134. * @param result defines the target matrix
  66135. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66136. */
  66137. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66138. /**
  66139. * Stores a perspective projection for WebVR info a given matrix
  66140. * @param fov defines the field of view
  66141. * @param znear defines the near clip plane
  66142. * @param zfar defines the far clip plane
  66143. * @param result defines the target matrix
  66144. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66145. */
  66146. static PerspectiveFovWebVRToRef(fov: {
  66147. upDegrees: number;
  66148. downDegrees: number;
  66149. leftDegrees: number;
  66150. rightDegrees: number;
  66151. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66152. /**
  66153. * Computes a complete transformation matrix
  66154. * @param viewport defines the viewport to use
  66155. * @param world defines the world matrix
  66156. * @param view defines the view matrix
  66157. * @param projection defines the projection matrix
  66158. * @param zmin defines the near clip plane
  66159. * @param zmax defines the far clip plane
  66160. * @returns the transformation matrix
  66161. */
  66162. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66163. /**
  66164. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66165. * @param matrix defines the matrix to use
  66166. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66167. */
  66168. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66169. /**
  66170. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66171. * @param matrix defines the matrix to use
  66172. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66173. */
  66174. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66175. /**
  66176. * Compute the transpose of a given matrix
  66177. * @param matrix defines the matrix to transpose
  66178. * @returns the new matrix
  66179. */
  66180. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66181. /**
  66182. * Compute the transpose of a matrix and store it in a target matrix
  66183. * @param matrix defines the matrix to transpose
  66184. * @param result defines the target matrix
  66185. */
  66186. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66187. /**
  66188. * Computes a reflection matrix from a plane
  66189. * @param plane defines the reflection plane
  66190. * @returns a new matrix
  66191. */
  66192. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66193. /**
  66194. * Computes a reflection matrix from a plane
  66195. * @param plane defines the reflection plane
  66196. * @param result defines the target matrix
  66197. */
  66198. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66199. /**
  66200. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66201. * @param xaxis defines the value of the 1st axis
  66202. * @param yaxis defines the value of the 2nd axis
  66203. * @param zaxis defines the value of the 3rd axis
  66204. * @param result defines the target matrix
  66205. */
  66206. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66207. /**
  66208. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66209. * @param quat defines the quaternion to use
  66210. * @param result defines the target matrix
  66211. */
  66212. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66213. }
  66214. /**
  66215. * Represens a plane by the equation ax + by + cz + d = 0
  66216. */
  66217. export class Plane {
  66218. /**
  66219. * Normal of the plane (a,b,c)
  66220. */
  66221. normal: Vector3;
  66222. /**
  66223. * d component of the plane
  66224. */
  66225. d: number;
  66226. /**
  66227. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66228. * @param a a component of the plane
  66229. * @param b b component of the plane
  66230. * @param c c component of the plane
  66231. * @param d d component of the plane
  66232. */
  66233. constructor(a: number, b: number, c: number, d: number);
  66234. /**
  66235. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66236. */
  66237. asArray(): number[];
  66238. /**
  66239. * @returns a new plane copied from the current Plane.
  66240. */
  66241. clone(): Plane;
  66242. /**
  66243. * @returns the string "Plane".
  66244. */
  66245. getClassName(): string;
  66246. /**
  66247. * @returns the Plane hash code.
  66248. */
  66249. getHashCode(): number;
  66250. /**
  66251. * Normalize the current Plane in place.
  66252. * @returns the updated Plane.
  66253. */
  66254. normalize(): Plane;
  66255. /**
  66256. * Applies a transformation the plane and returns the result
  66257. * @param transformation the transformation matrix to be applied to the plane
  66258. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66259. */
  66260. transform(transformation: DeepImmutable<Matrix>): Plane;
  66261. /**
  66262. * Calcualtte the dot product between the point and the plane normal
  66263. * @param point point to calculate the dot product with
  66264. * @returns the dot product (float) of the point coordinates and the plane normal.
  66265. */
  66266. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66267. /**
  66268. * Updates the current Plane from the plane defined by the three given points.
  66269. * @param point1 one of the points used to contruct the plane
  66270. * @param point2 one of the points used to contruct the plane
  66271. * @param point3 one of the points used to contruct the plane
  66272. * @returns the updated Plane.
  66273. */
  66274. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66275. /**
  66276. * Checks if the plane is facing a given direction
  66277. * @param direction the direction to check if the plane is facing
  66278. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66279. * @returns True is the vector "direction" is the same side than the plane normal.
  66280. */
  66281. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66282. /**
  66283. * Calculates the distance to a point
  66284. * @param point point to calculate distance to
  66285. * @returns the signed distance (float) from the given point to the Plane.
  66286. */
  66287. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66288. /**
  66289. * Creates a plane from an array
  66290. * @param array the array to create a plane from
  66291. * @returns a new Plane from the given array.
  66292. */
  66293. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66294. /**
  66295. * Creates a plane from three points
  66296. * @param point1 point used to create the plane
  66297. * @param point2 point used to create the plane
  66298. * @param point3 point used to create the plane
  66299. * @returns a new Plane defined by the three given points.
  66300. */
  66301. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66302. /**
  66303. * Creates a plane from an origin point and a normal
  66304. * @param origin origin of the plane to be constructed
  66305. * @param normal normal of the plane to be constructed
  66306. * @returns a new Plane the normal vector to this plane at the given origin point.
  66307. * Note : the vector "normal" is updated because normalized.
  66308. */
  66309. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66310. /**
  66311. * Calculates the distance from a plane and a point
  66312. * @param origin origin of the plane to be constructed
  66313. * @param normal normal of the plane to be constructed
  66314. * @param point point to calculate distance to
  66315. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66316. */
  66317. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66318. }
  66319. /**
  66320. * Class used to represent a viewport on screen
  66321. */
  66322. export class Viewport {
  66323. /** viewport left coordinate */
  66324. x: number;
  66325. /** viewport top coordinate */
  66326. y: number;
  66327. /**viewport width */
  66328. width: number;
  66329. /** viewport height */
  66330. height: number;
  66331. /**
  66332. * Creates a Viewport object located at (x, y) and sized (width, height)
  66333. * @param x defines viewport left coordinate
  66334. * @param y defines viewport top coordinate
  66335. * @param width defines the viewport width
  66336. * @param height defines the viewport height
  66337. */
  66338. constructor(
  66339. /** viewport left coordinate */
  66340. x: number,
  66341. /** viewport top coordinate */
  66342. y: number,
  66343. /**viewport width */
  66344. width: number,
  66345. /** viewport height */
  66346. height: number);
  66347. /**
  66348. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66349. * @param renderWidth defines the rendering width
  66350. * @param renderHeight defines the rendering height
  66351. * @returns a new Viewport
  66352. */
  66353. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66354. /**
  66355. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66356. * @param renderWidth defines the rendering width
  66357. * @param renderHeight defines the rendering height
  66358. * @param ref defines the target viewport
  66359. * @returns the current viewport
  66360. */
  66361. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66362. /**
  66363. * Returns a new Viewport copied from the current one
  66364. * @returns a new Viewport
  66365. */
  66366. clone(): Viewport;
  66367. }
  66368. /**
  66369. * Reprasents a camera frustum
  66370. */
  66371. export class Frustum {
  66372. /**
  66373. * Gets the planes representing the frustum
  66374. * @param transform matrix to be applied to the returned planes
  66375. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66376. */
  66377. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66378. /**
  66379. * Gets the near frustum plane transformed by the transform matrix
  66380. * @param transform transformation matrix to be applied to the resulting frustum plane
  66381. * @param frustumPlane the resuling frustum plane
  66382. */
  66383. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66384. /**
  66385. * Gets the far frustum plane transformed by the transform matrix
  66386. * @param transform transformation matrix to be applied to the resulting frustum plane
  66387. * @param frustumPlane the resuling frustum plane
  66388. */
  66389. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66390. /**
  66391. * Gets the left frustum plane transformed by the transform matrix
  66392. * @param transform transformation matrix to be applied to the resulting frustum plane
  66393. * @param frustumPlane the resuling frustum plane
  66394. */
  66395. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66396. /**
  66397. * Gets the right frustum plane transformed by the transform matrix
  66398. * @param transform transformation matrix to be applied to the resulting frustum plane
  66399. * @param frustumPlane the resuling frustum plane
  66400. */
  66401. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66402. /**
  66403. * Gets the top frustum plane transformed by the transform matrix
  66404. * @param transform transformation matrix to be applied to the resulting frustum plane
  66405. * @param frustumPlane the resuling frustum plane
  66406. */
  66407. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66408. /**
  66409. * Gets the bottom frustum plane transformed by the transform matrix
  66410. * @param transform transformation matrix to be applied to the resulting frustum plane
  66411. * @param frustumPlane the resuling frustum plane
  66412. */
  66413. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66414. /**
  66415. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66416. * @param transform transformation matrix to be applied to the resulting frustum planes
  66417. * @param frustumPlanes the resuling frustum planes
  66418. */
  66419. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66420. }
  66421. /** Defines supported spaces */
  66422. export enum Space {
  66423. /** Local (object) space */
  66424. LOCAL = 0,
  66425. /** World space */
  66426. WORLD = 1,
  66427. /** Bone space */
  66428. BONE = 2
  66429. }
  66430. /** Defines the 3 main axes */
  66431. export class Axis {
  66432. /** X axis */
  66433. static X: Vector3;
  66434. /** Y axis */
  66435. static Y: Vector3;
  66436. /** Z axis */
  66437. static Z: Vector3;
  66438. }
  66439. /** Class used to represent a Bezier curve */
  66440. export class BezierCurve {
  66441. /**
  66442. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66443. * @param t defines the time
  66444. * @param x1 defines the left coordinate on X axis
  66445. * @param y1 defines the left coordinate on Y axis
  66446. * @param x2 defines the right coordinate on X axis
  66447. * @param y2 defines the right coordinate on Y axis
  66448. * @returns the interpolated value
  66449. */
  66450. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66451. }
  66452. /**
  66453. * Defines potential orientation for back face culling
  66454. */
  66455. export enum Orientation {
  66456. /**
  66457. * Clockwise
  66458. */
  66459. CW = 0,
  66460. /** Counter clockwise */
  66461. CCW = 1
  66462. }
  66463. /**
  66464. * Defines angle representation
  66465. */
  66466. export class Angle {
  66467. private _radians;
  66468. /**
  66469. * Creates an Angle object of "radians" radians (float).
  66470. * @param radians the angle in radians
  66471. */
  66472. constructor(radians: number);
  66473. /**
  66474. * Get value in degrees
  66475. * @returns the Angle value in degrees (float)
  66476. */
  66477. degrees(): number;
  66478. /**
  66479. * Get value in radians
  66480. * @returns the Angle value in radians (float)
  66481. */
  66482. radians(): number;
  66483. /**
  66484. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66485. * @param a defines first vector
  66486. * @param b defines second vector
  66487. * @returns a new Angle
  66488. */
  66489. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66490. /**
  66491. * Gets a new Angle object from the given float in radians
  66492. * @param radians defines the angle value in radians
  66493. * @returns a new Angle
  66494. */
  66495. static FromRadians(radians: number): Angle;
  66496. /**
  66497. * Gets a new Angle object from the given float in degrees
  66498. * @param degrees defines the angle value in degrees
  66499. * @returns a new Angle
  66500. */
  66501. static FromDegrees(degrees: number): Angle;
  66502. }
  66503. /**
  66504. * This represents an arc in a 2d space.
  66505. */
  66506. export class Arc2 {
  66507. /** Defines the start point of the arc */
  66508. startPoint: Vector2;
  66509. /** Defines the mid point of the arc */
  66510. midPoint: Vector2;
  66511. /** Defines the end point of the arc */
  66512. endPoint: Vector2;
  66513. /**
  66514. * Defines the center point of the arc.
  66515. */
  66516. centerPoint: Vector2;
  66517. /**
  66518. * Defines the radius of the arc.
  66519. */
  66520. radius: number;
  66521. /**
  66522. * Defines the angle of the arc (from mid point to end point).
  66523. */
  66524. angle: Angle;
  66525. /**
  66526. * Defines the start angle of the arc (from start point to middle point).
  66527. */
  66528. startAngle: Angle;
  66529. /**
  66530. * Defines the orientation of the arc (clock wise/counter clock wise).
  66531. */
  66532. orientation: Orientation;
  66533. /**
  66534. * Creates an Arc object from the three given points : start, middle and end.
  66535. * @param startPoint Defines the start point of the arc
  66536. * @param midPoint Defines the midlle point of the arc
  66537. * @param endPoint Defines the end point of the arc
  66538. */
  66539. constructor(
  66540. /** Defines the start point of the arc */
  66541. startPoint: Vector2,
  66542. /** Defines the mid point of the arc */
  66543. midPoint: Vector2,
  66544. /** Defines the end point of the arc */
  66545. endPoint: Vector2);
  66546. }
  66547. /**
  66548. * Represents a 2D path made up of multiple 2D points
  66549. */
  66550. export class Path2 {
  66551. private _points;
  66552. private _length;
  66553. /**
  66554. * If the path start and end point are the same
  66555. */
  66556. closed: boolean;
  66557. /**
  66558. * Creates a Path2 object from the starting 2D coordinates x and y.
  66559. * @param x the starting points x value
  66560. * @param y the starting points y value
  66561. */
  66562. constructor(x: number, y: number);
  66563. /**
  66564. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66565. * @param x the added points x value
  66566. * @param y the added points y value
  66567. * @returns the updated Path2.
  66568. */
  66569. addLineTo(x: number, y: number): Path2;
  66570. /**
  66571. * 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.
  66572. * @param midX middle point x value
  66573. * @param midY middle point y value
  66574. * @param endX end point x value
  66575. * @param endY end point y value
  66576. * @param numberOfSegments (default: 36)
  66577. * @returns the updated Path2.
  66578. */
  66579. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66580. /**
  66581. * Closes the Path2.
  66582. * @returns the Path2.
  66583. */
  66584. close(): Path2;
  66585. /**
  66586. * Gets the sum of the distance between each sequential point in the path
  66587. * @returns the Path2 total length (float).
  66588. */
  66589. length(): number;
  66590. /**
  66591. * Gets the points which construct the path
  66592. * @returns the Path2 internal array of points.
  66593. */
  66594. getPoints(): Vector2[];
  66595. /**
  66596. * Retreives the point at the distance aways from the starting point
  66597. * @param normalizedLengthPosition the length along the path to retreive the point from
  66598. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66599. */
  66600. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66601. /**
  66602. * Creates a new path starting from an x and y position
  66603. * @param x starting x value
  66604. * @param y starting y value
  66605. * @returns a new Path2 starting at the coordinates (x, y).
  66606. */
  66607. static StartingAt(x: number, y: number): Path2;
  66608. }
  66609. /**
  66610. * Represents a 3D path made up of multiple 3D points
  66611. */
  66612. export class Path3D {
  66613. /**
  66614. * an array of Vector3, the curve axis of the Path3D
  66615. */
  66616. path: Vector3[];
  66617. private _curve;
  66618. private _distances;
  66619. private _tangents;
  66620. private _normals;
  66621. private _binormals;
  66622. private _raw;
  66623. /**
  66624. * new Path3D(path, normal, raw)
  66625. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66626. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66627. * @param path an array of Vector3, the curve axis of the Path3D
  66628. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66629. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66630. */
  66631. constructor(
  66632. /**
  66633. * an array of Vector3, the curve axis of the Path3D
  66634. */
  66635. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66636. /**
  66637. * Returns the Path3D array of successive Vector3 designing its curve.
  66638. * @returns the Path3D array of successive Vector3 designing its curve.
  66639. */
  66640. getCurve(): Vector3[];
  66641. /**
  66642. * Returns an array populated with tangent vectors on each Path3D curve point.
  66643. * @returns an array populated with tangent vectors on each Path3D curve point.
  66644. */
  66645. getTangents(): Vector3[];
  66646. /**
  66647. * Returns an array populated with normal vectors on each Path3D curve point.
  66648. * @returns an array populated with normal vectors on each Path3D curve point.
  66649. */
  66650. getNormals(): Vector3[];
  66651. /**
  66652. * Returns an array populated with binormal vectors on each Path3D curve point.
  66653. * @returns an array populated with binormal vectors on each Path3D curve point.
  66654. */
  66655. getBinormals(): Vector3[];
  66656. /**
  66657. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66658. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66659. */
  66660. getDistances(): number[];
  66661. /**
  66662. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66663. * @param path path which all values are copied into the curves points
  66664. * @param firstNormal which should be projected onto the curve
  66665. * @returns the same object updated.
  66666. */
  66667. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66668. private _compute;
  66669. private _getFirstNonNullVector;
  66670. private _getLastNonNullVector;
  66671. private _normalVector;
  66672. }
  66673. /**
  66674. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66675. * A Curve3 is designed from a series of successive Vector3.
  66676. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66677. */
  66678. export class Curve3 {
  66679. private _points;
  66680. private _length;
  66681. /**
  66682. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66683. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66684. * @param v1 (Vector3) the control point
  66685. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66686. * @param nbPoints (integer) the wanted number of points in the curve
  66687. * @returns the created Curve3
  66688. */
  66689. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66690. /**
  66691. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66692. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66693. * @param v1 (Vector3) the first control point
  66694. * @param v2 (Vector3) the second control point
  66695. * @param v3 (Vector3) the end point of the Cubic Bezier
  66696. * @param nbPoints (integer) the wanted number of points in the curve
  66697. * @returns the created Curve3
  66698. */
  66699. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66700. /**
  66701. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66702. * @param p1 (Vector3) the origin point of the Hermite Spline
  66703. * @param t1 (Vector3) the tangent vector at the origin point
  66704. * @param p2 (Vector3) the end point of the Hermite Spline
  66705. * @param t2 (Vector3) the tangent vector at the end point
  66706. * @param nbPoints (integer) the wanted number of points in the curve
  66707. * @returns the created Curve3
  66708. */
  66709. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66710. /**
  66711. * Returns a Curve3 object along a CatmullRom Spline curve :
  66712. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66713. * @param nbPoints (integer) the wanted number of points between each curve control points
  66714. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66715. * @returns the created Curve3
  66716. */
  66717. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66718. /**
  66719. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66720. * A Curve3 is designed from a series of successive Vector3.
  66721. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66722. * @param points points which make up the curve
  66723. */
  66724. constructor(points: Vector3[]);
  66725. /**
  66726. * @returns the Curve3 stored array of successive Vector3
  66727. */
  66728. getPoints(): Vector3[];
  66729. /**
  66730. * @returns the computed length (float) of the curve.
  66731. */
  66732. length(): number;
  66733. /**
  66734. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66735. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66736. * curveA and curveB keep unchanged.
  66737. * @param curve the curve to continue from this curve
  66738. * @returns the newly constructed curve
  66739. */
  66740. continue(curve: DeepImmutable<Curve3>): Curve3;
  66741. private _computeLength;
  66742. }
  66743. /**
  66744. * Contains position and normal vectors for a vertex
  66745. */
  66746. export class PositionNormalVertex {
  66747. /** the position of the vertex (defaut: 0,0,0) */
  66748. position: Vector3;
  66749. /** the normal of the vertex (defaut: 0,1,0) */
  66750. normal: Vector3;
  66751. /**
  66752. * Creates a PositionNormalVertex
  66753. * @param position the position of the vertex (defaut: 0,0,0)
  66754. * @param normal the normal of the vertex (defaut: 0,1,0)
  66755. */
  66756. constructor(
  66757. /** the position of the vertex (defaut: 0,0,0) */
  66758. position?: Vector3,
  66759. /** the normal of the vertex (defaut: 0,1,0) */
  66760. normal?: Vector3);
  66761. /**
  66762. * Clones the PositionNormalVertex
  66763. * @returns the cloned PositionNormalVertex
  66764. */
  66765. clone(): PositionNormalVertex;
  66766. }
  66767. /**
  66768. * Contains position, normal and uv vectors for a vertex
  66769. */
  66770. export class PositionNormalTextureVertex {
  66771. /** the position of the vertex (defaut: 0,0,0) */
  66772. position: Vector3;
  66773. /** the normal of the vertex (defaut: 0,1,0) */
  66774. normal: Vector3;
  66775. /** the uv of the vertex (default: 0,0) */
  66776. uv: Vector2;
  66777. /**
  66778. * Creates a PositionNormalTextureVertex
  66779. * @param position the position of the vertex (defaut: 0,0,0)
  66780. * @param normal the normal of the vertex (defaut: 0,1,0)
  66781. * @param uv the uv of the vertex (default: 0,0)
  66782. */
  66783. constructor(
  66784. /** the position of the vertex (defaut: 0,0,0) */
  66785. position?: Vector3,
  66786. /** the normal of the vertex (defaut: 0,1,0) */
  66787. normal?: Vector3,
  66788. /** the uv of the vertex (default: 0,0) */
  66789. uv?: Vector2);
  66790. /**
  66791. * Clones the PositionNormalTextureVertex
  66792. * @returns the cloned PositionNormalTextureVertex
  66793. */
  66794. clone(): PositionNormalTextureVertex;
  66795. }
  66796. /**
  66797. * @hidden
  66798. */
  66799. export class Tmp {
  66800. static Color3: Color3[];
  66801. static Color4: Color4[];
  66802. static Vector2: Vector2[];
  66803. static Vector3: Vector3[];
  66804. static Vector4: Vector4[];
  66805. static Quaternion: Quaternion[];
  66806. static Matrix: Matrix[];
  66807. }
  66808. }
  66809. declare module BABYLON {
  66810. /**
  66811. * Class used to enable access to offline support
  66812. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66813. */
  66814. export interface IOfflineProvider {
  66815. /**
  66816. * Gets a boolean indicating if scene must be saved in the database
  66817. */
  66818. enableSceneOffline: boolean;
  66819. /**
  66820. * Gets a boolean indicating if textures must be saved in the database
  66821. */
  66822. enableTexturesOffline: boolean;
  66823. /**
  66824. * Open the offline support and make it available
  66825. * @param successCallback defines the callback to call on success
  66826. * @param errorCallback defines the callback to call on error
  66827. */
  66828. open(successCallback: () => void, errorCallback: () => void): void;
  66829. /**
  66830. * Loads an image from the offline support
  66831. * @param url defines the url to load from
  66832. * @param image defines the target DOM image
  66833. */
  66834. loadImage(url: string, image: HTMLImageElement): void;
  66835. /**
  66836. * Loads a file from offline support
  66837. * @param url defines the URL to load from
  66838. * @param sceneLoaded defines a callback to call on success
  66839. * @param progressCallBack defines a callback to call when progress changed
  66840. * @param errorCallback defines a callback to call on error
  66841. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66842. */
  66843. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66844. }
  66845. }
  66846. declare module BABYLON {
  66847. /**
  66848. * A class serves as a medium between the observable and its observers
  66849. */
  66850. export class EventState {
  66851. /**
  66852. * Create a new EventState
  66853. * @param mask defines the mask associated with this state
  66854. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66855. * @param target defines the original target of the state
  66856. * @param currentTarget defines the current target of the state
  66857. */
  66858. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66859. /**
  66860. * Initialize the current event state
  66861. * @param mask defines the mask associated with this state
  66862. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66863. * @param target defines the original target of the state
  66864. * @param currentTarget defines the current target of the state
  66865. * @returns the current event state
  66866. */
  66867. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66868. /**
  66869. * An Observer can set this property to true to prevent subsequent observers of being notified
  66870. */
  66871. skipNextObservers: boolean;
  66872. /**
  66873. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66874. */
  66875. mask: number;
  66876. /**
  66877. * The object that originally notified the event
  66878. */
  66879. target?: any;
  66880. /**
  66881. * The current object in the bubbling phase
  66882. */
  66883. currentTarget?: any;
  66884. /**
  66885. * This will be populated with the return value of the last function that was executed.
  66886. * If it is the first function in the callback chain it will be the event data.
  66887. */
  66888. lastReturnValue?: any;
  66889. }
  66890. /**
  66891. * Represent an Observer registered to a given Observable object.
  66892. */
  66893. export class Observer<T> {
  66894. /**
  66895. * Defines the callback to call when the observer is notified
  66896. */
  66897. callback: (eventData: T, eventState: EventState) => void;
  66898. /**
  66899. * Defines the mask of the observer (used to filter notifications)
  66900. */
  66901. mask: number;
  66902. /**
  66903. * Defines the current scope used to restore the JS context
  66904. */
  66905. scope: any;
  66906. /** @hidden */
  66907. _willBeUnregistered: boolean;
  66908. /**
  66909. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66910. */
  66911. unregisterOnNextCall: boolean;
  66912. /**
  66913. * Creates a new observer
  66914. * @param callback defines the callback to call when the observer is notified
  66915. * @param mask defines the mask of the observer (used to filter notifications)
  66916. * @param scope defines the current scope used to restore the JS context
  66917. */
  66918. constructor(
  66919. /**
  66920. * Defines the callback to call when the observer is notified
  66921. */
  66922. callback: (eventData: T, eventState: EventState) => void,
  66923. /**
  66924. * Defines the mask of the observer (used to filter notifications)
  66925. */
  66926. mask: number,
  66927. /**
  66928. * Defines the current scope used to restore the JS context
  66929. */
  66930. scope?: any);
  66931. }
  66932. /**
  66933. * Represent a list of observers registered to multiple Observables object.
  66934. */
  66935. export class MultiObserver<T> {
  66936. private _observers;
  66937. private _observables;
  66938. /**
  66939. * Release associated resources
  66940. */
  66941. dispose(): void;
  66942. /**
  66943. * Raise a callback when one of the observable will notify
  66944. * @param observables defines a list of observables to watch
  66945. * @param callback defines the callback to call on notification
  66946. * @param mask defines the mask used to filter notifications
  66947. * @param scope defines the current scope used to restore the JS context
  66948. * @returns the new MultiObserver
  66949. */
  66950. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66951. }
  66952. /**
  66953. * The Observable class is a simple implementation of the Observable pattern.
  66954. *
  66955. * 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.
  66956. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66957. * 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).
  66958. * 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.
  66959. */
  66960. export class Observable<T> {
  66961. private _observers;
  66962. private _eventState;
  66963. private _onObserverAdded;
  66964. /**
  66965. * Gets the list of observers
  66966. */
  66967. readonly observers: Array<Observer<T>>;
  66968. /**
  66969. * Creates a new observable
  66970. * @param onObserverAdded defines a callback to call when a new observer is added
  66971. */
  66972. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66973. /**
  66974. * Create a new Observer with the specified callback
  66975. * @param callback the callback that will be executed for that Observer
  66976. * @param mask the mask used to filter observers
  66977. * @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.
  66978. * @param scope optional scope for the callback to be called from
  66979. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66980. * @returns the new observer created for the callback
  66981. */
  66982. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66983. /**
  66984. * Create a new Observer with the specified callback and unregisters after the next notification
  66985. * @param callback the callback that will be executed for that Observer
  66986. * @returns the new observer created for the callback
  66987. */
  66988. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66989. /**
  66990. * Remove an Observer from the Observable object
  66991. * @param observer the instance of the Observer to remove
  66992. * @returns false if it doesn't belong to this Observable
  66993. */
  66994. remove(observer: Nullable<Observer<T>>): boolean;
  66995. /**
  66996. * Remove a callback from the Observable object
  66997. * @param callback the callback to remove
  66998. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66999. * @returns false if it doesn't belong to this Observable
  67000. */
  67001. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67002. private _deferUnregister;
  67003. private _remove;
  67004. /**
  67005. * Moves the observable to the top of the observer list making it get called first when notified
  67006. * @param observer the observer to move
  67007. */
  67008. makeObserverTopPriority(observer: Observer<T>): void;
  67009. /**
  67010. * Moves the observable to the bottom of the observer list making it get called last when notified
  67011. * @param observer the observer to move
  67012. */
  67013. makeObserverBottomPriority(observer: Observer<T>): void;
  67014. /**
  67015. * Notify all Observers by calling their respective callback with the given data
  67016. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67017. * @param eventData defines the data to send to all observers
  67018. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67019. * @param target defines the original target of the state
  67020. * @param currentTarget defines the current target of the state
  67021. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67022. */
  67023. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67024. /**
  67025. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67026. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67027. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67028. * and it is crucial that all callbacks will be executed.
  67029. * The order of the callbacks is kept, callbacks are not executed parallel.
  67030. *
  67031. * @param eventData The data to be sent to each callback
  67032. * @param mask is used to filter observers defaults to -1
  67033. * @param target defines the callback target (see EventState)
  67034. * @param currentTarget defines he current object in the bubbling phase
  67035. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67036. */
  67037. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67038. /**
  67039. * Notify a specific observer
  67040. * @param observer defines the observer to notify
  67041. * @param eventData defines the data to be sent to each callback
  67042. * @param mask is used to filter observers defaults to -1
  67043. */
  67044. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67045. /**
  67046. * Gets a boolean indicating if the observable has at least one observer
  67047. * @returns true is the Observable has at least one Observer registered
  67048. */
  67049. hasObservers(): boolean;
  67050. /**
  67051. * Clear the list of observers
  67052. */
  67053. clear(): void;
  67054. /**
  67055. * Clone the current observable
  67056. * @returns a new observable
  67057. */
  67058. clone(): Observable<T>;
  67059. /**
  67060. * Does this observable handles observer registered with a given mask
  67061. * @param mask defines the mask to be tested
  67062. * @return whether or not one observer registered with the given mask is handeled
  67063. **/
  67064. hasSpecificMask(mask?: number): boolean;
  67065. }
  67066. }
  67067. declare module BABYLON {
  67068. /**
  67069. * Class used to help managing file picking and drag'n'drop
  67070. * File Storage
  67071. */
  67072. export class FilesInputStore {
  67073. /**
  67074. * List of files ready to be loaded
  67075. */
  67076. static FilesToLoad: {
  67077. [key: string]: File;
  67078. };
  67079. }
  67080. }
  67081. declare module BABYLON {
  67082. /** Defines the cross module used constants to avoid circular dependncies */
  67083. export class Constants {
  67084. /** Defines that alpha blending is disabled */
  67085. static readonly ALPHA_DISABLE: number;
  67086. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67087. static readonly ALPHA_ADD: number;
  67088. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67089. static readonly ALPHA_COMBINE: number;
  67090. /** Defines that alpha blending to DEST - SRC * DEST */
  67091. static readonly ALPHA_SUBTRACT: number;
  67092. /** Defines that alpha blending to SRC * DEST */
  67093. static readonly ALPHA_MULTIPLY: number;
  67094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67095. static readonly ALPHA_MAXIMIZED: number;
  67096. /** Defines that alpha blending to SRC + DEST */
  67097. static readonly ALPHA_ONEONE: number;
  67098. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67099. static readonly ALPHA_PREMULTIPLIED: number;
  67100. /**
  67101. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67102. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67103. */
  67104. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67105. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67106. static readonly ALPHA_INTERPOLATE: number;
  67107. /**
  67108. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67109. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67110. */
  67111. static readonly ALPHA_SCREENMODE: number;
  67112. /** Defines that the ressource is not delayed*/
  67113. static readonly DELAYLOADSTATE_NONE: number;
  67114. /** Defines that the ressource was successfully delay loaded */
  67115. static readonly DELAYLOADSTATE_LOADED: number;
  67116. /** Defines that the ressource is currently delay loading */
  67117. static readonly DELAYLOADSTATE_LOADING: number;
  67118. /** Defines that the ressource is delayed and has not started loading */
  67119. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67120. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67121. static readonly NEVER: number;
  67122. /** 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 */
  67123. static readonly ALWAYS: number;
  67124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67125. static readonly LESS: number;
  67126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67127. static readonly EQUAL: number;
  67128. /** 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 */
  67129. static readonly LEQUAL: number;
  67130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67131. static readonly GREATER: number;
  67132. /** 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 */
  67133. static readonly GEQUAL: number;
  67134. /** 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 */
  67135. static readonly NOTEQUAL: number;
  67136. /** Passed to stencilOperation to specify that stencil value must be kept */
  67137. static readonly KEEP: number;
  67138. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67139. static readonly REPLACE: number;
  67140. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67141. static readonly INCR: number;
  67142. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67143. static readonly DECR: number;
  67144. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67145. static readonly INVERT: number;
  67146. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67147. static readonly INCR_WRAP: number;
  67148. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67149. static readonly DECR_WRAP: number;
  67150. /** Texture is not repeating outside of 0..1 UVs */
  67151. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67152. /** Texture is repeating outside of 0..1 UVs */
  67153. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67154. /** Texture is repeating and mirrored */
  67155. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67156. /** ALPHA */
  67157. static readonly TEXTUREFORMAT_ALPHA: number;
  67158. /** LUMINANCE */
  67159. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67160. /** LUMINANCE_ALPHA */
  67161. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67162. /** RGB */
  67163. static readonly TEXTUREFORMAT_RGB: number;
  67164. /** RGBA */
  67165. static readonly TEXTUREFORMAT_RGBA: number;
  67166. /** RED */
  67167. static readonly TEXTUREFORMAT_RED: number;
  67168. /** RED (2nd reference) */
  67169. static readonly TEXTUREFORMAT_R: number;
  67170. /** RG */
  67171. static readonly TEXTUREFORMAT_RG: number;
  67172. /** RED_INTEGER */
  67173. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67174. /** RED_INTEGER (2nd reference) */
  67175. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67176. /** RG_INTEGER */
  67177. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67178. /** RGB_INTEGER */
  67179. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67180. /** RGBA_INTEGER */
  67181. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67182. /** UNSIGNED_BYTE */
  67183. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67184. /** UNSIGNED_BYTE (2nd reference) */
  67185. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67186. /** FLOAT */
  67187. static readonly TEXTURETYPE_FLOAT: number;
  67188. /** HALF_FLOAT */
  67189. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67190. /** BYTE */
  67191. static readonly TEXTURETYPE_BYTE: number;
  67192. /** SHORT */
  67193. static readonly TEXTURETYPE_SHORT: number;
  67194. /** UNSIGNED_SHORT */
  67195. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67196. /** INT */
  67197. static readonly TEXTURETYPE_INT: number;
  67198. /** UNSIGNED_INT */
  67199. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67200. /** UNSIGNED_SHORT_4_4_4_4 */
  67201. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67202. /** UNSIGNED_SHORT_5_5_5_1 */
  67203. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67204. /** UNSIGNED_SHORT_5_6_5 */
  67205. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67206. /** UNSIGNED_INT_2_10_10_10_REV */
  67207. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67208. /** UNSIGNED_INT_24_8 */
  67209. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67210. /** UNSIGNED_INT_10F_11F_11F_REV */
  67211. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67212. /** UNSIGNED_INT_5_9_9_9_REV */
  67213. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67214. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67215. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67216. /** nearest is mag = nearest and min = nearest and mip = linear */
  67217. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67219. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67220. /** Trilinear is mag = linear and min = linear and mip = linear */
  67221. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67222. /** nearest is mag = nearest and min = nearest and mip = linear */
  67223. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67225. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67226. /** Trilinear is mag = linear and min = linear and mip = linear */
  67227. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67228. /** mag = nearest and min = nearest and mip = nearest */
  67229. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67230. /** mag = nearest and min = linear and mip = nearest */
  67231. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67232. /** mag = nearest and min = linear and mip = linear */
  67233. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67234. /** mag = nearest and min = linear and mip = none */
  67235. static readonly TEXTURE_NEAREST_LINEAR: number;
  67236. /** mag = nearest and min = nearest and mip = none */
  67237. static readonly TEXTURE_NEAREST_NEAREST: number;
  67238. /** mag = linear and min = nearest and mip = nearest */
  67239. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67240. /** mag = linear and min = nearest and mip = linear */
  67241. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67242. /** mag = linear and min = linear and mip = none */
  67243. static readonly TEXTURE_LINEAR_LINEAR: number;
  67244. /** mag = linear and min = nearest and mip = none */
  67245. static readonly TEXTURE_LINEAR_NEAREST: number;
  67246. /** Explicit coordinates mode */
  67247. static readonly TEXTURE_EXPLICIT_MODE: number;
  67248. /** Spherical coordinates mode */
  67249. static readonly TEXTURE_SPHERICAL_MODE: number;
  67250. /** Planar coordinates mode */
  67251. static readonly TEXTURE_PLANAR_MODE: number;
  67252. /** Cubic coordinates mode */
  67253. static readonly TEXTURE_CUBIC_MODE: number;
  67254. /** Projection coordinates mode */
  67255. static readonly TEXTURE_PROJECTION_MODE: number;
  67256. /** Skybox coordinates mode */
  67257. static readonly TEXTURE_SKYBOX_MODE: number;
  67258. /** Inverse Cubic coordinates mode */
  67259. static readonly TEXTURE_INVCUBIC_MODE: number;
  67260. /** Equirectangular coordinates mode */
  67261. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67262. /** Equirectangular Fixed coordinates mode */
  67263. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67264. /** Equirectangular Fixed Mirrored coordinates mode */
  67265. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67266. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67267. static readonly SCALEMODE_FLOOR: number;
  67268. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67269. static readonly SCALEMODE_NEAREST: number;
  67270. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67271. static readonly SCALEMODE_CEILING: number;
  67272. /**
  67273. * The dirty texture flag value
  67274. */
  67275. static readonly MATERIAL_TextureDirtyFlag: number;
  67276. /**
  67277. * The dirty light flag value
  67278. */
  67279. static readonly MATERIAL_LightDirtyFlag: number;
  67280. /**
  67281. * The dirty fresnel flag value
  67282. */
  67283. static readonly MATERIAL_FresnelDirtyFlag: number;
  67284. /**
  67285. * The dirty attribute flag value
  67286. */
  67287. static readonly MATERIAL_AttributesDirtyFlag: number;
  67288. /**
  67289. * The dirty misc flag value
  67290. */
  67291. static readonly MATERIAL_MiscDirtyFlag: number;
  67292. /**
  67293. * The all dirty flag value
  67294. */
  67295. static readonly MATERIAL_AllDirtyFlag: number;
  67296. /**
  67297. * Returns the triangle fill mode
  67298. */
  67299. static readonly MATERIAL_TriangleFillMode: number;
  67300. /**
  67301. * Returns the wireframe mode
  67302. */
  67303. static readonly MATERIAL_WireFrameFillMode: number;
  67304. /**
  67305. * Returns the point fill mode
  67306. */
  67307. static readonly MATERIAL_PointFillMode: number;
  67308. /**
  67309. * Returns the point list draw mode
  67310. */
  67311. static readonly MATERIAL_PointListDrawMode: number;
  67312. /**
  67313. * Returns the line list draw mode
  67314. */
  67315. static readonly MATERIAL_LineListDrawMode: number;
  67316. /**
  67317. * Returns the line loop draw mode
  67318. */
  67319. static readonly MATERIAL_LineLoopDrawMode: number;
  67320. /**
  67321. * Returns the line strip draw mode
  67322. */
  67323. static readonly MATERIAL_LineStripDrawMode: number;
  67324. /**
  67325. * Returns the triangle strip draw mode
  67326. */
  67327. static readonly MATERIAL_TriangleStripDrawMode: number;
  67328. /**
  67329. * Returns the triangle fan draw mode
  67330. */
  67331. static readonly MATERIAL_TriangleFanDrawMode: number;
  67332. /**
  67333. * Stores the clock-wise side orientation
  67334. */
  67335. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67336. /**
  67337. * Stores the counter clock-wise side orientation
  67338. */
  67339. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67340. /**
  67341. * Nothing
  67342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67343. */
  67344. static readonly ACTION_NothingTrigger: number;
  67345. /**
  67346. * On pick
  67347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67348. */
  67349. static readonly ACTION_OnPickTrigger: number;
  67350. /**
  67351. * On left pick
  67352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67353. */
  67354. static readonly ACTION_OnLeftPickTrigger: number;
  67355. /**
  67356. * On right pick
  67357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67358. */
  67359. static readonly ACTION_OnRightPickTrigger: number;
  67360. /**
  67361. * On center pick
  67362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67363. */
  67364. static readonly ACTION_OnCenterPickTrigger: number;
  67365. /**
  67366. * On pick down
  67367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67368. */
  67369. static readonly ACTION_OnPickDownTrigger: number;
  67370. /**
  67371. * On double pick
  67372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67373. */
  67374. static readonly ACTION_OnDoublePickTrigger: number;
  67375. /**
  67376. * On pick up
  67377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67378. */
  67379. static readonly ACTION_OnPickUpTrigger: number;
  67380. /**
  67381. * On pick out.
  67382. * This trigger will only be raised if you also declared a OnPickDown
  67383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67384. */
  67385. static readonly ACTION_OnPickOutTrigger: number;
  67386. /**
  67387. * On long press
  67388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67389. */
  67390. static readonly ACTION_OnLongPressTrigger: number;
  67391. /**
  67392. * On pointer over
  67393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67394. */
  67395. static readonly ACTION_OnPointerOverTrigger: number;
  67396. /**
  67397. * On pointer out
  67398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67399. */
  67400. static readonly ACTION_OnPointerOutTrigger: number;
  67401. /**
  67402. * On every frame
  67403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67404. */
  67405. static readonly ACTION_OnEveryFrameTrigger: number;
  67406. /**
  67407. * On intersection enter
  67408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67409. */
  67410. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67411. /**
  67412. * On intersection exit
  67413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67414. */
  67415. static readonly ACTION_OnIntersectionExitTrigger: number;
  67416. /**
  67417. * On key down
  67418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67419. */
  67420. static readonly ACTION_OnKeyDownTrigger: number;
  67421. /**
  67422. * On key up
  67423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67424. */
  67425. static readonly ACTION_OnKeyUpTrigger: number;
  67426. /**
  67427. * Billboard mode will only apply to Y axis
  67428. */
  67429. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67430. /**
  67431. * Billboard mode will apply to all axes
  67432. */
  67433. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67434. /**
  67435. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67436. */
  67437. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67438. /**
  67439. * Gets or sets base Assets URL
  67440. */
  67441. static PARTICLES_BaseAssetsUrl: string;
  67442. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67443. * Test order :
  67444. * Is the bounding sphere outside the frustum ?
  67445. * If not, are the bounding box vertices outside the frustum ?
  67446. * It not, then the cullable object is in the frustum.
  67447. */
  67448. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67449. /** Culling strategy : Bounding Sphere Only.
  67450. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67451. * It's also less accurate than the standard because some not visible objects can still be selected.
  67452. * Test : is the bounding sphere outside the frustum ?
  67453. * If not, then the cullable object is in the frustum.
  67454. */
  67455. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67456. /** Culling strategy : Optimistic Inclusion.
  67457. * This in an inclusion test first, then the standard exclusion test.
  67458. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67459. * 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.
  67460. * Anyway, it's as accurate as the standard strategy.
  67461. * Test :
  67462. * Is the cullable object bounding sphere center in the frustum ?
  67463. * If not, apply the default culling strategy.
  67464. */
  67465. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67466. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67467. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67468. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67469. * 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.
  67470. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67471. * Test :
  67472. * Is the cullable object bounding sphere center in the frustum ?
  67473. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67474. */
  67475. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67476. /**
  67477. * No logging while loading
  67478. */
  67479. static readonly SCENELOADER_NO_LOGGING: number;
  67480. /**
  67481. * Minimal logging while loading
  67482. */
  67483. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67484. /**
  67485. * Summary logging while loading
  67486. */
  67487. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67488. /**
  67489. * Detailled logging while loading
  67490. */
  67491. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /**
  67496. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67497. * Babylon.js
  67498. */
  67499. export class DomManagement {
  67500. /**
  67501. * Checks if the window object exists
  67502. * @returns true if the window object exists
  67503. */
  67504. static IsWindowObjectExist(): boolean;
  67505. /**
  67506. * Extracts text content from a DOM element hierarchy
  67507. * @param element defines the root element
  67508. * @returns a string
  67509. */
  67510. static GetDOMTextContent(element: HTMLElement): string;
  67511. }
  67512. }
  67513. declare module BABYLON {
  67514. /**
  67515. * Logger used througouht the application to allow configuration of
  67516. * the log level required for the messages.
  67517. */
  67518. export class Logger {
  67519. /**
  67520. * No log
  67521. */
  67522. static readonly NoneLogLevel: number;
  67523. /**
  67524. * Only message logs
  67525. */
  67526. static readonly MessageLogLevel: number;
  67527. /**
  67528. * Only warning logs
  67529. */
  67530. static readonly WarningLogLevel: number;
  67531. /**
  67532. * Only error logs
  67533. */
  67534. static readonly ErrorLogLevel: number;
  67535. /**
  67536. * All logs
  67537. */
  67538. static readonly AllLogLevel: number;
  67539. private static _LogCache;
  67540. /**
  67541. * Gets a value indicating the number of loading errors
  67542. * @ignorenaming
  67543. */
  67544. static errorsCount: number;
  67545. /**
  67546. * Callback called when a new log is added
  67547. */
  67548. static OnNewCacheEntry: (entry: string) => void;
  67549. private static _AddLogEntry;
  67550. private static _FormatMessage;
  67551. private static _LogDisabled;
  67552. private static _LogEnabled;
  67553. private static _WarnDisabled;
  67554. private static _WarnEnabled;
  67555. private static _ErrorDisabled;
  67556. private static _ErrorEnabled;
  67557. /**
  67558. * Log a message to the console
  67559. */
  67560. static Log: (message: string) => void;
  67561. /**
  67562. * Write a warning message to the console
  67563. */
  67564. static Warn: (message: string) => void;
  67565. /**
  67566. * Write an error message to the console
  67567. */
  67568. static Error: (message: string) => void;
  67569. /**
  67570. * Gets current log cache (list of logs)
  67571. */
  67572. static readonly LogCache: string;
  67573. /**
  67574. * Clears the log cache
  67575. */
  67576. static ClearLogCache(): void;
  67577. /**
  67578. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67579. */
  67580. static LogLevels: number;
  67581. }
  67582. }
  67583. declare module BABYLON {
  67584. /** @hidden */
  67585. export class _TypeStore {
  67586. /** @hidden */
  67587. static RegisteredTypes: {
  67588. [key: string]: Object;
  67589. };
  67590. /** @hidden */
  67591. static GetClass(fqdn: string): any;
  67592. }
  67593. }
  67594. declare module BABYLON {
  67595. /**
  67596. * Class containing a set of static utilities functions for deep copy.
  67597. */
  67598. export class DeepCopier {
  67599. /**
  67600. * Tries to copy an object by duplicating every property
  67601. * @param source defines the source object
  67602. * @param destination defines the target object
  67603. * @param doNotCopyList defines a list of properties to avoid
  67604. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67605. */
  67606. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67607. }
  67608. }
  67609. declare module BABYLON {
  67610. /**
  67611. * Class containing a set of static utilities functions for precision date
  67612. */
  67613. export class PrecisionDate {
  67614. /**
  67615. * Gets either window.performance.now() if supported or Date.now() else
  67616. */
  67617. static readonly Now: number;
  67618. }
  67619. }
  67620. declare module BABYLON {
  67621. /** @hidden */
  67622. export class _DevTools {
  67623. static WarnImport(name: string): string;
  67624. }
  67625. }
  67626. declare module BABYLON {
  67627. /**
  67628. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67629. */
  67630. export class WebRequest {
  67631. private _xhr;
  67632. /**
  67633. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67634. * i.e. when loading files, where the server/service expects an Authorization header
  67635. */
  67636. static CustomRequestHeaders: {
  67637. [key: string]: string;
  67638. };
  67639. /**
  67640. * Add callback functions in this array to update all the requests before they get sent to the network
  67641. */
  67642. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67643. private _injectCustomRequestHeaders;
  67644. /**
  67645. * Gets or sets a function to be called when loading progress changes
  67646. */
  67647. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67648. /**
  67649. * Returns client's state
  67650. */
  67651. readonly readyState: number;
  67652. /**
  67653. * Returns client's status
  67654. */
  67655. readonly status: number;
  67656. /**
  67657. * Returns client's status as a text
  67658. */
  67659. readonly statusText: string;
  67660. /**
  67661. * Returns client's response
  67662. */
  67663. readonly response: any;
  67664. /**
  67665. * Returns client's response url
  67666. */
  67667. readonly responseURL: string;
  67668. /**
  67669. * Returns client's response as text
  67670. */
  67671. readonly responseText: string;
  67672. /**
  67673. * Gets or sets the expected response type
  67674. */
  67675. responseType: XMLHttpRequestResponseType;
  67676. /** @hidden */
  67677. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67678. /** @hidden */
  67679. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67680. /**
  67681. * Cancels any network activity
  67682. */
  67683. abort(): void;
  67684. /**
  67685. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67686. * @param body defines an optional request body
  67687. */
  67688. send(body?: Document | BodyInit | null): void;
  67689. /**
  67690. * Sets the request method, request URL
  67691. * @param method defines the method to use (GET, POST, etc..)
  67692. * @param url defines the url to connect with
  67693. */
  67694. open(method: string, url: string): void;
  67695. }
  67696. }
  67697. declare module BABYLON {
  67698. /**
  67699. * Class used to evalaute queries containing `and` and `or` operators
  67700. */
  67701. export class AndOrNotEvaluator {
  67702. /**
  67703. * Evaluate a query
  67704. * @param query defines the query to evaluate
  67705. * @param evaluateCallback defines the callback used to filter result
  67706. * @returns true if the query matches
  67707. */
  67708. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67709. private static _HandleParenthesisContent;
  67710. private static _SimplifyNegation;
  67711. }
  67712. }
  67713. declare module BABYLON {
  67714. /**
  67715. * Class used to store custom tags
  67716. */
  67717. export class Tags {
  67718. /**
  67719. * Adds support for tags on the given object
  67720. * @param obj defines the object to use
  67721. */
  67722. static EnableFor(obj: any): void;
  67723. /**
  67724. * Removes tags support
  67725. * @param obj defines the object to use
  67726. */
  67727. static DisableFor(obj: any): void;
  67728. /**
  67729. * Gets a boolean indicating if the given object has tags
  67730. * @param obj defines the object to use
  67731. * @returns a boolean
  67732. */
  67733. static HasTags(obj: any): boolean;
  67734. /**
  67735. * Gets the tags available on a given object
  67736. * @param obj defines the object to use
  67737. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67738. * @returns the tags
  67739. */
  67740. static GetTags(obj: any, asString?: boolean): any;
  67741. /**
  67742. * Adds tags to an object
  67743. * @param obj defines the object to use
  67744. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67745. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67746. */
  67747. static AddTagsTo(obj: any, tagsString: string): void;
  67748. /**
  67749. * @hidden
  67750. */
  67751. static _AddTagTo(obj: any, tag: string): void;
  67752. /**
  67753. * Removes specific tags from a specific object
  67754. * @param obj defines the object to use
  67755. * @param tagsString defines the tags to remove
  67756. */
  67757. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67758. /**
  67759. * @hidden
  67760. */
  67761. static _RemoveTagFrom(obj: any, tag: string): void;
  67762. /**
  67763. * Defines if tags hosted on an object match a given query
  67764. * @param obj defines the object to use
  67765. * @param tagsQuery defines the tag query
  67766. * @returns a boolean
  67767. */
  67768. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67769. }
  67770. }
  67771. declare module BABYLON {
  67772. /**
  67773. * Manages the defines for the Material
  67774. */
  67775. export class MaterialDefines {
  67776. /** @hidden */
  67777. protected _keys: string[];
  67778. private _isDirty;
  67779. /** @hidden */
  67780. _renderId: number;
  67781. /** @hidden */
  67782. _areLightsDirty: boolean;
  67783. /** @hidden */
  67784. _areAttributesDirty: boolean;
  67785. /** @hidden */
  67786. _areTexturesDirty: boolean;
  67787. /** @hidden */
  67788. _areFresnelDirty: boolean;
  67789. /** @hidden */
  67790. _areMiscDirty: boolean;
  67791. /** @hidden */
  67792. _areImageProcessingDirty: boolean;
  67793. /** @hidden */
  67794. _normals: boolean;
  67795. /** @hidden */
  67796. _uvs: boolean;
  67797. /** @hidden */
  67798. _needNormals: boolean;
  67799. /** @hidden */
  67800. _needUVs: boolean;
  67801. [id: string]: any;
  67802. /**
  67803. * Specifies if the material needs to be re-calculated
  67804. */
  67805. readonly isDirty: boolean;
  67806. /**
  67807. * Marks the material to indicate that it has been re-calculated
  67808. */
  67809. markAsProcessed(): void;
  67810. /**
  67811. * Marks the material to indicate that it needs to be re-calculated
  67812. */
  67813. markAsUnprocessed(): void;
  67814. /**
  67815. * Marks the material to indicate all of its defines need to be re-calculated
  67816. */
  67817. markAllAsDirty(): void;
  67818. /**
  67819. * Marks the material to indicate that image processing needs to be re-calculated
  67820. */
  67821. markAsImageProcessingDirty(): void;
  67822. /**
  67823. * Marks the material to indicate the lights need to be re-calculated
  67824. */
  67825. markAsLightDirty(): void;
  67826. /**
  67827. * Marks the attribute state as changed
  67828. */
  67829. markAsAttributesDirty(): void;
  67830. /**
  67831. * Marks the texture state as changed
  67832. */
  67833. markAsTexturesDirty(): void;
  67834. /**
  67835. * Marks the fresnel state as changed
  67836. */
  67837. markAsFresnelDirty(): void;
  67838. /**
  67839. * Marks the misc state as changed
  67840. */
  67841. markAsMiscDirty(): void;
  67842. /**
  67843. * Rebuilds the material defines
  67844. */
  67845. rebuild(): void;
  67846. /**
  67847. * Specifies if two material defines are equal
  67848. * @param other - A material define instance to compare to
  67849. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67850. */
  67851. isEqual(other: MaterialDefines): boolean;
  67852. /**
  67853. * Clones this instance's defines to another instance
  67854. * @param other - material defines to clone values to
  67855. */
  67856. cloneTo(other: MaterialDefines): void;
  67857. /**
  67858. * Resets the material define values
  67859. */
  67860. reset(): void;
  67861. /**
  67862. * Converts the material define values to a string
  67863. * @returns - String of material define information
  67864. */
  67865. toString(): string;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /**
  67870. * Class used to store and describe the pipeline context associated with an effect
  67871. */
  67872. export interface IPipelineContext {
  67873. /**
  67874. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67875. */
  67876. isAsync: boolean;
  67877. /**
  67878. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67879. */
  67880. isReady: boolean;
  67881. /** @hidden */
  67882. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67883. }
  67884. }
  67885. declare module BABYLON {
  67886. /**
  67887. * Class used to store gfx data (like WebGLBuffer)
  67888. */
  67889. export class DataBuffer {
  67890. /**
  67891. * Gets or sets the number of objects referencing this buffer
  67892. */
  67893. references: number;
  67894. /** Gets or sets the size of the underlying buffer */
  67895. capacity: number;
  67896. /**
  67897. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67898. */
  67899. is32Bits: boolean;
  67900. /**
  67901. * Gets the underlying buffer
  67902. */
  67903. readonly underlyingResource: any;
  67904. }
  67905. }
  67906. declare module BABYLON {
  67907. /** @hidden */
  67908. export interface IShaderProcessor {
  67909. attributeProcessor?: (attribute: string) => string;
  67910. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67911. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67912. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67913. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67914. lineProcessor?: (line: string, isFragment: boolean) => string;
  67915. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67916. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /** @hidden */
  67921. export interface ProcessingOptions {
  67922. defines: string[];
  67923. indexParameters: any;
  67924. isFragment: boolean;
  67925. shouldUseHighPrecisionShader: boolean;
  67926. supportsUniformBuffers: boolean;
  67927. shadersRepository: string;
  67928. includesShadersStore: {
  67929. [key: string]: string;
  67930. };
  67931. processor?: IShaderProcessor;
  67932. version: string;
  67933. platformName: string;
  67934. lookForClosingBracketForUniformBuffer?: boolean;
  67935. }
  67936. }
  67937. declare module BABYLON {
  67938. /** @hidden */
  67939. export class ShaderCodeNode {
  67940. line: string;
  67941. children: ShaderCodeNode[];
  67942. additionalDefineKey?: string;
  67943. additionalDefineValue?: string;
  67944. isValid(preprocessors: {
  67945. [key: string]: string;
  67946. }): boolean;
  67947. process(preprocessors: {
  67948. [key: string]: string;
  67949. }, options: ProcessingOptions): string;
  67950. }
  67951. }
  67952. declare module BABYLON {
  67953. /** @hidden */
  67954. export class ShaderCodeCursor {
  67955. private _lines;
  67956. lineIndex: number;
  67957. readonly currentLine: string;
  67958. readonly canRead: boolean;
  67959. lines: string[];
  67960. }
  67961. }
  67962. declare module BABYLON {
  67963. /** @hidden */
  67964. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67965. process(preprocessors: {
  67966. [key: string]: string;
  67967. }, options: ProcessingOptions): string;
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export class ShaderDefineExpression {
  67973. isTrue(preprocessors: {
  67974. [key: string]: string;
  67975. }): boolean;
  67976. }
  67977. }
  67978. declare module BABYLON {
  67979. /** @hidden */
  67980. export class ShaderCodeTestNode extends ShaderCodeNode {
  67981. testExpression: ShaderDefineExpression;
  67982. isValid(preprocessors: {
  67983. [key: string]: string;
  67984. }): boolean;
  67985. }
  67986. }
  67987. declare module BABYLON {
  67988. /** @hidden */
  67989. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67990. define: string;
  67991. not: boolean;
  67992. constructor(define: string, not?: boolean);
  67993. isTrue(preprocessors: {
  67994. [key: string]: string;
  67995. }): boolean;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /** @hidden */
  68000. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68001. leftOperand: ShaderDefineExpression;
  68002. rightOperand: ShaderDefineExpression;
  68003. isTrue(preprocessors: {
  68004. [key: string]: string;
  68005. }): boolean;
  68006. }
  68007. }
  68008. declare module BABYLON {
  68009. /** @hidden */
  68010. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68011. leftOperand: ShaderDefineExpression;
  68012. rightOperand: ShaderDefineExpression;
  68013. isTrue(preprocessors: {
  68014. [key: string]: string;
  68015. }): boolean;
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68021. define: string;
  68022. operand: string;
  68023. testValue: string;
  68024. constructor(define: string, operand: string, testValue: string);
  68025. isTrue(preprocessors: {
  68026. [key: string]: string;
  68027. }): boolean;
  68028. }
  68029. }
  68030. declare module BABYLON {
  68031. /** @hidden */
  68032. export class ShaderProcessor {
  68033. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68034. private static _ProcessPrecision;
  68035. private static _ExtractOperation;
  68036. private static _BuildSubExpression;
  68037. private static _BuildExpression;
  68038. private static _MoveCursorWithinIf;
  68039. private static _MoveCursor;
  68040. private static _EvaluatePreProcessors;
  68041. private static _PreparePreProcessors;
  68042. private static _ProcessShaderConversion;
  68043. private static _ProcessIncludes;
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /**
  68048. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68049. */
  68050. export class PerformanceMonitor {
  68051. private _enabled;
  68052. private _rollingFrameTime;
  68053. private _lastFrameTimeMs;
  68054. /**
  68055. * constructor
  68056. * @param frameSampleSize The number of samples required to saturate the sliding window
  68057. */
  68058. constructor(frameSampleSize?: number);
  68059. /**
  68060. * Samples current frame
  68061. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68062. */
  68063. sampleFrame(timeMs?: number): void;
  68064. /**
  68065. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68066. */
  68067. readonly averageFrameTime: number;
  68068. /**
  68069. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68070. */
  68071. readonly averageFrameTimeVariance: number;
  68072. /**
  68073. * Returns the frame time of the most recent frame
  68074. */
  68075. readonly instantaneousFrameTime: number;
  68076. /**
  68077. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68078. */
  68079. readonly averageFPS: number;
  68080. /**
  68081. * Returns the average framerate in frames per second using the most recent frame time
  68082. */
  68083. readonly instantaneousFPS: number;
  68084. /**
  68085. * Returns true if enough samples have been taken to completely fill the sliding window
  68086. */
  68087. readonly isSaturated: boolean;
  68088. /**
  68089. * Enables contributions to the sliding window sample set
  68090. */
  68091. enable(): void;
  68092. /**
  68093. * Disables contributions to the sliding window sample set
  68094. * Samples will not be interpolated over the disabled period
  68095. */
  68096. disable(): void;
  68097. /**
  68098. * Returns true if sampling is enabled
  68099. */
  68100. readonly isEnabled: boolean;
  68101. /**
  68102. * Resets performance monitor
  68103. */
  68104. reset(): void;
  68105. }
  68106. /**
  68107. * RollingAverage
  68108. *
  68109. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68110. */
  68111. export class RollingAverage {
  68112. /**
  68113. * Current average
  68114. */
  68115. average: number;
  68116. /**
  68117. * Current variance
  68118. */
  68119. variance: number;
  68120. protected _samples: Array<number>;
  68121. protected _sampleCount: number;
  68122. protected _pos: number;
  68123. protected _m2: number;
  68124. /**
  68125. * constructor
  68126. * @param length The number of samples required to saturate the sliding window
  68127. */
  68128. constructor(length: number);
  68129. /**
  68130. * Adds a sample to the sample set
  68131. * @param v The sample value
  68132. */
  68133. add(v: number): void;
  68134. /**
  68135. * Returns previously added values or null if outside of history or outside the sliding window domain
  68136. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68137. * @return Value previously recorded with add() or null if outside of range
  68138. */
  68139. history(i: number): number;
  68140. /**
  68141. * Returns true if enough samples have been taken to completely fill the sliding window
  68142. * @return true if sample-set saturated
  68143. */
  68144. isSaturated(): boolean;
  68145. /**
  68146. * Resets the rolling average (equivalent to 0 samples taken so far)
  68147. */
  68148. reset(): void;
  68149. /**
  68150. * Wraps a value around the sample range boundaries
  68151. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68152. * @return Wrapped position in sample range
  68153. */
  68154. protected _wrapPosition(i: number): number;
  68155. }
  68156. }
  68157. declare module BABYLON {
  68158. /**
  68159. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68160. * The underlying implementation relies on an associative array to ensure the best performances.
  68161. * The value can be anything including 'null' but except 'undefined'
  68162. */
  68163. export class StringDictionary<T> {
  68164. /**
  68165. * This will clear this dictionary and copy the content from the 'source' one.
  68166. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68167. * @param source the dictionary to take the content from and copy to this dictionary
  68168. */
  68169. copyFrom(source: StringDictionary<T>): void;
  68170. /**
  68171. * Get a value based from its key
  68172. * @param key the given key to get the matching value from
  68173. * @return the value if found, otherwise undefined is returned
  68174. */
  68175. get(key: string): T | undefined;
  68176. /**
  68177. * Get a value from its key or add it if it doesn't exist.
  68178. * This method will ensure you that a given key/data will be present in the dictionary.
  68179. * @param key the given key to get the matching value from
  68180. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68181. * The factory will only be invoked if there's no data for the given key.
  68182. * @return the value corresponding to the key.
  68183. */
  68184. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68185. /**
  68186. * Get a value from its key if present in the dictionary otherwise add it
  68187. * @param key the key to get the value from
  68188. * @param val if there's no such key/value pair in the dictionary add it with this value
  68189. * @return the value corresponding to the key
  68190. */
  68191. getOrAdd(key: string, val: T): T;
  68192. /**
  68193. * Check if there's a given key in the dictionary
  68194. * @param key the key to check for
  68195. * @return true if the key is present, false otherwise
  68196. */
  68197. contains(key: string): boolean;
  68198. /**
  68199. * Add a new key and its corresponding value
  68200. * @param key the key to add
  68201. * @param value the value corresponding to the key
  68202. * @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
  68203. */
  68204. add(key: string, value: T): boolean;
  68205. /**
  68206. * Update a specific value associated to a key
  68207. * @param key defines the key to use
  68208. * @param value defines the value to store
  68209. * @returns true if the value was updated (or false if the key was not found)
  68210. */
  68211. set(key: string, value: T): boolean;
  68212. /**
  68213. * Get the element of the given key and remove it from the dictionary
  68214. * @param key defines the key to search
  68215. * @returns the value associated with the key or null if not found
  68216. */
  68217. getAndRemove(key: string): Nullable<T>;
  68218. /**
  68219. * Remove a key/value from the dictionary.
  68220. * @param key the key to remove
  68221. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68222. */
  68223. remove(key: string): boolean;
  68224. /**
  68225. * Clear the whole content of the dictionary
  68226. */
  68227. clear(): void;
  68228. /**
  68229. * Gets the current count
  68230. */
  68231. readonly count: number;
  68232. /**
  68233. * Execute a callback on each key/val of the dictionary.
  68234. * Note that you can remove any element in this dictionary in the callback implementation
  68235. * @param callback the callback to execute on a given key/value pair
  68236. */
  68237. forEach(callback: (key: string, val: T) => void): void;
  68238. /**
  68239. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68240. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68241. * Note that you can remove any element in this dictionary in the callback implementation
  68242. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68243. * @returns the first item
  68244. */
  68245. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68246. private _count;
  68247. private _data;
  68248. }
  68249. }
  68250. declare module BABYLON {
  68251. /**
  68252. * Helper class that provides a small promise polyfill
  68253. */
  68254. export class PromisePolyfill {
  68255. /**
  68256. * Static function used to check if the polyfill is required
  68257. * If this is the case then the function will inject the polyfill to window.Promise
  68258. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68259. */
  68260. static Apply(force?: boolean): void;
  68261. }
  68262. }
  68263. declare module BABYLON {
  68264. /**
  68265. * Class used to store data that will be store in GPU memory
  68266. */
  68267. export class Buffer {
  68268. private _engine;
  68269. private _buffer;
  68270. /** @hidden */
  68271. _data: Nullable<DataArray>;
  68272. private _updatable;
  68273. private _instanced;
  68274. /**
  68275. * Gets the byte stride.
  68276. */
  68277. readonly byteStride: number;
  68278. /**
  68279. * Constructor
  68280. * @param engine the engine
  68281. * @param data the data to use for this buffer
  68282. * @param updatable whether the data is updatable
  68283. * @param stride the stride (optional)
  68284. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68285. * @param instanced whether the buffer is instanced (optional)
  68286. * @param useBytes set to true if the stride in in bytes (optional)
  68287. */
  68288. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68289. /**
  68290. * Create a new VertexBuffer based on the current buffer
  68291. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68292. * @param offset defines offset in the buffer (0 by default)
  68293. * @param size defines the size in floats of attributes (position is 3 for instance)
  68294. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68295. * @param instanced defines if the vertex buffer contains indexed data
  68296. * @param useBytes defines if the offset and stride are in bytes
  68297. * @returns the new vertex buffer
  68298. */
  68299. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68300. /**
  68301. * Gets a boolean indicating if the Buffer is updatable?
  68302. * @returns true if the buffer is updatable
  68303. */
  68304. isUpdatable(): boolean;
  68305. /**
  68306. * Gets current buffer's data
  68307. * @returns a DataArray or null
  68308. */
  68309. getData(): Nullable<DataArray>;
  68310. /**
  68311. * Gets underlying native buffer
  68312. * @returns underlying native buffer
  68313. */
  68314. getBuffer(): Nullable<DataBuffer>;
  68315. /**
  68316. * Gets the stride in float32 units (i.e. byte stride / 4).
  68317. * May not be an integer if the byte stride is not divisible by 4.
  68318. * DEPRECATED. Use byteStride instead.
  68319. * @returns the stride in float32 units
  68320. */
  68321. getStrideSize(): number;
  68322. /**
  68323. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68324. * @param data defines the data to store
  68325. */
  68326. create(data?: Nullable<DataArray>): void;
  68327. /** @hidden */
  68328. _rebuild(): void;
  68329. /**
  68330. * Update current buffer data
  68331. * @param data defines the data to store
  68332. */
  68333. update(data: DataArray): void;
  68334. /**
  68335. * Updates the data directly.
  68336. * @param data the new data
  68337. * @param offset the new offset
  68338. * @param vertexCount the vertex count (optional)
  68339. * @param useBytes set to true if the offset is in bytes
  68340. */
  68341. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68342. /**
  68343. * Release all resources
  68344. */
  68345. dispose(): void;
  68346. }
  68347. /**
  68348. * Specialized buffer used to store vertex data
  68349. */
  68350. export class VertexBuffer {
  68351. /** @hidden */
  68352. _buffer: Buffer;
  68353. private _kind;
  68354. private _size;
  68355. private _ownsBuffer;
  68356. private _instanced;
  68357. private _instanceDivisor;
  68358. /**
  68359. * The byte type.
  68360. */
  68361. static readonly BYTE: number;
  68362. /**
  68363. * The unsigned byte type.
  68364. */
  68365. static readonly UNSIGNED_BYTE: number;
  68366. /**
  68367. * The short type.
  68368. */
  68369. static readonly SHORT: number;
  68370. /**
  68371. * The unsigned short type.
  68372. */
  68373. static readonly UNSIGNED_SHORT: number;
  68374. /**
  68375. * The integer type.
  68376. */
  68377. static readonly INT: number;
  68378. /**
  68379. * The unsigned integer type.
  68380. */
  68381. static readonly UNSIGNED_INT: number;
  68382. /**
  68383. * The float type.
  68384. */
  68385. static readonly FLOAT: number;
  68386. /**
  68387. * Gets or sets the instance divisor when in instanced mode
  68388. */
  68389. instanceDivisor: number;
  68390. /**
  68391. * Gets the byte stride.
  68392. */
  68393. readonly byteStride: number;
  68394. /**
  68395. * Gets the byte offset.
  68396. */
  68397. readonly byteOffset: number;
  68398. /**
  68399. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68400. */
  68401. readonly normalized: boolean;
  68402. /**
  68403. * Gets the data type of each component in the array.
  68404. */
  68405. readonly type: number;
  68406. /**
  68407. * Constructor
  68408. * @param engine the engine
  68409. * @param data the data to use for this vertex buffer
  68410. * @param kind the vertex buffer kind
  68411. * @param updatable whether the data is updatable
  68412. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68413. * @param stride the stride (optional)
  68414. * @param instanced whether the buffer is instanced (optional)
  68415. * @param offset the offset of the data (optional)
  68416. * @param size the number of components (optional)
  68417. * @param type the type of the component (optional)
  68418. * @param normalized whether the data contains normalized data (optional)
  68419. * @param useBytes set to true if stride and offset are in bytes (optional)
  68420. */
  68421. 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);
  68422. /** @hidden */
  68423. _rebuild(): void;
  68424. /**
  68425. * Returns the kind of the VertexBuffer (string)
  68426. * @returns a string
  68427. */
  68428. getKind(): string;
  68429. /**
  68430. * Gets a boolean indicating if the VertexBuffer is updatable?
  68431. * @returns true if the buffer is updatable
  68432. */
  68433. isUpdatable(): boolean;
  68434. /**
  68435. * Gets current buffer's data
  68436. * @returns a DataArray or null
  68437. */
  68438. getData(): Nullable<DataArray>;
  68439. /**
  68440. * Gets underlying native buffer
  68441. * @returns underlying native buffer
  68442. */
  68443. getBuffer(): Nullable<DataBuffer>;
  68444. /**
  68445. * Gets the stride in float32 units (i.e. byte stride / 4).
  68446. * May not be an integer if the byte stride is not divisible by 4.
  68447. * DEPRECATED. Use byteStride instead.
  68448. * @returns the stride in float32 units
  68449. */
  68450. getStrideSize(): number;
  68451. /**
  68452. * Returns the offset as a multiple of the type byte length.
  68453. * DEPRECATED. Use byteOffset instead.
  68454. * @returns the offset in bytes
  68455. */
  68456. getOffset(): number;
  68457. /**
  68458. * Returns the number of components per vertex attribute (integer)
  68459. * @returns the size in float
  68460. */
  68461. getSize(): number;
  68462. /**
  68463. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68464. * @returns true if this buffer is instanced
  68465. */
  68466. getIsInstanced(): boolean;
  68467. /**
  68468. * Returns the instancing divisor, zero for non-instanced (integer).
  68469. * @returns a number
  68470. */
  68471. getInstanceDivisor(): number;
  68472. /**
  68473. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68474. * @param data defines the data to store
  68475. */
  68476. create(data?: DataArray): void;
  68477. /**
  68478. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68479. * This function will create a new buffer if the current one is not updatable
  68480. * @param data defines the data to store
  68481. */
  68482. update(data: DataArray): void;
  68483. /**
  68484. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68485. * Returns the directly updated WebGLBuffer.
  68486. * @param data the new data
  68487. * @param offset the new offset
  68488. * @param useBytes set to true if the offset is in bytes
  68489. */
  68490. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68491. /**
  68492. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68493. */
  68494. dispose(): void;
  68495. /**
  68496. * Enumerates each value of this vertex buffer as numbers.
  68497. * @param count the number of values to enumerate
  68498. * @param callback the callback function called for each value
  68499. */
  68500. forEach(count: number, callback: (value: number, index: number) => void): void;
  68501. /**
  68502. * Positions
  68503. */
  68504. static readonly PositionKind: string;
  68505. /**
  68506. * Normals
  68507. */
  68508. static readonly NormalKind: string;
  68509. /**
  68510. * Tangents
  68511. */
  68512. static readonly TangentKind: string;
  68513. /**
  68514. * Texture coordinates
  68515. */
  68516. static readonly UVKind: string;
  68517. /**
  68518. * Texture coordinates 2
  68519. */
  68520. static readonly UV2Kind: string;
  68521. /**
  68522. * Texture coordinates 3
  68523. */
  68524. static readonly UV3Kind: string;
  68525. /**
  68526. * Texture coordinates 4
  68527. */
  68528. static readonly UV4Kind: string;
  68529. /**
  68530. * Texture coordinates 5
  68531. */
  68532. static readonly UV5Kind: string;
  68533. /**
  68534. * Texture coordinates 6
  68535. */
  68536. static readonly UV6Kind: string;
  68537. /**
  68538. * Colors
  68539. */
  68540. static readonly ColorKind: string;
  68541. /**
  68542. * Matrix indices (for bones)
  68543. */
  68544. static readonly MatricesIndicesKind: string;
  68545. /**
  68546. * Matrix weights (for bones)
  68547. */
  68548. static readonly MatricesWeightsKind: string;
  68549. /**
  68550. * Additional matrix indices (for bones)
  68551. */
  68552. static readonly MatricesIndicesExtraKind: string;
  68553. /**
  68554. * Additional matrix weights (for bones)
  68555. */
  68556. static readonly MatricesWeightsExtraKind: string;
  68557. /**
  68558. * Deduces the stride given a kind.
  68559. * @param kind The kind string to deduce
  68560. * @returns The deduced stride
  68561. */
  68562. static DeduceStride(kind: string): number;
  68563. /**
  68564. * Gets the byte length of the given type.
  68565. * @param type the type
  68566. * @returns the number of bytes
  68567. */
  68568. static GetTypeByteLength(type: number): number;
  68569. /**
  68570. * Enumerates each value of the given parameters as numbers.
  68571. * @param data the data to enumerate
  68572. * @param byteOffset the byte offset of the data
  68573. * @param byteStride the byte stride of the data
  68574. * @param componentCount the number of components per element
  68575. * @param componentType the type of the component
  68576. * @param count the number of values to enumerate
  68577. * @param normalized whether the data is normalized
  68578. * @param callback the callback function called for each value
  68579. */
  68580. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68581. private static _GetFloatValue;
  68582. }
  68583. }
  68584. declare module BABYLON {
  68585. /**
  68586. * Class representing spherical harmonics coefficients to the 3rd degree
  68587. */
  68588. export class SphericalHarmonics {
  68589. /**
  68590. * Defines whether or not the harmonics have been prescaled for rendering.
  68591. */
  68592. preScaled: boolean;
  68593. /**
  68594. * The l0,0 coefficients of the spherical harmonics
  68595. */
  68596. l00: Vector3;
  68597. /**
  68598. * The l1,-1 coefficients of the spherical harmonics
  68599. */
  68600. l1_1: Vector3;
  68601. /**
  68602. * The l1,0 coefficients of the spherical harmonics
  68603. */
  68604. l10: Vector3;
  68605. /**
  68606. * The l1,1 coefficients of the spherical harmonics
  68607. */
  68608. l11: Vector3;
  68609. /**
  68610. * The l2,-2 coefficients of the spherical harmonics
  68611. */
  68612. l2_2: Vector3;
  68613. /**
  68614. * The l2,-1 coefficients of the spherical harmonics
  68615. */
  68616. l2_1: Vector3;
  68617. /**
  68618. * The l2,0 coefficients of the spherical harmonics
  68619. */
  68620. l20: Vector3;
  68621. /**
  68622. * The l2,1 coefficients of the spherical harmonics
  68623. */
  68624. l21: Vector3;
  68625. /**
  68626. * The l2,2 coefficients of the spherical harmonics
  68627. */
  68628. l22: Vector3;
  68629. /**
  68630. * Adds a light to the spherical harmonics
  68631. * @param direction the direction of the light
  68632. * @param color the color of the light
  68633. * @param deltaSolidAngle the delta solid angle of the light
  68634. */
  68635. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68636. /**
  68637. * Scales the spherical harmonics by the given amount
  68638. * @param scale the amount to scale
  68639. */
  68640. scaleInPlace(scale: number): void;
  68641. /**
  68642. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68643. *
  68644. * ```
  68645. * E_lm = A_l * L_lm
  68646. * ```
  68647. *
  68648. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68649. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68650. * the scaling factors are given in equation 9.
  68651. */
  68652. convertIncidentRadianceToIrradiance(): void;
  68653. /**
  68654. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68655. *
  68656. * ```
  68657. * L = (1/pi) * E * rho
  68658. * ```
  68659. *
  68660. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68661. */
  68662. convertIrradianceToLambertianRadiance(): void;
  68663. /**
  68664. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68665. * required operations at run time.
  68666. *
  68667. * This is simply done by scaling back the SH with Ylm constants parameter.
  68668. * The trigonometric part being applied by the shader at run time.
  68669. */
  68670. preScaleForRendering(): void;
  68671. /**
  68672. * Constructs a spherical harmonics from an array.
  68673. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68674. * @returns the spherical harmonics
  68675. */
  68676. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68677. /**
  68678. * Gets the spherical harmonics from polynomial
  68679. * @param polynomial the spherical polynomial
  68680. * @returns the spherical harmonics
  68681. */
  68682. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68683. }
  68684. /**
  68685. * Class representing spherical polynomial coefficients to the 3rd degree
  68686. */
  68687. export class SphericalPolynomial {
  68688. private _harmonics;
  68689. /**
  68690. * The spherical harmonics used to create the polynomials.
  68691. */
  68692. readonly preScaledHarmonics: SphericalHarmonics;
  68693. /**
  68694. * The x coefficients of the spherical polynomial
  68695. */
  68696. x: Vector3;
  68697. /**
  68698. * The y coefficients of the spherical polynomial
  68699. */
  68700. y: Vector3;
  68701. /**
  68702. * The z coefficients of the spherical polynomial
  68703. */
  68704. z: Vector3;
  68705. /**
  68706. * The xx coefficients of the spherical polynomial
  68707. */
  68708. xx: Vector3;
  68709. /**
  68710. * The yy coefficients of the spherical polynomial
  68711. */
  68712. yy: Vector3;
  68713. /**
  68714. * The zz coefficients of the spherical polynomial
  68715. */
  68716. zz: Vector3;
  68717. /**
  68718. * The xy coefficients of the spherical polynomial
  68719. */
  68720. xy: Vector3;
  68721. /**
  68722. * The yz coefficients of the spherical polynomial
  68723. */
  68724. yz: Vector3;
  68725. /**
  68726. * The zx coefficients of the spherical polynomial
  68727. */
  68728. zx: Vector3;
  68729. /**
  68730. * Adds an ambient color to the spherical polynomial
  68731. * @param color the color to add
  68732. */
  68733. addAmbient(color: Color3): void;
  68734. /**
  68735. * Scales the spherical polynomial by the given amount
  68736. * @param scale the amount to scale
  68737. */
  68738. scaleInPlace(scale: number): void;
  68739. /**
  68740. * Gets the spherical polynomial from harmonics
  68741. * @param harmonics the spherical harmonics
  68742. * @returns the spherical polynomial
  68743. */
  68744. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68745. /**
  68746. * Constructs a spherical polynomial from an array.
  68747. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68748. * @returns the spherical polynomial
  68749. */
  68750. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68751. }
  68752. }
  68753. declare module BABYLON {
  68754. /**
  68755. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68756. */
  68757. export interface CubeMapInfo {
  68758. /**
  68759. * The pixel array for the front face.
  68760. * This is stored in format, left to right, up to down format.
  68761. */
  68762. front: Nullable<ArrayBufferView>;
  68763. /**
  68764. * The pixel array for the back face.
  68765. * This is stored in format, left to right, up to down format.
  68766. */
  68767. back: Nullable<ArrayBufferView>;
  68768. /**
  68769. * The pixel array for the left face.
  68770. * This is stored in format, left to right, up to down format.
  68771. */
  68772. left: Nullable<ArrayBufferView>;
  68773. /**
  68774. * The pixel array for the right face.
  68775. * This is stored in format, left to right, up to down format.
  68776. */
  68777. right: Nullable<ArrayBufferView>;
  68778. /**
  68779. * The pixel array for the up face.
  68780. * This is stored in format, left to right, up to down format.
  68781. */
  68782. up: Nullable<ArrayBufferView>;
  68783. /**
  68784. * The pixel array for the down face.
  68785. * This is stored in format, left to right, up to down format.
  68786. */
  68787. down: Nullable<ArrayBufferView>;
  68788. /**
  68789. * The size of the cubemap stored.
  68790. *
  68791. * Each faces will be size * size pixels.
  68792. */
  68793. size: number;
  68794. /**
  68795. * The format of the texture.
  68796. *
  68797. * RGBA, RGB.
  68798. */
  68799. format: number;
  68800. /**
  68801. * The type of the texture data.
  68802. *
  68803. * UNSIGNED_INT, FLOAT.
  68804. */
  68805. type: number;
  68806. /**
  68807. * Specifies whether the texture is in gamma space.
  68808. */
  68809. gammaSpace: boolean;
  68810. }
  68811. /**
  68812. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68813. */
  68814. export class PanoramaToCubeMapTools {
  68815. private static FACE_FRONT;
  68816. private static FACE_BACK;
  68817. private static FACE_RIGHT;
  68818. private static FACE_LEFT;
  68819. private static FACE_DOWN;
  68820. private static FACE_UP;
  68821. /**
  68822. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68823. *
  68824. * @param float32Array The source data.
  68825. * @param inputWidth The width of the input panorama.
  68826. * @param inputHeight The height of the input panorama.
  68827. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68828. * @return The cubemap data
  68829. */
  68830. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68831. private static CreateCubemapTexture;
  68832. private static CalcProjectionSpherical;
  68833. }
  68834. }
  68835. declare module BABYLON {
  68836. /**
  68837. * Helper class dealing with the extraction of spherical polynomial dataArray
  68838. * from a cube map.
  68839. */
  68840. export class CubeMapToSphericalPolynomialTools {
  68841. private static FileFaces;
  68842. /**
  68843. * Converts a texture to the according Spherical Polynomial data.
  68844. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68845. *
  68846. * @param texture The texture to extract the information from.
  68847. * @return The Spherical Polynomial data.
  68848. */
  68849. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68850. /**
  68851. * Converts a cubemap to the according Spherical Polynomial data.
  68852. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68853. *
  68854. * @param cubeInfo The Cube map to extract the information from.
  68855. * @return The Spherical Polynomial data.
  68856. */
  68857. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68858. }
  68859. }
  68860. declare module BABYLON {
  68861. /**
  68862. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68863. * during the life time of the application.
  68864. */
  68865. export class EngineStore {
  68866. /** Gets the list of created engines */
  68867. static Instances: Engine[];
  68868. /** @hidden */
  68869. static _LastCreatedScene: Nullable<Scene>;
  68870. /**
  68871. * Gets the latest created engine
  68872. */
  68873. static readonly LastCreatedEngine: Nullable<Engine>;
  68874. /**
  68875. * Gets the latest created scene
  68876. */
  68877. static readonly LastCreatedScene: Nullable<Scene>;
  68878. }
  68879. }
  68880. declare module BABYLON {
  68881. /**
  68882. * Define options used to create a render target texture
  68883. */
  68884. export class RenderTargetCreationOptions {
  68885. /**
  68886. * Specifies is mipmaps must be generated
  68887. */
  68888. generateMipMaps?: boolean;
  68889. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68890. generateDepthBuffer?: boolean;
  68891. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68892. generateStencilBuffer?: boolean;
  68893. /** Defines texture type (int by default) */
  68894. type?: number;
  68895. /** Defines sampling mode (trilinear by default) */
  68896. samplingMode?: number;
  68897. /** Defines format (RGBA by default) */
  68898. format?: number;
  68899. }
  68900. }
  68901. declare module BABYLON {
  68902. /**
  68903. * @hidden
  68904. **/
  68905. export class _AlphaState {
  68906. private _isAlphaBlendDirty;
  68907. private _isBlendFunctionParametersDirty;
  68908. private _isBlendEquationParametersDirty;
  68909. private _isBlendConstantsDirty;
  68910. private _alphaBlend;
  68911. private _blendFunctionParameters;
  68912. private _blendEquationParameters;
  68913. private _blendConstants;
  68914. /**
  68915. * Initializes the state.
  68916. */
  68917. constructor();
  68918. readonly isDirty: boolean;
  68919. alphaBlend: boolean;
  68920. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68921. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68922. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68923. reset(): void;
  68924. apply(gl: WebGLRenderingContext): void;
  68925. }
  68926. }
  68927. declare module BABYLON {
  68928. /**
  68929. * @hidden
  68930. **/
  68931. export class _DepthCullingState {
  68932. private _isDepthTestDirty;
  68933. private _isDepthMaskDirty;
  68934. private _isDepthFuncDirty;
  68935. private _isCullFaceDirty;
  68936. private _isCullDirty;
  68937. private _isZOffsetDirty;
  68938. private _isFrontFaceDirty;
  68939. private _depthTest;
  68940. private _depthMask;
  68941. private _depthFunc;
  68942. private _cull;
  68943. private _cullFace;
  68944. private _zOffset;
  68945. private _frontFace;
  68946. /**
  68947. * Initializes the state.
  68948. */
  68949. constructor();
  68950. readonly isDirty: boolean;
  68951. zOffset: number;
  68952. cullFace: Nullable<number>;
  68953. cull: Nullable<boolean>;
  68954. depthFunc: Nullable<number>;
  68955. depthMask: boolean;
  68956. depthTest: boolean;
  68957. frontFace: Nullable<number>;
  68958. reset(): void;
  68959. apply(gl: WebGLRenderingContext): void;
  68960. }
  68961. }
  68962. declare module BABYLON {
  68963. /**
  68964. * @hidden
  68965. **/
  68966. export class _StencilState {
  68967. /** 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 */
  68968. static readonly ALWAYS: number;
  68969. /** Passed to stencilOperation to specify that stencil value must be kept */
  68970. static readonly KEEP: number;
  68971. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68972. static readonly REPLACE: number;
  68973. private _isStencilTestDirty;
  68974. private _isStencilMaskDirty;
  68975. private _isStencilFuncDirty;
  68976. private _isStencilOpDirty;
  68977. private _stencilTest;
  68978. private _stencilMask;
  68979. private _stencilFunc;
  68980. private _stencilFuncRef;
  68981. private _stencilFuncMask;
  68982. private _stencilOpStencilFail;
  68983. private _stencilOpDepthFail;
  68984. private _stencilOpStencilDepthPass;
  68985. readonly isDirty: boolean;
  68986. stencilFunc: number;
  68987. stencilFuncRef: number;
  68988. stencilFuncMask: number;
  68989. stencilOpStencilFail: number;
  68990. stencilOpDepthFail: number;
  68991. stencilOpStencilDepthPass: number;
  68992. stencilMask: number;
  68993. stencilTest: boolean;
  68994. constructor();
  68995. reset(): void;
  68996. apply(gl: WebGLRenderingContext): void;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /**
  69001. * @hidden
  69002. **/
  69003. export class _TimeToken {
  69004. _startTimeQuery: Nullable<WebGLQuery>;
  69005. _endTimeQuery: Nullable<WebGLQuery>;
  69006. _timeElapsedQuery: Nullable<WebGLQuery>;
  69007. _timeElapsedQueryEnded: boolean;
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * Class used to store data associated with WebGL texture data for the engine
  69013. * This class should not be used directly
  69014. */
  69015. export class InternalTexture {
  69016. /** @hidden */
  69017. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  69018. /**
  69019. * The source of the texture data is unknown
  69020. */
  69021. static DATASOURCE_UNKNOWN: number;
  69022. /**
  69023. * Texture data comes from an URL
  69024. */
  69025. static DATASOURCE_URL: number;
  69026. /**
  69027. * Texture data is only used for temporary storage
  69028. */
  69029. static DATASOURCE_TEMP: number;
  69030. /**
  69031. * Texture data comes from raw data (ArrayBuffer)
  69032. */
  69033. static DATASOURCE_RAW: number;
  69034. /**
  69035. * Texture content is dynamic (video or dynamic texture)
  69036. */
  69037. static DATASOURCE_DYNAMIC: number;
  69038. /**
  69039. * Texture content is generated by rendering to it
  69040. */
  69041. static DATASOURCE_RENDERTARGET: number;
  69042. /**
  69043. * Texture content is part of a multi render target process
  69044. */
  69045. static DATASOURCE_MULTIRENDERTARGET: number;
  69046. /**
  69047. * Texture data comes from a cube data file
  69048. */
  69049. static DATASOURCE_CUBE: number;
  69050. /**
  69051. * Texture data comes from a raw cube data
  69052. */
  69053. static DATASOURCE_CUBERAW: number;
  69054. /**
  69055. * Texture data come from a prefiltered cube data file
  69056. */
  69057. static DATASOURCE_CUBEPREFILTERED: number;
  69058. /**
  69059. * Texture content is raw 3D data
  69060. */
  69061. static DATASOURCE_RAW3D: number;
  69062. /**
  69063. * Texture content is a depth texture
  69064. */
  69065. static DATASOURCE_DEPTHTEXTURE: number;
  69066. /**
  69067. * Texture data comes from a raw cube data encoded with RGBD
  69068. */
  69069. static DATASOURCE_CUBERAW_RGBD: number;
  69070. /**
  69071. * Defines if the texture is ready
  69072. */
  69073. isReady: boolean;
  69074. /**
  69075. * Defines if the texture is a cube texture
  69076. */
  69077. isCube: boolean;
  69078. /**
  69079. * Defines if the texture contains 3D data
  69080. */
  69081. is3D: boolean;
  69082. /**
  69083. * Defines if the texture contains multiview data
  69084. */
  69085. isMultiview: boolean;
  69086. /**
  69087. * Gets the URL used to load this texture
  69088. */
  69089. url: string;
  69090. /**
  69091. * Gets the sampling mode of the texture
  69092. */
  69093. samplingMode: number;
  69094. /**
  69095. * Gets a boolean indicating if the texture needs mipmaps generation
  69096. */
  69097. generateMipMaps: boolean;
  69098. /**
  69099. * Gets the number of samples used by the texture (WebGL2+ only)
  69100. */
  69101. samples: number;
  69102. /**
  69103. * Gets the type of the texture (int, float...)
  69104. */
  69105. type: number;
  69106. /**
  69107. * Gets the format of the texture (RGB, RGBA...)
  69108. */
  69109. format: number;
  69110. /**
  69111. * Observable called when the texture is loaded
  69112. */
  69113. onLoadedObservable: Observable<InternalTexture>;
  69114. /**
  69115. * Gets the width of the texture
  69116. */
  69117. width: number;
  69118. /**
  69119. * Gets the height of the texture
  69120. */
  69121. height: number;
  69122. /**
  69123. * Gets the depth of the texture
  69124. */
  69125. depth: number;
  69126. /**
  69127. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69128. */
  69129. baseWidth: number;
  69130. /**
  69131. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69132. */
  69133. baseHeight: number;
  69134. /**
  69135. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69136. */
  69137. baseDepth: number;
  69138. /**
  69139. * Gets a boolean indicating if the texture is inverted on Y axis
  69140. */
  69141. invertY: boolean;
  69142. /** @hidden */
  69143. _invertVScale: boolean;
  69144. /** @hidden */
  69145. _associatedChannel: number;
  69146. /** @hidden */
  69147. _dataSource: number;
  69148. /** @hidden */
  69149. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69150. /** @hidden */
  69151. _bufferView: Nullable<ArrayBufferView>;
  69152. /** @hidden */
  69153. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69154. /** @hidden */
  69155. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69156. /** @hidden */
  69157. _size: number;
  69158. /** @hidden */
  69159. _extension: string;
  69160. /** @hidden */
  69161. _files: Nullable<string[]>;
  69162. /** @hidden */
  69163. _workingCanvas: Nullable<HTMLCanvasElement>;
  69164. /** @hidden */
  69165. _workingContext: Nullable<CanvasRenderingContext2D>;
  69166. /** @hidden */
  69167. _framebuffer: Nullable<WebGLFramebuffer>;
  69168. /** @hidden */
  69169. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69170. /** @hidden */
  69171. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69172. /** @hidden */
  69173. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69174. /** @hidden */
  69175. _attachments: Nullable<number[]>;
  69176. /** @hidden */
  69177. _cachedCoordinatesMode: Nullable<number>;
  69178. /** @hidden */
  69179. _cachedWrapU: Nullable<number>;
  69180. /** @hidden */
  69181. _cachedWrapV: Nullable<number>;
  69182. /** @hidden */
  69183. _cachedWrapR: Nullable<number>;
  69184. /** @hidden */
  69185. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69186. /** @hidden */
  69187. _isDisabled: boolean;
  69188. /** @hidden */
  69189. _compression: Nullable<string>;
  69190. /** @hidden */
  69191. _generateStencilBuffer: boolean;
  69192. /** @hidden */
  69193. _generateDepthBuffer: boolean;
  69194. /** @hidden */
  69195. _comparisonFunction: number;
  69196. /** @hidden */
  69197. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69198. /** @hidden */
  69199. _lodGenerationScale: number;
  69200. /** @hidden */
  69201. _lodGenerationOffset: number;
  69202. /** @hidden */
  69203. _colorTextureArray: Nullable<WebGLTexture>;
  69204. /** @hidden */
  69205. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69206. /** @hidden */
  69207. _lodTextureHigh: Nullable<BaseTexture>;
  69208. /** @hidden */
  69209. _lodTextureMid: Nullable<BaseTexture>;
  69210. /** @hidden */
  69211. _lodTextureLow: Nullable<BaseTexture>;
  69212. /** @hidden */
  69213. _isRGBD: boolean;
  69214. /** @hidden */
  69215. _linearSpecularLOD: boolean;
  69216. /** @hidden */
  69217. _irradianceTexture: Nullable<BaseTexture>;
  69218. /** @hidden */
  69219. _webGLTexture: Nullable<WebGLTexture>;
  69220. /** @hidden */
  69221. _references: number;
  69222. private _engine;
  69223. /**
  69224. * Gets the Engine the texture belongs to.
  69225. * @returns The babylon engine
  69226. */
  69227. getEngine(): Engine;
  69228. /**
  69229. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69230. */
  69231. readonly dataSource: number;
  69232. /**
  69233. * Creates a new InternalTexture
  69234. * @param engine defines the engine to use
  69235. * @param dataSource defines the type of data that will be used
  69236. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69237. */
  69238. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69239. /**
  69240. * Increments the number of references (ie. the number of Texture that point to it)
  69241. */
  69242. incrementReferences(): void;
  69243. /**
  69244. * Change the size of the texture (not the size of the content)
  69245. * @param width defines the new width
  69246. * @param height defines the new height
  69247. * @param depth defines the new depth (1 by default)
  69248. */
  69249. updateSize(width: int, height: int, depth?: int): void;
  69250. /** @hidden */
  69251. _rebuild(): void;
  69252. /** @hidden */
  69253. _swapAndDie(target: InternalTexture): void;
  69254. /**
  69255. * Dispose the current allocated resources
  69256. */
  69257. dispose(): void;
  69258. }
  69259. }
  69260. declare module BABYLON {
  69261. /**
  69262. * This represents the main contract an easing function should follow.
  69263. * Easing functions are used throughout the animation system.
  69264. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69265. */
  69266. export interface IEasingFunction {
  69267. /**
  69268. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69269. * of the easing function.
  69270. * The link below provides some of the most common examples of easing functions.
  69271. * @see https://easings.net/
  69272. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69273. * @returns the corresponding value on the curve defined by the easing function
  69274. */
  69275. ease(gradient: number): number;
  69276. }
  69277. /**
  69278. * Base class used for every default easing function.
  69279. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69280. */
  69281. export class EasingFunction implements IEasingFunction {
  69282. /**
  69283. * Interpolation follows the mathematical formula associated with the easing function.
  69284. */
  69285. static readonly EASINGMODE_EASEIN: number;
  69286. /**
  69287. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69288. */
  69289. static readonly EASINGMODE_EASEOUT: number;
  69290. /**
  69291. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69292. */
  69293. static readonly EASINGMODE_EASEINOUT: number;
  69294. private _easingMode;
  69295. /**
  69296. * Sets the easing mode of the current function.
  69297. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69298. */
  69299. setEasingMode(easingMode: number): void;
  69300. /**
  69301. * Gets the current easing mode.
  69302. * @returns the easing mode
  69303. */
  69304. getEasingMode(): number;
  69305. /**
  69306. * @hidden
  69307. */
  69308. easeInCore(gradient: number): number;
  69309. /**
  69310. * Given an input gradient between 0 and 1, this returns the corresponding value
  69311. * of the easing function.
  69312. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69313. * @returns the corresponding value on the curve defined by the easing function
  69314. */
  69315. ease(gradient: number): number;
  69316. }
  69317. /**
  69318. * Easing function with a circle shape (see link below).
  69319. * @see https://easings.net/#easeInCirc
  69320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69321. */
  69322. export class CircleEase extends EasingFunction implements IEasingFunction {
  69323. /** @hidden */
  69324. easeInCore(gradient: number): number;
  69325. }
  69326. /**
  69327. * Easing function with a ease back shape (see link below).
  69328. * @see https://easings.net/#easeInBack
  69329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69330. */
  69331. export class BackEase extends EasingFunction implements IEasingFunction {
  69332. /** Defines the amplitude of the function */
  69333. amplitude: number;
  69334. /**
  69335. * Instantiates a back ease easing
  69336. * @see https://easings.net/#easeInBack
  69337. * @param amplitude Defines the amplitude of the function
  69338. */
  69339. constructor(
  69340. /** Defines the amplitude of the function */
  69341. amplitude?: number);
  69342. /** @hidden */
  69343. easeInCore(gradient: number): number;
  69344. }
  69345. /**
  69346. * Easing function with a bouncing shape (see link below).
  69347. * @see https://easings.net/#easeInBounce
  69348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69349. */
  69350. export class BounceEase extends EasingFunction implements IEasingFunction {
  69351. /** Defines the number of bounces */
  69352. bounces: number;
  69353. /** Defines the amplitude of the bounce */
  69354. bounciness: number;
  69355. /**
  69356. * Instantiates a bounce easing
  69357. * @see https://easings.net/#easeInBounce
  69358. * @param bounces Defines the number of bounces
  69359. * @param bounciness Defines the amplitude of the bounce
  69360. */
  69361. constructor(
  69362. /** Defines the number of bounces */
  69363. bounces?: number,
  69364. /** Defines the amplitude of the bounce */
  69365. bounciness?: number);
  69366. /** @hidden */
  69367. easeInCore(gradient: number): number;
  69368. }
  69369. /**
  69370. * Easing function with a power of 3 shape (see link below).
  69371. * @see https://easings.net/#easeInCubic
  69372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69373. */
  69374. export class CubicEase extends EasingFunction implements IEasingFunction {
  69375. /** @hidden */
  69376. easeInCore(gradient: number): number;
  69377. }
  69378. /**
  69379. * Easing function with an elastic shape (see link below).
  69380. * @see https://easings.net/#easeInElastic
  69381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69382. */
  69383. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69384. /** Defines the number of oscillations*/
  69385. oscillations: number;
  69386. /** Defines the amplitude of the oscillations*/
  69387. springiness: number;
  69388. /**
  69389. * Instantiates an elastic easing function
  69390. * @see https://easings.net/#easeInElastic
  69391. * @param oscillations Defines the number of oscillations
  69392. * @param springiness Defines the amplitude of the oscillations
  69393. */
  69394. constructor(
  69395. /** Defines the number of oscillations*/
  69396. oscillations?: number,
  69397. /** Defines the amplitude of the oscillations*/
  69398. springiness?: number);
  69399. /** @hidden */
  69400. easeInCore(gradient: number): number;
  69401. }
  69402. /**
  69403. * Easing function with an exponential shape (see link below).
  69404. * @see https://easings.net/#easeInExpo
  69405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69406. */
  69407. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69408. /** Defines the exponent of the function */
  69409. exponent: number;
  69410. /**
  69411. * Instantiates an exponential easing function
  69412. * @see https://easings.net/#easeInExpo
  69413. * @param exponent Defines the exponent of the function
  69414. */
  69415. constructor(
  69416. /** Defines the exponent of the function */
  69417. exponent?: number);
  69418. /** @hidden */
  69419. easeInCore(gradient: number): number;
  69420. }
  69421. /**
  69422. * Easing function with a power shape (see link below).
  69423. * @see https://easings.net/#easeInQuad
  69424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69425. */
  69426. export class PowerEase extends EasingFunction implements IEasingFunction {
  69427. /** Defines the power of the function */
  69428. power: number;
  69429. /**
  69430. * Instantiates an power base easing function
  69431. * @see https://easings.net/#easeInQuad
  69432. * @param power Defines the power of the function
  69433. */
  69434. constructor(
  69435. /** Defines the power of the function */
  69436. power?: number);
  69437. /** @hidden */
  69438. easeInCore(gradient: number): number;
  69439. }
  69440. /**
  69441. * Easing function with a power of 2 shape (see link below).
  69442. * @see https://easings.net/#easeInQuad
  69443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69444. */
  69445. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69446. /** @hidden */
  69447. easeInCore(gradient: number): number;
  69448. }
  69449. /**
  69450. * Easing function with a power of 4 shape (see link below).
  69451. * @see https://easings.net/#easeInQuart
  69452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69453. */
  69454. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69455. /** @hidden */
  69456. easeInCore(gradient: number): number;
  69457. }
  69458. /**
  69459. * Easing function with a power of 5 shape (see link below).
  69460. * @see https://easings.net/#easeInQuint
  69461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69462. */
  69463. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69464. /** @hidden */
  69465. easeInCore(gradient: number): number;
  69466. }
  69467. /**
  69468. * Easing function with a sin shape (see link below).
  69469. * @see https://easings.net/#easeInSine
  69470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69471. */
  69472. export class SineEase extends EasingFunction implements IEasingFunction {
  69473. /** @hidden */
  69474. easeInCore(gradient: number): number;
  69475. }
  69476. /**
  69477. * Easing function with a bezier shape (see link below).
  69478. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69480. */
  69481. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69482. /** Defines the x component of the start tangent in the bezier curve */
  69483. x1: number;
  69484. /** Defines the y component of the start tangent in the bezier curve */
  69485. y1: number;
  69486. /** Defines the x component of the end tangent in the bezier curve */
  69487. x2: number;
  69488. /** Defines the y component of the end tangent in the bezier curve */
  69489. y2: number;
  69490. /**
  69491. * Instantiates a bezier function
  69492. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69493. * @param x1 Defines the x component of the start tangent in the bezier curve
  69494. * @param y1 Defines the y component of the start tangent in the bezier curve
  69495. * @param x2 Defines the x component of the end tangent in the bezier curve
  69496. * @param y2 Defines the y component of the end tangent in the bezier curve
  69497. */
  69498. constructor(
  69499. /** Defines the x component of the start tangent in the bezier curve */
  69500. x1?: number,
  69501. /** Defines the y component of the start tangent in the bezier curve */
  69502. y1?: number,
  69503. /** Defines the x component of the end tangent in the bezier curve */
  69504. x2?: number,
  69505. /** Defines the y component of the end tangent in the bezier curve */
  69506. y2?: number);
  69507. /** @hidden */
  69508. easeInCore(gradient: number): number;
  69509. }
  69510. }
  69511. declare module BABYLON {
  69512. /**
  69513. * Defines an interface which represents an animation key frame
  69514. */
  69515. export interface IAnimationKey {
  69516. /**
  69517. * Frame of the key frame
  69518. */
  69519. frame: number;
  69520. /**
  69521. * Value at the specifies key frame
  69522. */
  69523. value: any;
  69524. /**
  69525. * The input tangent for the cubic hermite spline
  69526. */
  69527. inTangent?: any;
  69528. /**
  69529. * The output tangent for the cubic hermite spline
  69530. */
  69531. outTangent?: any;
  69532. /**
  69533. * The animation interpolation type
  69534. */
  69535. interpolation?: AnimationKeyInterpolation;
  69536. }
  69537. /**
  69538. * Enum for the animation key frame interpolation type
  69539. */
  69540. export enum AnimationKeyInterpolation {
  69541. /**
  69542. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69543. */
  69544. STEP = 1
  69545. }
  69546. }
  69547. declare module BABYLON {
  69548. /**
  69549. * Represents the range of an animation
  69550. */
  69551. export class AnimationRange {
  69552. /**The name of the animation range**/
  69553. name: string;
  69554. /**The starting frame of the animation */
  69555. from: number;
  69556. /**The ending frame of the animation*/
  69557. to: number;
  69558. /**
  69559. * Initializes the range of an animation
  69560. * @param name The name of the animation range
  69561. * @param from The starting frame of the animation
  69562. * @param to The ending frame of the animation
  69563. */
  69564. constructor(
  69565. /**The name of the animation range**/
  69566. name: string,
  69567. /**The starting frame of the animation */
  69568. from: number,
  69569. /**The ending frame of the animation*/
  69570. to: number);
  69571. /**
  69572. * Makes a copy of the animation range
  69573. * @returns A copy of the animation range
  69574. */
  69575. clone(): AnimationRange;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /**
  69580. * Composed of a frame, and an action function
  69581. */
  69582. export class AnimationEvent {
  69583. /** The frame for which the event is triggered **/
  69584. frame: number;
  69585. /** The event to perform when triggered **/
  69586. action: (currentFrame: number) => void;
  69587. /** Specifies if the event should be triggered only once**/
  69588. onlyOnce?: boolean | undefined;
  69589. /**
  69590. * Specifies if the animation event is done
  69591. */
  69592. isDone: boolean;
  69593. /**
  69594. * Initializes the animation event
  69595. * @param frame The frame for which the event is triggered
  69596. * @param action The event to perform when triggered
  69597. * @param onlyOnce Specifies if the event should be triggered only once
  69598. */
  69599. constructor(
  69600. /** The frame for which the event is triggered **/
  69601. frame: number,
  69602. /** The event to perform when triggered **/
  69603. action: (currentFrame: number) => void,
  69604. /** Specifies if the event should be triggered only once**/
  69605. onlyOnce?: boolean | undefined);
  69606. /** @hidden */
  69607. _clone(): AnimationEvent;
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /**
  69612. * Interface used to define a behavior
  69613. */
  69614. export interface Behavior<T> {
  69615. /** gets or sets behavior's name */
  69616. name: string;
  69617. /**
  69618. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69619. */
  69620. init(): void;
  69621. /**
  69622. * Called when the behavior is attached to a target
  69623. * @param target defines the target where the behavior is attached to
  69624. */
  69625. attach(target: T): void;
  69626. /**
  69627. * Called when the behavior is detached from its target
  69628. */
  69629. detach(): void;
  69630. }
  69631. /**
  69632. * Interface implemented by classes supporting behaviors
  69633. */
  69634. export interface IBehaviorAware<T> {
  69635. /**
  69636. * Attach a behavior
  69637. * @param behavior defines the behavior to attach
  69638. * @returns the current host
  69639. */
  69640. addBehavior(behavior: Behavior<T>): T;
  69641. /**
  69642. * Remove a behavior from the current object
  69643. * @param behavior defines the behavior to detach
  69644. * @returns the current host
  69645. */
  69646. removeBehavior(behavior: Behavior<T>): T;
  69647. /**
  69648. * Gets a behavior using its name to search
  69649. * @param name defines the name to search
  69650. * @returns the behavior or null if not found
  69651. */
  69652. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69653. }
  69654. }
  69655. declare module BABYLON {
  69656. /**
  69657. * @hidden
  69658. */
  69659. export class IntersectionInfo {
  69660. bu: Nullable<number>;
  69661. bv: Nullable<number>;
  69662. distance: number;
  69663. faceId: number;
  69664. subMeshId: number;
  69665. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /**
  69670. * Class used to store bounding sphere information
  69671. */
  69672. export class BoundingSphere {
  69673. /**
  69674. * Gets the center of the bounding sphere in local space
  69675. */
  69676. readonly center: Vector3;
  69677. /**
  69678. * Radius of the bounding sphere in local space
  69679. */
  69680. radius: number;
  69681. /**
  69682. * Gets the center of the bounding sphere in world space
  69683. */
  69684. readonly centerWorld: Vector3;
  69685. /**
  69686. * Radius of the bounding sphere in world space
  69687. */
  69688. radiusWorld: number;
  69689. /**
  69690. * Gets the minimum vector in local space
  69691. */
  69692. readonly minimum: Vector3;
  69693. /**
  69694. * Gets the maximum vector in local space
  69695. */
  69696. readonly maximum: Vector3;
  69697. private _worldMatrix;
  69698. private static readonly TmpVector3;
  69699. /**
  69700. * Creates a new bounding sphere
  69701. * @param min defines the minimum vector (in local space)
  69702. * @param max defines the maximum vector (in local space)
  69703. * @param worldMatrix defines the new world matrix
  69704. */
  69705. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69706. /**
  69707. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69708. * @param min defines the new minimum vector (in local space)
  69709. * @param max defines the new maximum vector (in local space)
  69710. * @param worldMatrix defines the new world matrix
  69711. */
  69712. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69713. /**
  69714. * Scale the current bounding sphere by applying a scale factor
  69715. * @param factor defines the scale factor to apply
  69716. * @returns the current bounding box
  69717. */
  69718. scale(factor: number): BoundingSphere;
  69719. /**
  69720. * Gets the world matrix of the bounding box
  69721. * @returns a matrix
  69722. */
  69723. getWorldMatrix(): DeepImmutable<Matrix>;
  69724. /** @hidden */
  69725. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69726. /**
  69727. * Tests if the bounding sphere is intersecting the frustum planes
  69728. * @param frustumPlanes defines the frustum planes to test
  69729. * @returns true if there is an intersection
  69730. */
  69731. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69732. /**
  69733. * Tests if the bounding sphere center is in between the frustum planes.
  69734. * Used for optimistic fast inclusion.
  69735. * @param frustumPlanes defines the frustum planes to test
  69736. * @returns true if the sphere center is in between the frustum planes
  69737. */
  69738. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69739. /**
  69740. * Tests if a point is inside the bounding sphere
  69741. * @param point defines the point to test
  69742. * @returns true if the point is inside the bounding sphere
  69743. */
  69744. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69745. /**
  69746. * Checks if two sphere intersct
  69747. * @param sphere0 sphere 0
  69748. * @param sphere1 sphere 1
  69749. * @returns true if the speres intersect
  69750. */
  69751. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69752. }
  69753. }
  69754. declare module BABYLON {
  69755. /**
  69756. * Class used to store bounding box information
  69757. */
  69758. export class BoundingBox implements ICullable {
  69759. /**
  69760. * Gets the 8 vectors representing the bounding box in local space
  69761. */
  69762. readonly vectors: Vector3[];
  69763. /**
  69764. * Gets the center of the bounding box in local space
  69765. */
  69766. readonly center: Vector3;
  69767. /**
  69768. * Gets the center of the bounding box in world space
  69769. */
  69770. readonly centerWorld: Vector3;
  69771. /**
  69772. * Gets the extend size in local space
  69773. */
  69774. readonly extendSize: Vector3;
  69775. /**
  69776. * Gets the extend size in world space
  69777. */
  69778. readonly extendSizeWorld: Vector3;
  69779. /**
  69780. * Gets the OBB (object bounding box) directions
  69781. */
  69782. readonly directions: Vector3[];
  69783. /**
  69784. * Gets the 8 vectors representing the bounding box in world space
  69785. */
  69786. readonly vectorsWorld: Vector3[];
  69787. /**
  69788. * Gets the minimum vector in world space
  69789. */
  69790. readonly minimumWorld: Vector3;
  69791. /**
  69792. * Gets the maximum vector in world space
  69793. */
  69794. readonly maximumWorld: Vector3;
  69795. /**
  69796. * Gets the minimum vector in local space
  69797. */
  69798. readonly minimum: Vector3;
  69799. /**
  69800. * Gets the maximum vector in local space
  69801. */
  69802. readonly maximum: Vector3;
  69803. private _worldMatrix;
  69804. private static readonly TmpVector3;
  69805. /**
  69806. * @hidden
  69807. */
  69808. _tag: number;
  69809. /**
  69810. * Creates a new bounding box
  69811. * @param min defines the minimum vector (in local space)
  69812. * @param max defines the maximum vector (in local space)
  69813. * @param worldMatrix defines the new world matrix
  69814. */
  69815. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69816. /**
  69817. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69818. * @param min defines the new minimum vector (in local space)
  69819. * @param max defines the new maximum vector (in local space)
  69820. * @param worldMatrix defines the new world matrix
  69821. */
  69822. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69823. /**
  69824. * Scale the current bounding box by applying a scale factor
  69825. * @param factor defines the scale factor to apply
  69826. * @returns the current bounding box
  69827. */
  69828. scale(factor: number): BoundingBox;
  69829. /**
  69830. * Gets the world matrix of the bounding box
  69831. * @returns a matrix
  69832. */
  69833. getWorldMatrix(): DeepImmutable<Matrix>;
  69834. /** @hidden */
  69835. _update(world: DeepImmutable<Matrix>): void;
  69836. /**
  69837. * Tests if the bounding box is intersecting the frustum planes
  69838. * @param frustumPlanes defines the frustum planes to test
  69839. * @returns true if there is an intersection
  69840. */
  69841. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69842. /**
  69843. * Tests if the bounding box is entirely inside the frustum planes
  69844. * @param frustumPlanes defines the frustum planes to test
  69845. * @returns true if there is an inclusion
  69846. */
  69847. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69848. /**
  69849. * Tests if a point is inside the bounding box
  69850. * @param point defines the point to test
  69851. * @returns true if the point is inside the bounding box
  69852. */
  69853. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69854. /**
  69855. * Tests if the bounding box intersects with a bounding sphere
  69856. * @param sphere defines the sphere to test
  69857. * @returns true if there is an intersection
  69858. */
  69859. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69860. /**
  69861. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69862. * @param min defines the min vector to use
  69863. * @param max defines the max vector to use
  69864. * @returns true if there is an intersection
  69865. */
  69866. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69867. /**
  69868. * Tests if two bounding boxes are intersections
  69869. * @param box0 defines the first box to test
  69870. * @param box1 defines the second box to test
  69871. * @returns true if there is an intersection
  69872. */
  69873. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69874. /**
  69875. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69876. * @param minPoint defines the minimum vector of the bounding box
  69877. * @param maxPoint defines the maximum vector of the bounding box
  69878. * @param sphereCenter defines the sphere center
  69879. * @param sphereRadius defines the sphere radius
  69880. * @returns true if there is an intersection
  69881. */
  69882. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69883. /**
  69884. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69885. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69886. * @param frustumPlanes defines the frustum planes to test
  69887. * @return true if there is an inclusion
  69888. */
  69889. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69890. /**
  69891. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69892. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69893. * @param frustumPlanes defines the frustum planes to test
  69894. * @return true if there is an intersection
  69895. */
  69896. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69897. }
  69898. }
  69899. declare module BABYLON {
  69900. /** @hidden */
  69901. export class Collider {
  69902. /** Define if a collision was found */
  69903. collisionFound: boolean;
  69904. /**
  69905. * Define last intersection point in local space
  69906. */
  69907. intersectionPoint: Vector3;
  69908. /**
  69909. * Define last collided mesh
  69910. */
  69911. collidedMesh: Nullable<AbstractMesh>;
  69912. private _collisionPoint;
  69913. private _planeIntersectionPoint;
  69914. private _tempVector;
  69915. private _tempVector2;
  69916. private _tempVector3;
  69917. private _tempVector4;
  69918. private _edge;
  69919. private _baseToVertex;
  69920. private _destinationPoint;
  69921. private _slidePlaneNormal;
  69922. private _displacementVector;
  69923. /** @hidden */
  69924. _radius: Vector3;
  69925. /** @hidden */
  69926. _retry: number;
  69927. private _velocity;
  69928. private _basePoint;
  69929. private _epsilon;
  69930. /** @hidden */
  69931. _velocityWorldLength: number;
  69932. /** @hidden */
  69933. _basePointWorld: Vector3;
  69934. private _velocityWorld;
  69935. private _normalizedVelocity;
  69936. /** @hidden */
  69937. _initialVelocity: Vector3;
  69938. /** @hidden */
  69939. _initialPosition: Vector3;
  69940. private _nearestDistance;
  69941. private _collisionMask;
  69942. collisionMask: number;
  69943. /**
  69944. * Gets the plane normal used to compute the sliding response (in local space)
  69945. */
  69946. readonly slidePlaneNormal: Vector3;
  69947. /** @hidden */
  69948. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69949. /** @hidden */
  69950. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69951. /** @hidden */
  69952. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69953. /** @hidden */
  69954. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69955. /** @hidden */
  69956. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69957. /** @hidden */
  69958. _getResponse(pos: Vector3, vel: Vector3): void;
  69959. }
  69960. }
  69961. declare module BABYLON {
  69962. /**
  69963. * Interface for cullable objects
  69964. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69965. */
  69966. export interface ICullable {
  69967. /**
  69968. * Checks if the object or part of the object is in the frustum
  69969. * @param frustumPlanes Camera near/planes
  69970. * @returns true if the object is in frustum otherwise false
  69971. */
  69972. isInFrustum(frustumPlanes: Plane[]): boolean;
  69973. /**
  69974. * Checks if a cullable object (mesh...) is in the camera frustum
  69975. * Unlike isInFrustum this cheks the full bounding box
  69976. * @param frustumPlanes Camera near/planes
  69977. * @returns true if the object is in frustum otherwise false
  69978. */
  69979. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69980. }
  69981. /**
  69982. * Info for a bounding data of a mesh
  69983. */
  69984. export class BoundingInfo implements ICullable {
  69985. /**
  69986. * Bounding box for the mesh
  69987. */
  69988. readonly boundingBox: BoundingBox;
  69989. /**
  69990. * Bounding sphere for the mesh
  69991. */
  69992. readonly boundingSphere: BoundingSphere;
  69993. private _isLocked;
  69994. private static readonly TmpVector3;
  69995. /**
  69996. * Constructs bounding info
  69997. * @param minimum min vector of the bounding box/sphere
  69998. * @param maximum max vector of the bounding box/sphere
  69999. * @param worldMatrix defines the new world matrix
  70000. */
  70001. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70002. /**
  70003. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70004. * @param min defines the new minimum vector (in local space)
  70005. * @param max defines the new maximum vector (in local space)
  70006. * @param worldMatrix defines the new world matrix
  70007. */
  70008. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70009. /**
  70010. * min vector of the bounding box/sphere
  70011. */
  70012. readonly minimum: Vector3;
  70013. /**
  70014. * max vector of the bounding box/sphere
  70015. */
  70016. readonly maximum: Vector3;
  70017. /**
  70018. * If the info is locked and won't be updated to avoid perf overhead
  70019. */
  70020. isLocked: boolean;
  70021. /**
  70022. * Updates the bounding sphere and box
  70023. * @param world world matrix to be used to update
  70024. */
  70025. update(world: DeepImmutable<Matrix>): void;
  70026. /**
  70027. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70028. * @param center New center of the bounding info
  70029. * @param extend New extend of the bounding info
  70030. * @returns the current bounding info
  70031. */
  70032. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70033. /**
  70034. * Scale the current bounding info by applying a scale factor
  70035. * @param factor defines the scale factor to apply
  70036. * @returns the current bounding info
  70037. */
  70038. scale(factor: number): BoundingInfo;
  70039. /**
  70040. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70041. * @param frustumPlanes defines the frustum to test
  70042. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70043. * @returns true if the bounding info is in the frustum planes
  70044. */
  70045. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70046. /**
  70047. * Gets the world distance between the min and max points of the bounding box
  70048. */
  70049. readonly diagonalLength: number;
  70050. /**
  70051. * Checks if a cullable object (mesh...) is in the camera frustum
  70052. * Unlike isInFrustum this cheks the full bounding box
  70053. * @param frustumPlanes Camera near/planes
  70054. * @returns true if the object is in frustum otherwise false
  70055. */
  70056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70057. /** @hidden */
  70058. _checkCollision(collider: Collider): boolean;
  70059. /**
  70060. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70061. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70062. * @param point the point to check intersection with
  70063. * @returns if the point intersects
  70064. */
  70065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70066. /**
  70067. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70068. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70069. * @param boundingInfo the bounding info to check intersection with
  70070. * @param precise if the intersection should be done using OBB
  70071. * @returns if the bounding info intersects
  70072. */
  70073. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70074. }
  70075. }
  70076. declare module BABYLON {
  70077. /**
  70078. * Defines an array and its length.
  70079. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70080. */
  70081. export interface ISmartArrayLike<T> {
  70082. /**
  70083. * The data of the array.
  70084. */
  70085. data: Array<T>;
  70086. /**
  70087. * The active length of the array.
  70088. */
  70089. length: number;
  70090. }
  70091. /**
  70092. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70093. */
  70094. export class SmartArray<T> implements ISmartArrayLike<T> {
  70095. /**
  70096. * The full set of data from the array.
  70097. */
  70098. data: Array<T>;
  70099. /**
  70100. * The active length of the array.
  70101. */
  70102. length: number;
  70103. protected _id: number;
  70104. /**
  70105. * Instantiates a Smart Array.
  70106. * @param capacity defines the default capacity of the array.
  70107. */
  70108. constructor(capacity: number);
  70109. /**
  70110. * Pushes a value at the end of the active data.
  70111. * @param value defines the object to push in the array.
  70112. */
  70113. push(value: T): void;
  70114. /**
  70115. * Iterates over the active data and apply the lambda to them.
  70116. * @param func defines the action to apply on each value.
  70117. */
  70118. forEach(func: (content: T) => void): void;
  70119. /**
  70120. * Sorts the full sets of data.
  70121. * @param compareFn defines the comparison function to apply.
  70122. */
  70123. sort(compareFn: (a: T, b: T) => number): void;
  70124. /**
  70125. * Resets the active data to an empty array.
  70126. */
  70127. reset(): void;
  70128. /**
  70129. * Releases all the data from the array as well as the array.
  70130. */
  70131. dispose(): void;
  70132. /**
  70133. * Concats the active data with a given array.
  70134. * @param array defines the data to concatenate with.
  70135. */
  70136. concat(array: any): void;
  70137. /**
  70138. * Returns the position of a value in the active data.
  70139. * @param value defines the value to find the index for
  70140. * @returns the index if found in the active data otherwise -1
  70141. */
  70142. indexOf(value: T): number;
  70143. /**
  70144. * Returns whether an element is part of the active data.
  70145. * @param value defines the value to look for
  70146. * @returns true if found in the active data otherwise false
  70147. */
  70148. contains(value: T): boolean;
  70149. private static _GlobalId;
  70150. }
  70151. /**
  70152. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70153. * The data in this array can only be present once
  70154. */
  70155. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70156. private _duplicateId;
  70157. /**
  70158. * Pushes a value at the end of the active data.
  70159. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70160. * @param value defines the object to push in the array.
  70161. */
  70162. push(value: T): void;
  70163. /**
  70164. * Pushes a value at the end of the active data.
  70165. * If the data is already present, it won t be added again
  70166. * @param value defines the object to push in the array.
  70167. * @returns true if added false if it was already present
  70168. */
  70169. pushNoDuplicate(value: T): boolean;
  70170. /**
  70171. * Resets the active data to an empty array.
  70172. */
  70173. reset(): void;
  70174. /**
  70175. * Concats the active data with a given array.
  70176. * This ensures no dupplicate will be present in the result.
  70177. * @param array defines the data to concatenate with.
  70178. */
  70179. concatWithNoDuplicate(array: any): void;
  70180. }
  70181. }
  70182. declare module BABYLON {
  70183. /**
  70184. * Enum that determines the text-wrapping mode to use.
  70185. */
  70186. export enum InspectableType {
  70187. /**
  70188. * Checkbox for booleans
  70189. */
  70190. Checkbox = 0,
  70191. /**
  70192. * Sliders for numbers
  70193. */
  70194. Slider = 1,
  70195. /**
  70196. * Vector3
  70197. */
  70198. Vector3 = 2,
  70199. /**
  70200. * Quaternions
  70201. */
  70202. Quaternion = 3,
  70203. /**
  70204. * Color3
  70205. */
  70206. Color3 = 4
  70207. }
  70208. /**
  70209. * Interface used to define custom inspectable properties.
  70210. * This interface is used by the inspector to display custom property grids
  70211. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70212. */
  70213. export interface IInspectable {
  70214. /**
  70215. * Gets the label to display
  70216. */
  70217. label: string;
  70218. /**
  70219. * Gets the name of the property to edit
  70220. */
  70221. propertyName: string;
  70222. /**
  70223. * Gets the type of the editor to use
  70224. */
  70225. type: InspectableType;
  70226. /**
  70227. * Gets the minimum value of the property when using in "slider" mode
  70228. */
  70229. min?: number;
  70230. /**
  70231. * Gets the maximum value of the property when using in "slider" mode
  70232. */
  70233. max?: number;
  70234. /**
  70235. * Gets the setp to use when using in "slider" mode
  70236. */
  70237. step?: number;
  70238. }
  70239. }
  70240. declare module BABYLON {
  70241. /**
  70242. * This represents the required contract to create a new type of texture loader.
  70243. */
  70244. export interface IInternalTextureLoader {
  70245. /**
  70246. * Defines wether the loader supports cascade loading the different faces.
  70247. */
  70248. supportCascades: boolean;
  70249. /**
  70250. * This returns if the loader support the current file information.
  70251. * @param extension defines the file extension of the file being loaded
  70252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70253. * @param fallback defines the fallback internal texture if any
  70254. * @param isBase64 defines whether the texture is encoded as a base64
  70255. * @param isBuffer defines whether the texture data are stored as a buffer
  70256. * @returns true if the loader can load the specified file
  70257. */
  70258. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70259. /**
  70260. * Transform the url before loading if required.
  70261. * @param rootUrl the url of the texture
  70262. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70263. * @returns the transformed texture
  70264. */
  70265. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70266. /**
  70267. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70268. * @param rootUrl the url of the texture
  70269. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70270. * @returns the fallback texture
  70271. */
  70272. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70273. /**
  70274. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70275. * @param data contains the texture data
  70276. * @param texture defines the BabylonJS internal texture
  70277. * @param createPolynomials will be true if polynomials have been requested
  70278. * @param onLoad defines the callback to trigger once the texture is ready
  70279. * @param onError defines the callback to trigger in case of error
  70280. */
  70281. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70282. /**
  70283. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70284. * @param data contains the texture data
  70285. * @param texture defines the BabylonJS internal texture
  70286. * @param callback defines the method to call once ready to upload
  70287. */
  70288. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. interface Engine {
  70293. /**
  70294. * Creates a depth stencil cube texture.
  70295. * This is only available in WebGL 2.
  70296. * @param size The size of face edge in the cube texture.
  70297. * @param options The options defining the cube texture.
  70298. * @returns The cube texture
  70299. */
  70300. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70301. /**
  70302. * Creates a cube texture
  70303. * @param rootUrl defines the url where the files to load is located
  70304. * @param scene defines the current scene
  70305. * @param files defines the list of files to load (1 per face)
  70306. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70307. * @param onLoad defines an optional callback raised when the texture is loaded
  70308. * @param onError defines an optional callback raised if there is an issue to load the texture
  70309. * @param format defines the format of the data
  70310. * @param forcedExtension defines the extension to use to pick the right loader
  70311. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70312. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70313. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70314. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70315. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70316. * @returns the cube texture as an InternalTexture
  70317. */
  70318. 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;
  70319. /**
  70320. * Creates a cube texture
  70321. * @param rootUrl defines the url where the files to load is located
  70322. * @param scene defines the current scene
  70323. * @param files defines the list of files to load (1 per face)
  70324. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70325. * @param onLoad defines an optional callback raised when the texture is loaded
  70326. * @param onError defines an optional callback raised if there is an issue to load the texture
  70327. * @param format defines the format of the data
  70328. * @param forcedExtension defines the extension to use to pick the right loader
  70329. * @returns the cube texture as an InternalTexture
  70330. */
  70331. 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;
  70332. /**
  70333. * Creates a cube texture
  70334. * @param rootUrl defines the url where the files to load is located
  70335. * @param scene defines the current scene
  70336. * @param files defines the list of files to load (1 per face)
  70337. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70338. * @param onLoad defines an optional callback raised when the texture is loaded
  70339. * @param onError defines an optional callback raised if there is an issue to load the texture
  70340. * @param format defines the format of the data
  70341. * @param forcedExtension defines the extension to use to pick the right loader
  70342. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70343. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70344. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70345. * @returns the cube texture as an InternalTexture
  70346. */
  70347. 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;
  70348. /** @hidden */
  70349. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70350. /** @hidden */
  70351. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70352. /** @hidden */
  70353. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70354. /** @hidden */
  70355. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70356. }
  70357. }
  70358. declare module BABYLON {
  70359. /**
  70360. * Class for creating a cube texture
  70361. */
  70362. export class CubeTexture extends BaseTexture {
  70363. private _delayedOnLoad;
  70364. /**
  70365. * The url of the texture
  70366. */
  70367. url: string;
  70368. /**
  70369. * Gets or sets the center of the bounding box associated with the cube texture.
  70370. * It must define where the camera used to render the texture was set
  70371. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70372. */
  70373. boundingBoxPosition: Vector3;
  70374. private _boundingBoxSize;
  70375. /**
  70376. * Gets or sets the size of the bounding box associated with the cube texture
  70377. * When defined, the cubemap will switch to local mode
  70378. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70379. * @example https://www.babylonjs-playground.com/#RNASML
  70380. */
  70381. /**
  70382. * Returns the bounding box size
  70383. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70384. */
  70385. boundingBoxSize: Vector3;
  70386. protected _rotationY: number;
  70387. /**
  70388. * Sets texture matrix rotation angle around Y axis in radians.
  70389. */
  70390. /**
  70391. * Gets texture matrix rotation angle around Y axis radians.
  70392. */
  70393. rotationY: number;
  70394. /**
  70395. * Are mip maps generated for this texture or not.
  70396. */
  70397. readonly noMipmap: boolean;
  70398. private _noMipmap;
  70399. private _files;
  70400. private _extensions;
  70401. private _textureMatrix;
  70402. private _format;
  70403. private _createPolynomials;
  70404. /** @hidden */
  70405. _prefiltered: boolean;
  70406. /**
  70407. * Creates a cube texture from an array of image urls
  70408. * @param files defines an array of image urls
  70409. * @param scene defines the hosting scene
  70410. * @param noMipmap specifies if mip maps are not used
  70411. * @returns a cube texture
  70412. */
  70413. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70414. /**
  70415. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70416. * @param url defines the url of the prefiltered texture
  70417. * @param scene defines the scene the texture is attached to
  70418. * @param forcedExtension defines the extension of the file if different from the url
  70419. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70420. * @return the prefiltered texture
  70421. */
  70422. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70423. /**
  70424. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70425. * as prefiltered data.
  70426. * @param rootUrl defines the url of the texture or the root name of the six images
  70427. * @param scene defines the scene the texture is attached to
  70428. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70429. * @param noMipmap defines if mipmaps should be created or not
  70430. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70431. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70432. * @param onError defines a callback triggered in case of error during load
  70433. * @param format defines the internal format to use for the texture once loaded
  70434. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70435. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70436. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70437. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70438. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70439. * @return the cube texture
  70440. */
  70441. 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);
  70442. /**
  70443. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70444. */
  70445. readonly isPrefiltered: boolean;
  70446. /**
  70447. * Get the current class name of the texture useful for serialization or dynamic coding.
  70448. * @returns "CubeTexture"
  70449. */
  70450. getClassName(): string;
  70451. /**
  70452. * Update the url (and optional buffer) of this texture if url was null during construction.
  70453. * @param url the url of the texture
  70454. * @param forcedExtension defines the extension to use
  70455. * @param onLoad callback called when the texture is loaded (defaults to null)
  70456. */
  70457. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70458. /**
  70459. * Delays loading of the cube texture
  70460. * @param forcedExtension defines the extension to use
  70461. */
  70462. delayLoad(forcedExtension?: string): void;
  70463. /**
  70464. * Returns the reflection texture matrix
  70465. * @returns the reflection texture matrix
  70466. */
  70467. getReflectionTextureMatrix(): Matrix;
  70468. /**
  70469. * Sets the reflection texture matrix
  70470. * @param value Reflection texture matrix
  70471. */
  70472. setReflectionTextureMatrix(value: Matrix): void;
  70473. /**
  70474. * Parses text to create a cube texture
  70475. * @param parsedTexture define the serialized text to read from
  70476. * @param scene defines the hosting scene
  70477. * @param rootUrl defines the root url of the cube texture
  70478. * @returns a cube texture
  70479. */
  70480. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70481. /**
  70482. * Makes a clone, or deep copy, of the cube texture
  70483. * @returns a new cube texture
  70484. */
  70485. clone(): CubeTexture;
  70486. }
  70487. }
  70488. declare module BABYLON {
  70489. /** @hidden */
  70490. export var postprocessVertexShader: {
  70491. name: string;
  70492. shader: string;
  70493. };
  70494. }
  70495. declare module BABYLON {
  70496. /**
  70497. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70498. * This is the base of the follow, arc rotate cameras and Free camera
  70499. * @see http://doc.babylonjs.com/features/cameras
  70500. */
  70501. export class TargetCamera extends Camera {
  70502. private static _RigCamTransformMatrix;
  70503. private static _TargetTransformMatrix;
  70504. private static _TargetFocalPoint;
  70505. /**
  70506. * Define the current direction the camera is moving to
  70507. */
  70508. cameraDirection: Vector3;
  70509. /**
  70510. * Define the current rotation the camera is rotating to
  70511. */
  70512. cameraRotation: Vector2;
  70513. /**
  70514. * When set, the up vector of the camera will be updated by the rotation of the camera
  70515. */
  70516. updateUpVectorFromRotation: boolean;
  70517. private _tmpQuaternion;
  70518. /**
  70519. * Define the current rotation of the camera
  70520. */
  70521. rotation: Vector3;
  70522. /**
  70523. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70524. */
  70525. rotationQuaternion: Quaternion;
  70526. /**
  70527. * Define the current speed of the camera
  70528. */
  70529. speed: number;
  70530. /**
  70531. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70532. * around all axis.
  70533. */
  70534. noRotationConstraint: boolean;
  70535. /**
  70536. * Define the current target of the camera as an object or a position.
  70537. */
  70538. lockedTarget: any;
  70539. /** @hidden */
  70540. _currentTarget: Vector3;
  70541. /** @hidden */
  70542. _initialFocalDistance: number;
  70543. /** @hidden */
  70544. _viewMatrix: Matrix;
  70545. /** @hidden */
  70546. _camMatrix: Matrix;
  70547. /** @hidden */
  70548. _cameraTransformMatrix: Matrix;
  70549. /** @hidden */
  70550. _cameraRotationMatrix: Matrix;
  70551. /** @hidden */
  70552. _referencePoint: Vector3;
  70553. /** @hidden */
  70554. _transformedReferencePoint: Vector3;
  70555. protected _globalCurrentTarget: Vector3;
  70556. protected _globalCurrentUpVector: Vector3;
  70557. /** @hidden */
  70558. _reset: () => void;
  70559. private _defaultUp;
  70560. /**
  70561. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70562. * This is the base of the follow, arc rotate cameras and Free camera
  70563. * @see http://doc.babylonjs.com/features/cameras
  70564. * @param name Defines the name of the camera in the scene
  70565. * @param position Defines the start position of the camera in the scene
  70566. * @param scene Defines the scene the camera belongs to
  70567. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70568. */
  70569. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70570. /**
  70571. * Gets the position in front of the camera at a given distance.
  70572. * @param distance The distance from the camera we want the position to be
  70573. * @returns the position
  70574. */
  70575. getFrontPosition(distance: number): Vector3;
  70576. /** @hidden */
  70577. _getLockedTargetPosition(): Nullable<Vector3>;
  70578. private _storedPosition;
  70579. private _storedRotation;
  70580. private _storedRotationQuaternion;
  70581. /**
  70582. * Store current camera state of the camera (fov, position, rotation, etc..)
  70583. * @returns the camera
  70584. */
  70585. storeState(): Camera;
  70586. /**
  70587. * Restored camera state. You must call storeState() first
  70588. * @returns whether it was successful or not
  70589. * @hidden
  70590. */
  70591. _restoreStateValues(): boolean;
  70592. /** @hidden */
  70593. _initCache(): void;
  70594. /** @hidden */
  70595. _updateCache(ignoreParentClass?: boolean): void;
  70596. /** @hidden */
  70597. _isSynchronizedViewMatrix(): boolean;
  70598. /** @hidden */
  70599. _computeLocalCameraSpeed(): number;
  70600. /**
  70601. * Defines the target the camera should look at.
  70602. * @param target Defines the new target as a Vector or a mesh
  70603. */
  70604. setTarget(target: Vector3): void;
  70605. /**
  70606. * Return the current target position of the camera. This value is expressed in local space.
  70607. * @returns the target position
  70608. */
  70609. getTarget(): Vector3;
  70610. /** @hidden */
  70611. _decideIfNeedsToMove(): boolean;
  70612. /** @hidden */
  70613. _updatePosition(): void;
  70614. /** @hidden */
  70615. _checkInputs(): void;
  70616. protected _updateCameraRotationMatrix(): void;
  70617. /**
  70618. * 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)
  70619. * @returns the current camera
  70620. */
  70621. private _rotateUpVectorWithCameraRotationMatrix;
  70622. private _cachedRotationZ;
  70623. private _cachedQuaternionRotationZ;
  70624. /** @hidden */
  70625. _getViewMatrix(): Matrix;
  70626. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70627. /**
  70628. * @hidden
  70629. */
  70630. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70631. /**
  70632. * @hidden
  70633. */
  70634. _updateRigCameras(): void;
  70635. private _getRigCamPositionAndTarget;
  70636. /**
  70637. * Gets the current object class name.
  70638. * @return the class name
  70639. */
  70640. getClassName(): string;
  70641. }
  70642. }
  70643. declare module BABYLON {
  70644. /**
  70645. * @ignore
  70646. * This is a list of all the different input types that are available in the application.
  70647. * Fo instance: ArcRotateCameraGamepadInput...
  70648. */
  70649. export var CameraInputTypes: {};
  70650. /**
  70651. * This is the contract to implement in order to create a new input class.
  70652. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70653. */
  70654. export interface ICameraInput<TCamera extends Camera> {
  70655. /**
  70656. * Defines the camera the input is attached to.
  70657. */
  70658. camera: Nullable<TCamera>;
  70659. /**
  70660. * Gets the class name of the current intput.
  70661. * @returns the class name
  70662. */
  70663. getClassName(): string;
  70664. /**
  70665. * Get the friendly name associated with the input class.
  70666. * @returns the input friendly name
  70667. */
  70668. getSimpleName(): string;
  70669. /**
  70670. * Attach the input controls to a specific dom element to get the input from.
  70671. * @param element Defines the element the controls should be listened from
  70672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70673. */
  70674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70675. /**
  70676. * Detach the current controls from the specified dom element.
  70677. * @param element Defines the element to stop listening the inputs from
  70678. */
  70679. detachControl(element: Nullable<HTMLElement>): void;
  70680. /**
  70681. * Update the current camera state depending on the inputs that have been used this frame.
  70682. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70683. */
  70684. checkInputs?: () => void;
  70685. }
  70686. /**
  70687. * Represents a map of input types to input instance or input index to input instance.
  70688. */
  70689. export interface CameraInputsMap<TCamera extends Camera> {
  70690. /**
  70691. * Accessor to the input by input type.
  70692. */
  70693. [name: string]: ICameraInput<TCamera>;
  70694. /**
  70695. * Accessor to the input by input index.
  70696. */
  70697. [idx: number]: ICameraInput<TCamera>;
  70698. }
  70699. /**
  70700. * This represents the input manager used within a camera.
  70701. * It helps dealing with all the different kind of input attached to a camera.
  70702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70703. */
  70704. export class CameraInputsManager<TCamera extends Camera> {
  70705. /**
  70706. * Defines the list of inputs attahed to the camera.
  70707. */
  70708. attached: CameraInputsMap<TCamera>;
  70709. /**
  70710. * Defines the dom element the camera is collecting inputs from.
  70711. * This is null if the controls have not been attached.
  70712. */
  70713. attachedElement: Nullable<HTMLElement>;
  70714. /**
  70715. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70716. */
  70717. noPreventDefault: boolean;
  70718. /**
  70719. * Defined the camera the input manager belongs to.
  70720. */
  70721. camera: TCamera;
  70722. /**
  70723. * Update the current camera state depending on the inputs that have been used this frame.
  70724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70725. */
  70726. checkInputs: () => void;
  70727. /**
  70728. * Instantiate a new Camera Input Manager.
  70729. * @param camera Defines the camera the input manager blongs to
  70730. */
  70731. constructor(camera: TCamera);
  70732. /**
  70733. * Add an input method to a camera
  70734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70735. * @param input camera input method
  70736. */
  70737. add(input: ICameraInput<TCamera>): void;
  70738. /**
  70739. * Remove a specific input method from a camera
  70740. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70741. * @param inputToRemove camera input method
  70742. */
  70743. remove(inputToRemove: ICameraInput<TCamera>): void;
  70744. /**
  70745. * Remove a specific input type from a camera
  70746. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70747. * @param inputType the type of the input to remove
  70748. */
  70749. removeByType(inputType: string): void;
  70750. private _addCheckInputs;
  70751. /**
  70752. * Attach the input controls to the currently attached dom element to listen the events from.
  70753. * @param input Defines the input to attach
  70754. */
  70755. attachInput(input: ICameraInput<TCamera>): void;
  70756. /**
  70757. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70758. * @param element Defines the dom element to collect the events from
  70759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70760. */
  70761. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70762. /**
  70763. * Detach the current manager inputs controls from a specific dom element.
  70764. * @param element Defines the dom element to collect the events from
  70765. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70766. */
  70767. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70768. /**
  70769. * Rebuild the dynamic inputCheck function from the current list of
  70770. * defined inputs in the manager.
  70771. */
  70772. rebuildInputCheck(): void;
  70773. /**
  70774. * Remove all attached input methods from a camera
  70775. */
  70776. clear(): void;
  70777. /**
  70778. * Serialize the current input manager attached to a camera.
  70779. * This ensures than once parsed,
  70780. * the input associated to the camera will be identical to the current ones
  70781. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70782. */
  70783. serialize(serializedCamera: any): void;
  70784. /**
  70785. * Parses an input manager serialized JSON to restore the previous list of inputs
  70786. * and states associated to a camera.
  70787. * @param parsedCamera Defines the JSON to parse
  70788. */
  70789. parse(parsedCamera: any): void;
  70790. }
  70791. }
  70792. declare module BABYLON {
  70793. /**
  70794. * Gather the list of keyboard event types as constants.
  70795. */
  70796. export class KeyboardEventTypes {
  70797. /**
  70798. * The keydown event is fired when a key becomes active (pressed).
  70799. */
  70800. static readonly KEYDOWN: number;
  70801. /**
  70802. * The keyup event is fired when a key has been released.
  70803. */
  70804. static readonly KEYUP: number;
  70805. }
  70806. /**
  70807. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70808. */
  70809. export class KeyboardInfo {
  70810. /**
  70811. * Defines the type of event (KeyboardEventTypes)
  70812. */
  70813. type: number;
  70814. /**
  70815. * Defines the related dom event
  70816. */
  70817. event: KeyboardEvent;
  70818. /**
  70819. * Instantiates a new keyboard info.
  70820. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70821. * @param type Defines the type of event (KeyboardEventTypes)
  70822. * @param event Defines the related dom event
  70823. */
  70824. constructor(
  70825. /**
  70826. * Defines the type of event (KeyboardEventTypes)
  70827. */
  70828. type: number,
  70829. /**
  70830. * Defines the related dom event
  70831. */
  70832. event: KeyboardEvent);
  70833. }
  70834. /**
  70835. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70836. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70837. */
  70838. export class KeyboardInfoPre extends KeyboardInfo {
  70839. /**
  70840. * Defines the type of event (KeyboardEventTypes)
  70841. */
  70842. type: number;
  70843. /**
  70844. * Defines the related dom event
  70845. */
  70846. event: KeyboardEvent;
  70847. /**
  70848. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70849. */
  70850. skipOnPointerObservable: boolean;
  70851. /**
  70852. * Instantiates a new keyboard pre info.
  70853. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70854. * @param type Defines the type of event (KeyboardEventTypes)
  70855. * @param event Defines the related dom event
  70856. */
  70857. constructor(
  70858. /**
  70859. * Defines the type of event (KeyboardEventTypes)
  70860. */
  70861. type: number,
  70862. /**
  70863. * Defines the related dom event
  70864. */
  70865. event: KeyboardEvent);
  70866. }
  70867. }
  70868. declare module BABYLON {
  70869. /**
  70870. * Manage the keyboard inputs to control the movement of a free camera.
  70871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70872. */
  70873. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70874. /**
  70875. * Defines the camera the input is attached to.
  70876. */
  70877. camera: FreeCamera;
  70878. /**
  70879. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70880. */
  70881. keysUp: number[];
  70882. /**
  70883. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70884. */
  70885. keysDown: number[];
  70886. /**
  70887. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70888. */
  70889. keysLeft: number[];
  70890. /**
  70891. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70892. */
  70893. keysRight: number[];
  70894. private _keys;
  70895. private _onCanvasBlurObserver;
  70896. private _onKeyboardObserver;
  70897. private _engine;
  70898. private _scene;
  70899. /**
  70900. * Attach the input controls to a specific dom element to get the input from.
  70901. * @param element Defines the element the controls should be listened from
  70902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70903. */
  70904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70905. /**
  70906. * Detach the current controls from the specified dom element.
  70907. * @param element Defines the element to stop listening the inputs from
  70908. */
  70909. detachControl(element: Nullable<HTMLElement>): void;
  70910. /**
  70911. * Update the current camera state depending on the inputs that have been used this frame.
  70912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70913. */
  70914. checkInputs(): void;
  70915. /**
  70916. * Gets the class name of the current intput.
  70917. * @returns the class name
  70918. */
  70919. getClassName(): string;
  70920. /** @hidden */
  70921. _onLostFocus(): void;
  70922. /**
  70923. * Get the friendly name associated with the input class.
  70924. * @returns the input friendly name
  70925. */
  70926. getSimpleName(): string;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70932. * separate meshes. This can be use to improve performances.
  70933. * @see http://doc.babylonjs.com/how_to/multi_materials
  70934. */
  70935. export class MultiMaterial extends Material {
  70936. private _subMaterials;
  70937. /**
  70938. * Gets or Sets the list of Materials used within the multi material.
  70939. * They need to be ordered according to the submeshes order in the associated mesh
  70940. */
  70941. subMaterials: Nullable<Material>[];
  70942. /**
  70943. * Function used to align with Node.getChildren()
  70944. * @returns the list of Materials used within the multi material
  70945. */
  70946. getChildren(): Nullable<Material>[];
  70947. /**
  70948. * Instantiates a new Multi Material
  70949. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70950. * separate meshes. This can be use to improve performances.
  70951. * @see http://doc.babylonjs.com/how_to/multi_materials
  70952. * @param name Define the name in the scene
  70953. * @param scene Define the scene the material belongs to
  70954. */
  70955. constructor(name: string, scene: Scene);
  70956. private _hookArray;
  70957. /**
  70958. * Get one of the submaterial by its index in the submaterials array
  70959. * @param index The index to look the sub material at
  70960. * @returns The Material if the index has been defined
  70961. */
  70962. getSubMaterial(index: number): Nullable<Material>;
  70963. /**
  70964. * Get the list of active textures for the whole sub materials list.
  70965. * @returns All the textures that will be used during the rendering
  70966. */
  70967. getActiveTextures(): BaseTexture[];
  70968. /**
  70969. * Gets the current class name of the material e.g. "MultiMaterial"
  70970. * Mainly use in serialization.
  70971. * @returns the class name
  70972. */
  70973. getClassName(): string;
  70974. /**
  70975. * Checks if the material is ready to render the requested sub mesh
  70976. * @param mesh Define the mesh the submesh belongs to
  70977. * @param subMesh Define the sub mesh to look readyness for
  70978. * @param useInstances Define whether or not the material is used with instances
  70979. * @returns true if ready, otherwise false
  70980. */
  70981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70982. /**
  70983. * Clones the current material and its related sub materials
  70984. * @param name Define the name of the newly cloned material
  70985. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70986. * @returns the cloned material
  70987. */
  70988. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70989. /**
  70990. * Serializes the materials into a JSON representation.
  70991. * @returns the JSON representation
  70992. */
  70993. serialize(): any;
  70994. /**
  70995. * Dispose the material and release its associated resources
  70996. * @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)
  70997. * @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)
  70998. * @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)
  70999. */
  71000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  71001. /**
  71002. * Creates a MultiMaterial from parsed MultiMaterial data.
  71003. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  71004. * @param scene defines the hosting scene
  71005. * @returns a new MultiMaterial
  71006. */
  71007. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  71008. }
  71009. }
  71010. declare module BABYLON {
  71011. /**
  71012. * Class used to represent data loading progression
  71013. */
  71014. export class SceneLoaderFlags {
  71015. private static _ForceFullSceneLoadingForIncremental;
  71016. private static _ShowLoadingScreen;
  71017. private static _CleanBoneMatrixWeights;
  71018. private static _loggingLevel;
  71019. /**
  71020. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  71021. */
  71022. static ForceFullSceneLoadingForIncremental: boolean;
  71023. /**
  71024. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71025. */
  71026. static ShowLoadingScreen: boolean;
  71027. /**
  71028. * Defines the current logging level (while loading the scene)
  71029. * @ignorenaming
  71030. */
  71031. static loggingLevel: number;
  71032. /**
  71033. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71034. */
  71035. static CleanBoneMatrixWeights: boolean;
  71036. }
  71037. }
  71038. declare module BABYLON {
  71039. /**
  71040. * 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.
  71041. * @see https://doc.babylonjs.com/how_to/transformnode
  71042. */
  71043. export class TransformNode extends Node {
  71044. /**
  71045. * Object will not rotate to face the camera
  71046. */
  71047. static BILLBOARDMODE_NONE: number;
  71048. /**
  71049. * Object will rotate to face the camera but only on the x axis
  71050. */
  71051. static BILLBOARDMODE_X: number;
  71052. /**
  71053. * Object will rotate to face the camera but only on the y axis
  71054. */
  71055. static BILLBOARDMODE_Y: number;
  71056. /**
  71057. * Object will rotate to face the camera but only on the z axis
  71058. */
  71059. static BILLBOARDMODE_Z: number;
  71060. /**
  71061. * Object will rotate to face the camera
  71062. */
  71063. static BILLBOARDMODE_ALL: number;
  71064. private _forward;
  71065. private _forwardInverted;
  71066. private _up;
  71067. private _right;
  71068. private _rightInverted;
  71069. private _position;
  71070. private _rotation;
  71071. private _rotationQuaternion;
  71072. protected _scaling: Vector3;
  71073. protected _isDirty: boolean;
  71074. private _transformToBoneReferal;
  71075. private _billboardMode;
  71076. /**
  71077. * Gets or sets the billboard mode. Default is 0.
  71078. *
  71079. * | Value | Type | Description |
  71080. * | --- | --- | --- |
  71081. * | 0 | BILLBOARDMODE_NONE | |
  71082. * | 1 | BILLBOARDMODE_X | |
  71083. * | 2 | BILLBOARDMODE_Y | |
  71084. * | 4 | BILLBOARDMODE_Z | |
  71085. * | 7 | BILLBOARDMODE_ALL | |
  71086. *
  71087. */
  71088. billboardMode: number;
  71089. private _preserveParentRotationForBillboard;
  71090. /**
  71091. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71092. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71093. */
  71094. preserveParentRotationForBillboard: boolean;
  71095. /**
  71096. * 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
  71097. */
  71098. scalingDeterminant: number;
  71099. private _infiniteDistance;
  71100. /**
  71101. * Gets or sets the distance of the object to max, often used by skybox
  71102. */
  71103. infiniteDistance: boolean;
  71104. /**
  71105. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71106. * By default the system will update normals to compensate
  71107. */
  71108. ignoreNonUniformScaling: boolean;
  71109. /**
  71110. * 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
  71111. */
  71112. reIntegrateRotationIntoRotationQuaternion: boolean;
  71113. /** @hidden */
  71114. _poseMatrix: Nullable<Matrix>;
  71115. /** @hidden */
  71116. _localMatrix: Matrix;
  71117. private _usePivotMatrix;
  71118. private _absolutePosition;
  71119. private _pivotMatrix;
  71120. private _pivotMatrixInverse;
  71121. protected _postMultiplyPivotMatrix: boolean;
  71122. protected _isWorldMatrixFrozen: boolean;
  71123. /** @hidden */
  71124. _indexInSceneTransformNodesArray: number;
  71125. /**
  71126. * An event triggered after the world matrix is updated
  71127. */
  71128. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71129. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71130. /**
  71131. * Gets a string identifying the name of the class
  71132. * @returns "TransformNode" string
  71133. */
  71134. getClassName(): string;
  71135. /**
  71136. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71137. */
  71138. position: Vector3;
  71139. /**
  71140. * 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)).
  71141. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71142. */
  71143. rotation: Vector3;
  71144. /**
  71145. * 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)).
  71146. */
  71147. scaling: Vector3;
  71148. /**
  71149. * 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).
  71150. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71151. */
  71152. rotationQuaternion: Nullable<Quaternion>;
  71153. /**
  71154. * The forward direction of that transform in world space.
  71155. */
  71156. readonly forward: Vector3;
  71157. /**
  71158. * The up direction of that transform in world space.
  71159. */
  71160. readonly up: Vector3;
  71161. /**
  71162. * The right direction of that transform in world space.
  71163. */
  71164. readonly right: Vector3;
  71165. /**
  71166. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71167. * @param matrix the matrix to copy the pose from
  71168. * @returns this TransformNode.
  71169. */
  71170. updatePoseMatrix(matrix: Matrix): TransformNode;
  71171. /**
  71172. * Returns the mesh Pose matrix.
  71173. * @returns the pose matrix
  71174. */
  71175. getPoseMatrix(): Matrix;
  71176. /** @hidden */
  71177. _isSynchronized(): boolean;
  71178. /** @hidden */
  71179. _initCache(): void;
  71180. /**
  71181. * Flag the transform node as dirty (Forcing it to update everything)
  71182. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71183. * @returns this transform node
  71184. */
  71185. markAsDirty(property: string): TransformNode;
  71186. /**
  71187. * Returns the current mesh absolute position.
  71188. * Returns a Vector3.
  71189. */
  71190. readonly absolutePosition: Vector3;
  71191. /**
  71192. * Sets a new matrix to apply before all other transformation
  71193. * @param matrix defines the transform matrix
  71194. * @returns the current TransformNode
  71195. */
  71196. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71197. /**
  71198. * Sets a new pivot matrix to the current node
  71199. * @param matrix defines the new pivot matrix to use
  71200. * @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
  71201. * @returns the current TransformNode
  71202. */
  71203. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71204. /**
  71205. * Returns the mesh pivot matrix.
  71206. * Default : Identity.
  71207. * @returns the matrix
  71208. */
  71209. getPivotMatrix(): Matrix;
  71210. /**
  71211. * Prevents the World matrix to be computed any longer.
  71212. * @returns the TransformNode.
  71213. */
  71214. freezeWorldMatrix(): TransformNode;
  71215. /**
  71216. * Allows back the World matrix computation.
  71217. * @returns the TransformNode.
  71218. */
  71219. unfreezeWorldMatrix(): this;
  71220. /**
  71221. * True if the World matrix has been frozen.
  71222. */
  71223. readonly isWorldMatrixFrozen: boolean;
  71224. /**
  71225. * Retuns the mesh absolute position in the World.
  71226. * @returns a Vector3.
  71227. */
  71228. getAbsolutePosition(): Vector3;
  71229. /**
  71230. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71231. * @param absolutePosition the absolute position to set
  71232. * @returns the TransformNode.
  71233. */
  71234. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71235. /**
  71236. * Sets the mesh position in its local space.
  71237. * @param vector3 the position to set in localspace
  71238. * @returns the TransformNode.
  71239. */
  71240. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71241. /**
  71242. * Returns the mesh position in the local space from the current World matrix values.
  71243. * @returns a new Vector3.
  71244. */
  71245. getPositionExpressedInLocalSpace(): Vector3;
  71246. /**
  71247. * Translates the mesh along the passed Vector3 in its local space.
  71248. * @param vector3 the distance to translate in localspace
  71249. * @returns the TransformNode.
  71250. */
  71251. locallyTranslate(vector3: Vector3): TransformNode;
  71252. private static _lookAtVectorCache;
  71253. /**
  71254. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71255. * @param targetPoint the position (must be in same space as current mesh) to look at
  71256. * @param yawCor optional yaw (y-axis) correction in radians
  71257. * @param pitchCor optional pitch (x-axis) correction in radians
  71258. * @param rollCor optional roll (z-axis) correction in radians
  71259. * @param space the choosen space of the target
  71260. * @returns the TransformNode.
  71261. */
  71262. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71263. /**
  71264. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71265. * This Vector3 is expressed in the World space.
  71266. * @param localAxis axis to rotate
  71267. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71268. */
  71269. getDirection(localAxis: Vector3): Vector3;
  71270. /**
  71271. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71272. * localAxis is expressed in the mesh local space.
  71273. * result is computed in the Wordl space from the mesh World matrix.
  71274. * @param localAxis axis to rotate
  71275. * @param result the resulting transformnode
  71276. * @returns this TransformNode.
  71277. */
  71278. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71279. /**
  71280. * Sets this transform node rotation to the given local axis.
  71281. * @param localAxis the axis in local space
  71282. * @param yawCor optional yaw (y-axis) correction in radians
  71283. * @param pitchCor optional pitch (x-axis) correction in radians
  71284. * @param rollCor optional roll (z-axis) correction in radians
  71285. * @returns this TransformNode
  71286. */
  71287. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71288. /**
  71289. * Sets a new pivot point to the current node
  71290. * @param point defines the new pivot point to use
  71291. * @param space defines if the point is in world or local space (local by default)
  71292. * @returns the current TransformNode
  71293. */
  71294. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71295. /**
  71296. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71297. * @returns the pivot point
  71298. */
  71299. getPivotPoint(): Vector3;
  71300. /**
  71301. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71302. * @param result the vector3 to store the result
  71303. * @returns this TransformNode.
  71304. */
  71305. getPivotPointToRef(result: Vector3): TransformNode;
  71306. /**
  71307. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71308. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71309. */
  71310. getAbsolutePivotPoint(): Vector3;
  71311. /**
  71312. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71313. * @param result vector3 to store the result
  71314. * @returns this TransformNode.
  71315. */
  71316. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71317. /**
  71318. * Defines the passed node as the parent of the current node.
  71319. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71320. * @see https://doc.babylonjs.com/how_to/parenting
  71321. * @param node the node ot set as the parent
  71322. * @returns this TransformNode.
  71323. */
  71324. setParent(node: Nullable<Node>): TransformNode;
  71325. private _nonUniformScaling;
  71326. /**
  71327. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71328. */
  71329. readonly nonUniformScaling: boolean;
  71330. /** @hidden */
  71331. _updateNonUniformScalingState(value: boolean): boolean;
  71332. /**
  71333. * Attach the current TransformNode to another TransformNode associated with a bone
  71334. * @param bone Bone affecting the TransformNode
  71335. * @param affectedTransformNode TransformNode associated with the bone
  71336. * @returns this object
  71337. */
  71338. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71339. /**
  71340. * Detach the transform node if its associated with a bone
  71341. * @returns this object
  71342. */
  71343. detachFromBone(): TransformNode;
  71344. private static _rotationAxisCache;
  71345. /**
  71346. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71347. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71348. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71349. * The passed axis is also normalized.
  71350. * @param axis the axis to rotate around
  71351. * @param amount the amount to rotate in radians
  71352. * @param space Space to rotate in (Default: local)
  71353. * @returns the TransformNode.
  71354. */
  71355. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71356. /**
  71357. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71358. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71359. * The passed axis is also normalized. .
  71360. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71361. * @param point the point to rotate around
  71362. * @param axis the axis to rotate around
  71363. * @param amount the amount to rotate in radians
  71364. * @returns the TransformNode
  71365. */
  71366. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71367. /**
  71368. * Translates the mesh along the axis vector for the passed distance in the given space.
  71369. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71370. * @param axis the axis to translate in
  71371. * @param distance the distance to translate
  71372. * @param space Space to rotate in (Default: local)
  71373. * @returns the TransformNode.
  71374. */
  71375. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71376. /**
  71377. * Adds a rotation step to the mesh current rotation.
  71378. * x, y, z are Euler angles expressed in radians.
  71379. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71380. * This means this rotation is made in the mesh local space only.
  71381. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71382. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71383. * ```javascript
  71384. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71385. * ```
  71386. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71387. * 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.
  71388. * @param x Rotation to add
  71389. * @param y Rotation to add
  71390. * @param z Rotation to add
  71391. * @returns the TransformNode.
  71392. */
  71393. addRotation(x: number, y: number, z: number): TransformNode;
  71394. /**
  71395. * @hidden
  71396. */
  71397. protected _getEffectiveParent(): Nullable<Node>;
  71398. /**
  71399. * Computes the world matrix of the node
  71400. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71401. * @returns the world matrix
  71402. */
  71403. computeWorldMatrix(force?: boolean): Matrix;
  71404. protected _afterComputeWorldMatrix(): void;
  71405. /**
  71406. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71407. * @param func callback function to add
  71408. *
  71409. * @returns the TransformNode.
  71410. */
  71411. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71412. /**
  71413. * Removes a registered callback function.
  71414. * @param func callback function to remove
  71415. * @returns the TransformNode.
  71416. */
  71417. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71418. /**
  71419. * Gets the position of the current mesh in camera space
  71420. * @param camera defines the camera to use
  71421. * @returns a position
  71422. */
  71423. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71424. /**
  71425. * Returns the distance from the mesh to the active camera
  71426. * @param camera defines the camera to use
  71427. * @returns the distance
  71428. */
  71429. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71430. /**
  71431. * Clone the current transform node
  71432. * @param name Name of the new clone
  71433. * @param newParent New parent for the clone
  71434. * @param doNotCloneChildren Do not clone children hierarchy
  71435. * @returns the new transform node
  71436. */
  71437. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71438. /**
  71439. * Serializes the objects information.
  71440. * @param currentSerializationObject defines the object to serialize in
  71441. * @returns the serialized object
  71442. */
  71443. serialize(currentSerializationObject?: any): any;
  71444. /**
  71445. * Returns a new TransformNode object parsed from the source provided.
  71446. * @param parsedTransformNode is the source.
  71447. * @param scene the scne the object belongs to
  71448. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71449. * @returns a new TransformNode object parsed from the source provided.
  71450. */
  71451. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71452. /**
  71453. * Get all child-transformNodes of this node
  71454. * @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
  71455. * @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
  71456. * @returns an array of TransformNode
  71457. */
  71458. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71459. /**
  71460. * Releases resources associated with this transform node.
  71461. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71462. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71463. */
  71464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71465. /**
  71466. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71467. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71468. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71469. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71470. * @returns the current mesh
  71471. */
  71472. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71473. }
  71474. }
  71475. declare module BABYLON {
  71476. /**
  71477. * Class used to override all child animations of a given target
  71478. */
  71479. export class AnimationPropertiesOverride {
  71480. /**
  71481. * Gets or sets a value indicating if animation blending must be used
  71482. */
  71483. enableBlending: boolean;
  71484. /**
  71485. * Gets or sets the blending speed to use when enableBlending is true
  71486. */
  71487. blendingSpeed: number;
  71488. /**
  71489. * Gets or sets the default loop mode to use
  71490. */
  71491. loopMode: number;
  71492. }
  71493. }
  71494. declare module BABYLON {
  71495. /**
  71496. * Class used to store bone information
  71497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71498. */
  71499. export class Bone extends Node {
  71500. /**
  71501. * defines the bone name
  71502. */
  71503. name: string;
  71504. private static _tmpVecs;
  71505. private static _tmpQuat;
  71506. private static _tmpMats;
  71507. /**
  71508. * Gets the list of child bones
  71509. */
  71510. children: Bone[];
  71511. /** Gets the animations associated with this bone */
  71512. animations: Animation[];
  71513. /**
  71514. * Gets or sets bone length
  71515. */
  71516. length: number;
  71517. /**
  71518. * @hidden Internal only
  71519. * Set this value to map this bone to a different index in the transform matrices
  71520. * Set this value to -1 to exclude the bone from the transform matrices
  71521. */
  71522. _index: Nullable<number>;
  71523. private _skeleton;
  71524. private _localMatrix;
  71525. private _restPose;
  71526. private _baseMatrix;
  71527. private _absoluteTransform;
  71528. private _invertedAbsoluteTransform;
  71529. private _parent;
  71530. private _scalingDeterminant;
  71531. private _worldTransform;
  71532. private _localScaling;
  71533. private _localRotation;
  71534. private _localPosition;
  71535. private _needToDecompose;
  71536. private _needToCompose;
  71537. /** @hidden */
  71538. _linkedTransformNode: Nullable<TransformNode>;
  71539. /** @hidden */
  71540. _waitingTransformNodeId: Nullable<string>;
  71541. /** @hidden */
  71542. /** @hidden */
  71543. _matrix: Matrix;
  71544. /**
  71545. * Create a new bone
  71546. * @param name defines the bone name
  71547. * @param skeleton defines the parent skeleton
  71548. * @param parentBone defines the parent (can be null if the bone is the root)
  71549. * @param localMatrix defines the local matrix
  71550. * @param restPose defines the rest pose matrix
  71551. * @param baseMatrix defines the base matrix
  71552. * @param index defines index of the bone in the hiearchy
  71553. */
  71554. constructor(
  71555. /**
  71556. * defines the bone name
  71557. */
  71558. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71559. /**
  71560. * Gets the current object class name.
  71561. * @return the class name
  71562. */
  71563. getClassName(): string;
  71564. /**
  71565. * Gets the parent skeleton
  71566. * @returns a skeleton
  71567. */
  71568. getSkeleton(): Skeleton;
  71569. /**
  71570. * Gets parent bone
  71571. * @returns a bone or null if the bone is the root of the bone hierarchy
  71572. */
  71573. getParent(): Nullable<Bone>;
  71574. /**
  71575. * Returns an array containing the root bones
  71576. * @returns an array containing the root bones
  71577. */
  71578. getChildren(): Array<Bone>;
  71579. /**
  71580. * Sets the parent bone
  71581. * @param parent defines the parent (can be null if the bone is the root)
  71582. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71583. */
  71584. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71585. /**
  71586. * Gets the local matrix
  71587. * @returns a matrix
  71588. */
  71589. getLocalMatrix(): Matrix;
  71590. /**
  71591. * Gets the base matrix (initial matrix which remains unchanged)
  71592. * @returns a matrix
  71593. */
  71594. getBaseMatrix(): Matrix;
  71595. /**
  71596. * Gets the rest pose matrix
  71597. * @returns a matrix
  71598. */
  71599. getRestPose(): Matrix;
  71600. /**
  71601. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71602. */
  71603. getWorldMatrix(): Matrix;
  71604. /**
  71605. * Sets the local matrix to rest pose matrix
  71606. */
  71607. returnToRest(): void;
  71608. /**
  71609. * Gets the inverse of the absolute transform matrix.
  71610. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71611. * @returns a matrix
  71612. */
  71613. getInvertedAbsoluteTransform(): Matrix;
  71614. /**
  71615. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71616. * @returns a matrix
  71617. */
  71618. getAbsoluteTransform(): Matrix;
  71619. /**
  71620. * Links with the given transform node.
  71621. * The local matrix of this bone is copied from the transform node every frame.
  71622. * @param transformNode defines the transform node to link to
  71623. */
  71624. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71625. /** Gets or sets current position (in local space) */
  71626. position: Vector3;
  71627. /** Gets or sets current rotation (in local space) */
  71628. rotation: Vector3;
  71629. /** Gets or sets current rotation quaternion (in local space) */
  71630. rotationQuaternion: Quaternion;
  71631. /** Gets or sets current scaling (in local space) */
  71632. scaling: Vector3;
  71633. /**
  71634. * Gets the animation properties override
  71635. */
  71636. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71637. private _decompose;
  71638. private _compose;
  71639. /**
  71640. * Update the base and local matrices
  71641. * @param matrix defines the new base or local matrix
  71642. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71643. * @param updateLocalMatrix defines if the local matrix should be updated
  71644. */
  71645. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71646. /** @hidden */
  71647. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71648. /**
  71649. * Flag the bone as dirty (Forcing it to update everything)
  71650. */
  71651. markAsDirty(): void;
  71652. /** @hidden */
  71653. _markAsDirtyAndCompose(): void;
  71654. private _markAsDirtyAndDecompose;
  71655. /**
  71656. * Translate the bone in local or world space
  71657. * @param vec The amount to translate the bone
  71658. * @param space The space that the translation is in
  71659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71660. */
  71661. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71662. /**
  71663. * Set the postion of the bone in local or world space
  71664. * @param position The position to set the bone
  71665. * @param space The space that the position is in
  71666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71667. */
  71668. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71669. /**
  71670. * Set the absolute position of the bone (world space)
  71671. * @param position The position to set the bone
  71672. * @param mesh The mesh that this bone is attached to
  71673. */
  71674. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71675. /**
  71676. * Scale the bone on the x, y and z axes (in local space)
  71677. * @param x The amount to scale the bone on the x axis
  71678. * @param y The amount to scale the bone on the y axis
  71679. * @param z The amount to scale the bone on the z axis
  71680. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71681. */
  71682. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71683. /**
  71684. * Set the bone scaling in local space
  71685. * @param scale defines the scaling vector
  71686. */
  71687. setScale(scale: Vector3): void;
  71688. /**
  71689. * Gets the current scaling in local space
  71690. * @returns the current scaling vector
  71691. */
  71692. getScale(): Vector3;
  71693. /**
  71694. * Gets the current scaling in local space and stores it in a target vector
  71695. * @param result defines the target vector
  71696. */
  71697. getScaleToRef(result: Vector3): void;
  71698. /**
  71699. * Set the yaw, pitch, and roll of the bone in local or world space
  71700. * @param yaw The rotation of the bone on the y axis
  71701. * @param pitch The rotation of the bone on the x axis
  71702. * @param roll The rotation of the bone on the z axis
  71703. * @param space The space that the axes of rotation are in
  71704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71705. */
  71706. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71707. /**
  71708. * Add a rotation to the bone on an axis in local or world space
  71709. * @param axis The axis to rotate the bone on
  71710. * @param amount The amount to rotate the bone
  71711. * @param space The space that the axis is in
  71712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71713. */
  71714. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71715. /**
  71716. * Set the rotation of the bone to a particular axis angle in local or world space
  71717. * @param axis The axis to rotate the bone on
  71718. * @param angle The angle that the bone should be rotated to
  71719. * @param space The space that the axis is in
  71720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71721. */
  71722. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71723. /**
  71724. * Set the euler rotation of the bone in local of world space
  71725. * @param rotation The euler rotation that the bone should be set to
  71726. * @param space The space that the rotation is in
  71727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71728. */
  71729. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71730. /**
  71731. * Set the quaternion rotation of the bone in local of world space
  71732. * @param quat The quaternion rotation that the bone should be set to
  71733. * @param space The space that the rotation is in
  71734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71735. */
  71736. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71737. /**
  71738. * Set the rotation matrix of the bone in local of world space
  71739. * @param rotMat The rotation matrix that the bone should be set to
  71740. * @param space The space that the rotation is in
  71741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71742. */
  71743. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71744. private _rotateWithMatrix;
  71745. private _getNegativeRotationToRef;
  71746. /**
  71747. * Get the position of the bone in local or world space
  71748. * @param space The space that the returned position is in
  71749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71750. * @returns The position of the bone
  71751. */
  71752. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71753. /**
  71754. * Copy the position of the bone to a vector3 in local or world space
  71755. * @param space The space that the returned position is in
  71756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71757. * @param result The vector3 to copy the position to
  71758. */
  71759. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71760. /**
  71761. * Get the absolute position of the bone (world space)
  71762. * @param mesh The mesh that this bone is attached to
  71763. * @returns The absolute position of the bone
  71764. */
  71765. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71766. /**
  71767. * Copy the absolute position of the bone (world space) to the result param
  71768. * @param mesh The mesh that this bone is attached to
  71769. * @param result The vector3 to copy the absolute position to
  71770. */
  71771. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71772. /**
  71773. * Compute the absolute transforms of this bone and its children
  71774. */
  71775. computeAbsoluteTransforms(): void;
  71776. /**
  71777. * Get the world direction from an axis that is in the local space of the bone
  71778. * @param localAxis The local direction that is used to compute the world direction
  71779. * @param mesh The mesh that this bone is attached to
  71780. * @returns The world direction
  71781. */
  71782. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71783. /**
  71784. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71785. * @param localAxis The local direction that is used to compute the world direction
  71786. * @param mesh The mesh that this bone is attached to
  71787. * @param result The vector3 that the world direction will be copied to
  71788. */
  71789. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71790. /**
  71791. * Get the euler rotation of the bone in local or world space
  71792. * @param space The space that the rotation should be in
  71793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71794. * @returns The euler rotation
  71795. */
  71796. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71797. /**
  71798. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71799. * @param space The space that the rotation should be in
  71800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71801. * @param result The vector3 that the rotation should be copied to
  71802. */
  71803. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71804. /**
  71805. * Get the quaternion rotation of the bone in either local or world space
  71806. * @param space The space that the rotation should be in
  71807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71808. * @returns The quaternion rotation
  71809. */
  71810. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71811. /**
  71812. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71813. * @param space The space that the rotation should be in
  71814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71815. * @param result The quaternion that the rotation should be copied to
  71816. */
  71817. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71818. /**
  71819. * Get the rotation matrix of the bone in local or world space
  71820. * @param space The space that the rotation should be in
  71821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71822. * @returns The rotation matrix
  71823. */
  71824. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71825. /**
  71826. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71827. * @param space The space that the rotation should be in
  71828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71829. * @param result The quaternion that the rotation should be copied to
  71830. */
  71831. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71832. /**
  71833. * Get the world position of a point that is in the local space of the bone
  71834. * @param position The local position
  71835. * @param mesh The mesh that this bone is attached to
  71836. * @returns The world position
  71837. */
  71838. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71839. /**
  71840. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71841. * @param position The local position
  71842. * @param mesh The mesh that this bone is attached to
  71843. * @param result The vector3 that the world position should be copied to
  71844. */
  71845. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71846. /**
  71847. * Get the local position of a point that is in world space
  71848. * @param position The world position
  71849. * @param mesh The mesh that this bone is attached to
  71850. * @returns The local position
  71851. */
  71852. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71853. /**
  71854. * Get the local position of a point that is in world space and copy it to the result param
  71855. * @param position The world position
  71856. * @param mesh The mesh that this bone is attached to
  71857. * @param result The vector3 that the local position should be copied to
  71858. */
  71859. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71860. }
  71861. }
  71862. declare module BABYLON {
  71863. interface Engine {
  71864. /**
  71865. * Creates a raw texture
  71866. * @param data defines the data to store in the texture
  71867. * @param width defines the width of the texture
  71868. * @param height defines the height of the texture
  71869. * @param format defines the format of the data
  71870. * @param generateMipMaps defines if the engine should generate the mip levels
  71871. * @param invertY defines if data must be stored with Y axis inverted
  71872. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71873. * @param compression defines the compression used (null by default)
  71874. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71875. * @returns the raw texture inside an InternalTexture
  71876. */
  71877. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71878. /**
  71879. * Update a raw texture
  71880. * @param texture defines the texture to update
  71881. * @param data defines the data to store in the texture
  71882. * @param format defines the format of the data
  71883. * @param invertY defines if data must be stored with Y axis inverted
  71884. */
  71885. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71886. /**
  71887. * Update a raw texture
  71888. * @param texture defines the texture to update
  71889. * @param data defines the data to store in the texture
  71890. * @param format defines the format of the data
  71891. * @param invertY defines if data must be stored with Y axis inverted
  71892. * @param compression defines the compression used (null by default)
  71893. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71894. */
  71895. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71896. /**
  71897. * Creates a new raw cube texture
  71898. * @param data defines the array of data to use to create each face
  71899. * @param size defines the size of the textures
  71900. * @param format defines the format of the data
  71901. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71902. * @param generateMipMaps defines if the engine should generate the mip levels
  71903. * @param invertY defines if data must be stored with Y axis inverted
  71904. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71905. * @param compression defines the compression used (null by default)
  71906. * @returns the cube texture as an InternalTexture
  71907. */
  71908. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71909. /**
  71910. * Update a raw cube texture
  71911. * @param texture defines the texture to udpdate
  71912. * @param data defines the data to store
  71913. * @param format defines the data format
  71914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71915. * @param invertY defines if data must be stored with Y axis inverted
  71916. */
  71917. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71918. /**
  71919. * Update a raw cube texture
  71920. * @param texture defines the texture to udpdate
  71921. * @param data defines the data to store
  71922. * @param format defines the data format
  71923. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71924. * @param invertY defines if data must be stored with Y axis inverted
  71925. * @param compression defines the compression used (null by default)
  71926. */
  71927. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71928. /**
  71929. * Update a raw cube texture
  71930. * @param texture defines the texture to udpdate
  71931. * @param data defines the data to store
  71932. * @param format defines the data format
  71933. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71934. * @param invertY defines if data must be stored with Y axis inverted
  71935. * @param compression defines the compression used (null by default)
  71936. * @param level defines which level of the texture to update
  71937. */
  71938. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71939. /**
  71940. * Creates a new raw cube texture from a specified url
  71941. * @param url defines the url where the data is located
  71942. * @param scene defines the current scene
  71943. * @param size defines the size of the textures
  71944. * @param format defines the format of the data
  71945. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71946. * @param noMipmap defines if the engine should avoid generating the mip levels
  71947. * @param callback defines a callback used to extract texture data from loaded data
  71948. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71949. * @param onLoad defines a callback called when texture is loaded
  71950. * @param onError defines a callback called if there is an error
  71951. * @returns the cube texture as an InternalTexture
  71952. */
  71953. 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;
  71954. /**
  71955. * Creates a new raw cube texture from a specified url
  71956. * @param url defines the url where the data is located
  71957. * @param scene defines the current scene
  71958. * @param size defines the size of the textures
  71959. * @param format defines the format of the data
  71960. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71961. * @param noMipmap defines if the engine should avoid generating the mip levels
  71962. * @param callback defines a callback used to extract texture data from loaded data
  71963. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71964. * @param onLoad defines a callback called when texture is loaded
  71965. * @param onError defines a callback called if there is an error
  71966. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71967. * @param invertY defines if data must be stored with Y axis inverted
  71968. * @returns the cube texture as an InternalTexture
  71969. */
  71970. 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;
  71971. /**
  71972. * Creates a new raw 3D texture
  71973. * @param data defines the data used to create the texture
  71974. * @param width defines the width of the texture
  71975. * @param height defines the height of the texture
  71976. * @param depth defines the depth of the texture
  71977. * @param format defines the format of the texture
  71978. * @param generateMipMaps defines if the engine must generate mip levels
  71979. * @param invertY defines if data must be stored with Y axis inverted
  71980. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71981. * @param compression defines the compressed used (can be null)
  71982. * @param textureType defines the compressed used (can be null)
  71983. * @returns a new raw 3D texture (stored in an InternalTexture)
  71984. */
  71985. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71986. /**
  71987. * Update a raw 3D texture
  71988. * @param texture defines the texture to update
  71989. * @param data defines the data to store
  71990. * @param format defines the data format
  71991. * @param invertY defines if data must be stored with Y axis inverted
  71992. */
  71993. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71994. /**
  71995. * Update a raw 3D texture
  71996. * @param texture defines the texture to update
  71997. * @param data defines the data to store
  71998. * @param format defines the data format
  71999. * @param invertY defines if data must be stored with Y axis inverted
  72000. * @param compression defines the used compression (can be null)
  72001. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  72002. */
  72003. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. /**
  72008. * Raw texture can help creating a texture directly from an array of data.
  72009. * This can be super useful if you either get the data from an uncompressed source or
  72010. * if you wish to create your texture pixel by pixel.
  72011. */
  72012. export class RawTexture extends Texture {
  72013. /**
  72014. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72015. */
  72016. format: number;
  72017. private _engine;
  72018. /**
  72019. * Instantiates a new RawTexture.
  72020. * Raw texture can help creating a texture directly from an array of data.
  72021. * This can be super useful if you either get the data from an uncompressed source or
  72022. * if you wish to create your texture pixel by pixel.
  72023. * @param data define the array of data to use to create the texture
  72024. * @param width define the width of the texture
  72025. * @param height define the height of the texture
  72026. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72027. * @param scene define the scene the texture belongs to
  72028. * @param generateMipMaps define whether mip maps should be generated or not
  72029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72032. */
  72033. constructor(data: ArrayBufferView, width: number, height: number,
  72034. /**
  72035. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72036. */
  72037. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72038. /**
  72039. * Updates the texture underlying data.
  72040. * @param data Define the new data of the texture
  72041. */
  72042. update(data: ArrayBufferView): void;
  72043. /**
  72044. * Creates a luminance texture from some data.
  72045. * @param data Define the texture data
  72046. * @param width Define the width of the texture
  72047. * @param height Define the height of the texture
  72048. * @param scene Define the scene the texture belongs to
  72049. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72050. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72051. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72052. * @returns the luminance texture
  72053. */
  72054. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72055. /**
  72056. * Creates a luminance alpha texture from some data.
  72057. * @param data Define the texture data
  72058. * @param width Define the width of the texture
  72059. * @param height Define the height of the texture
  72060. * @param scene Define the scene the texture belongs to
  72061. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72062. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72063. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72064. * @returns the luminance alpha texture
  72065. */
  72066. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72067. /**
  72068. * Creates an alpha texture from some data.
  72069. * @param data Define the texture data
  72070. * @param width Define the width of the texture
  72071. * @param height Define the height of the texture
  72072. * @param scene Define the scene the texture belongs to
  72073. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72074. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72075. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72076. * @returns the alpha texture
  72077. */
  72078. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72079. /**
  72080. * Creates a RGB texture from some data.
  72081. * @param data Define the texture data
  72082. * @param width Define the width of the texture
  72083. * @param height Define the height of the texture
  72084. * @param scene Define the scene the texture belongs to
  72085. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72086. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72087. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72088. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72089. * @returns the RGB alpha texture
  72090. */
  72091. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72092. /**
  72093. * Creates a RGBA texture from some data.
  72094. * @param data Define the texture data
  72095. * @param width Define the width of the texture
  72096. * @param height Define the height of the texture
  72097. * @param scene Define the scene the texture belongs to
  72098. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72099. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72100. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72101. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72102. * @returns the RGBA texture
  72103. */
  72104. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72105. /**
  72106. * Creates a R texture from some data.
  72107. * @param data Define the texture data
  72108. * @param width Define the width of the texture
  72109. * @param height Define the height of the texture
  72110. * @param scene Define the scene the texture belongs to
  72111. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72112. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72113. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72114. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72115. * @returns the R texture
  72116. */
  72117. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72118. }
  72119. }
  72120. declare module BABYLON {
  72121. /**
  72122. * Defines a runtime animation
  72123. */
  72124. export class RuntimeAnimation {
  72125. private _events;
  72126. /**
  72127. * The current frame of the runtime animation
  72128. */
  72129. private _currentFrame;
  72130. /**
  72131. * The animation used by the runtime animation
  72132. */
  72133. private _animation;
  72134. /**
  72135. * The target of the runtime animation
  72136. */
  72137. private _target;
  72138. /**
  72139. * The initiating animatable
  72140. */
  72141. private _host;
  72142. /**
  72143. * The original value of the runtime animation
  72144. */
  72145. private _originalValue;
  72146. /**
  72147. * The original blend value of the runtime animation
  72148. */
  72149. private _originalBlendValue;
  72150. /**
  72151. * The offsets cache of the runtime animation
  72152. */
  72153. private _offsetsCache;
  72154. /**
  72155. * The high limits cache of the runtime animation
  72156. */
  72157. private _highLimitsCache;
  72158. /**
  72159. * Specifies if the runtime animation has been stopped
  72160. */
  72161. private _stopped;
  72162. /**
  72163. * The blending factor of the runtime animation
  72164. */
  72165. private _blendingFactor;
  72166. /**
  72167. * The BabylonJS scene
  72168. */
  72169. private _scene;
  72170. /**
  72171. * The current value of the runtime animation
  72172. */
  72173. private _currentValue;
  72174. /** @hidden */
  72175. _animationState: _IAnimationState;
  72176. /**
  72177. * The active target of the runtime animation
  72178. */
  72179. private _activeTargets;
  72180. private _currentActiveTarget;
  72181. private _directTarget;
  72182. /**
  72183. * The target path of the runtime animation
  72184. */
  72185. private _targetPath;
  72186. /**
  72187. * The weight of the runtime animation
  72188. */
  72189. private _weight;
  72190. /**
  72191. * The ratio offset of the runtime animation
  72192. */
  72193. private _ratioOffset;
  72194. /**
  72195. * The previous delay of the runtime animation
  72196. */
  72197. private _previousDelay;
  72198. /**
  72199. * The previous ratio of the runtime animation
  72200. */
  72201. private _previousRatio;
  72202. private _enableBlending;
  72203. private _keys;
  72204. private _minFrame;
  72205. private _maxFrame;
  72206. private _minValue;
  72207. private _maxValue;
  72208. private _targetIsArray;
  72209. /**
  72210. * Gets the current frame of the runtime animation
  72211. */
  72212. readonly currentFrame: number;
  72213. /**
  72214. * Gets the weight of the runtime animation
  72215. */
  72216. readonly weight: number;
  72217. /**
  72218. * Gets the current value of the runtime animation
  72219. */
  72220. readonly currentValue: any;
  72221. /**
  72222. * Gets the target path of the runtime animation
  72223. */
  72224. readonly targetPath: string;
  72225. /**
  72226. * Gets the actual target of the runtime animation
  72227. */
  72228. readonly target: any;
  72229. /** @hidden */
  72230. _onLoop: () => void;
  72231. /**
  72232. * Create a new RuntimeAnimation object
  72233. * @param target defines the target of the animation
  72234. * @param animation defines the source animation object
  72235. * @param scene defines the hosting scene
  72236. * @param host defines the initiating Animatable
  72237. */
  72238. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72239. private _preparePath;
  72240. /**
  72241. * Gets the animation from the runtime animation
  72242. */
  72243. readonly animation: Animation;
  72244. /**
  72245. * Resets the runtime animation to the beginning
  72246. * @param restoreOriginal defines whether to restore the target property to the original value
  72247. */
  72248. reset(restoreOriginal?: boolean): void;
  72249. /**
  72250. * Specifies if the runtime animation is stopped
  72251. * @returns Boolean specifying if the runtime animation is stopped
  72252. */
  72253. isStopped(): boolean;
  72254. /**
  72255. * Disposes of the runtime animation
  72256. */
  72257. dispose(): void;
  72258. /**
  72259. * Apply the interpolated value to the target
  72260. * @param currentValue defines the value computed by the animation
  72261. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72262. */
  72263. setValue(currentValue: any, weight: number): void;
  72264. private _getOriginalValues;
  72265. private _setValue;
  72266. /**
  72267. * Gets the loop pmode of the runtime animation
  72268. * @returns Loop Mode
  72269. */
  72270. private _getCorrectLoopMode;
  72271. /**
  72272. * Move the current animation to a given frame
  72273. * @param frame defines the frame to move to
  72274. */
  72275. goToFrame(frame: number): void;
  72276. /**
  72277. * @hidden Internal use only
  72278. */
  72279. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72280. /**
  72281. * Execute the current animation
  72282. * @param delay defines the delay to add to the current frame
  72283. * @param from defines the lower bound of the animation range
  72284. * @param to defines the upper bound of the animation range
  72285. * @param loop defines if the current animation must loop
  72286. * @param speedRatio defines the current speed ratio
  72287. * @param weight defines the weight of the animation (default is -1 so no weight)
  72288. * @param onLoop optional callback called when animation loops
  72289. * @returns a boolean indicating if the animation is running
  72290. */
  72291. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72292. }
  72293. }
  72294. declare module BABYLON {
  72295. /**
  72296. * Class used to store an actual running animation
  72297. */
  72298. export class Animatable {
  72299. /** defines the target object */
  72300. target: any;
  72301. /** defines the starting frame number (default is 0) */
  72302. fromFrame: number;
  72303. /** defines the ending frame number (default is 100) */
  72304. toFrame: number;
  72305. /** defines if the animation must loop (default is false) */
  72306. loopAnimation: boolean;
  72307. /** defines a callback to call when animation ends if it is not looping */
  72308. onAnimationEnd?: (() => void) | null | undefined;
  72309. /** defines a callback to call when animation loops */
  72310. onAnimationLoop?: (() => void) | null | undefined;
  72311. private _localDelayOffset;
  72312. private _pausedDelay;
  72313. private _runtimeAnimations;
  72314. private _paused;
  72315. private _scene;
  72316. private _speedRatio;
  72317. private _weight;
  72318. private _syncRoot;
  72319. /**
  72320. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72321. * This will only apply for non looping animation (default is true)
  72322. */
  72323. disposeOnEnd: boolean;
  72324. /**
  72325. * Gets a boolean indicating if the animation has started
  72326. */
  72327. animationStarted: boolean;
  72328. /**
  72329. * Observer raised when the animation ends
  72330. */
  72331. onAnimationEndObservable: Observable<Animatable>;
  72332. /**
  72333. * Observer raised when the animation loops
  72334. */
  72335. onAnimationLoopObservable: Observable<Animatable>;
  72336. /**
  72337. * Gets the root Animatable used to synchronize and normalize animations
  72338. */
  72339. readonly syncRoot: Nullable<Animatable>;
  72340. /**
  72341. * Gets the current frame of the first RuntimeAnimation
  72342. * Used to synchronize Animatables
  72343. */
  72344. readonly masterFrame: number;
  72345. /**
  72346. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72347. */
  72348. weight: number;
  72349. /**
  72350. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72351. */
  72352. speedRatio: number;
  72353. /**
  72354. * Creates a new Animatable
  72355. * @param scene defines the hosting scene
  72356. * @param target defines the target object
  72357. * @param fromFrame defines the starting frame number (default is 0)
  72358. * @param toFrame defines the ending frame number (default is 100)
  72359. * @param loopAnimation defines if the animation must loop (default is false)
  72360. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72361. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72362. * @param animations defines a group of animation to add to the new Animatable
  72363. * @param onAnimationLoop defines a callback to call when animation loops
  72364. */
  72365. constructor(scene: Scene,
  72366. /** defines the target object */
  72367. target: any,
  72368. /** defines the starting frame number (default is 0) */
  72369. fromFrame?: number,
  72370. /** defines the ending frame number (default is 100) */
  72371. toFrame?: number,
  72372. /** defines if the animation must loop (default is false) */
  72373. loopAnimation?: boolean, speedRatio?: number,
  72374. /** defines a callback to call when animation ends if it is not looping */
  72375. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72376. /** defines a callback to call when animation loops */
  72377. onAnimationLoop?: (() => void) | null | undefined);
  72378. /**
  72379. * Synchronize and normalize current Animatable with a source Animatable
  72380. * This is useful when using animation weights and when animations are not of the same length
  72381. * @param root defines the root Animatable to synchronize with
  72382. * @returns the current Animatable
  72383. */
  72384. syncWith(root: Animatable): Animatable;
  72385. /**
  72386. * Gets the list of runtime animations
  72387. * @returns an array of RuntimeAnimation
  72388. */
  72389. getAnimations(): RuntimeAnimation[];
  72390. /**
  72391. * Adds more animations to the current animatable
  72392. * @param target defines the target of the animations
  72393. * @param animations defines the new animations to add
  72394. */
  72395. appendAnimations(target: any, animations: Animation[]): void;
  72396. /**
  72397. * Gets the source animation for a specific property
  72398. * @param property defines the propertyu to look for
  72399. * @returns null or the source animation for the given property
  72400. */
  72401. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72402. /**
  72403. * Gets the runtime animation for a specific property
  72404. * @param property defines the propertyu to look for
  72405. * @returns null or the runtime animation for the given property
  72406. */
  72407. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72408. /**
  72409. * Resets the animatable to its original state
  72410. */
  72411. reset(): void;
  72412. /**
  72413. * Allows the animatable to blend with current running animations
  72414. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72415. * @param blendingSpeed defines the blending speed to use
  72416. */
  72417. enableBlending(blendingSpeed: number): void;
  72418. /**
  72419. * Disable animation blending
  72420. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72421. */
  72422. disableBlending(): void;
  72423. /**
  72424. * Jump directly to a given frame
  72425. * @param frame defines the frame to jump to
  72426. */
  72427. goToFrame(frame: number): void;
  72428. /**
  72429. * Pause the animation
  72430. */
  72431. pause(): void;
  72432. /**
  72433. * Restart the animation
  72434. */
  72435. restart(): void;
  72436. private _raiseOnAnimationEnd;
  72437. /**
  72438. * Stop and delete the current animation
  72439. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72440. * @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)
  72441. */
  72442. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72443. /**
  72444. * Wait asynchronously for the animation to end
  72445. * @returns a promise which will be fullfilled when the animation ends
  72446. */
  72447. waitAsync(): Promise<Animatable>;
  72448. /** @hidden */
  72449. _animate(delay: number): boolean;
  72450. }
  72451. interface Scene {
  72452. /** @hidden */
  72453. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72454. /** @hidden */
  72455. _processLateAnimationBindingsForMatrices(holder: {
  72456. totalWeight: number;
  72457. animations: RuntimeAnimation[];
  72458. originalValue: Matrix;
  72459. }): any;
  72460. /** @hidden */
  72461. _processLateAnimationBindingsForQuaternions(holder: {
  72462. totalWeight: number;
  72463. animations: RuntimeAnimation[];
  72464. originalValue: Quaternion;
  72465. }, refQuaternion: Quaternion): Quaternion;
  72466. /** @hidden */
  72467. _processLateAnimationBindings(): void;
  72468. /**
  72469. * Will start the animation sequence of a given target
  72470. * @param target defines the target
  72471. * @param from defines from which frame should animation start
  72472. * @param to defines until which frame should animation run.
  72473. * @param weight defines the weight to apply to the animation (1.0 by default)
  72474. * @param loop defines if the animation loops
  72475. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72476. * @param onAnimationEnd defines the function to be executed when the animation ends
  72477. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72478. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72479. * @param onAnimationLoop defines the callback to call when an animation loops
  72480. * @returns the animatable object created for this animation
  72481. */
  72482. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72483. /**
  72484. * Will start the animation sequence of a given target
  72485. * @param target defines the target
  72486. * @param from defines from which frame should animation start
  72487. * @param to defines until which frame should animation run.
  72488. * @param loop defines if the animation loops
  72489. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72490. * @param onAnimationEnd defines the function to be executed when the animation ends
  72491. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72492. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72493. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72494. * @param onAnimationLoop defines the callback to call when an animation loops
  72495. * @returns the animatable object created for this animation
  72496. */
  72497. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72498. /**
  72499. * Will start the animation sequence of a given target and its hierarchy
  72500. * @param target defines the target
  72501. * @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.
  72502. * @param from defines from which frame should animation start
  72503. * @param to defines until which frame should animation run.
  72504. * @param loop defines if the animation loops
  72505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72506. * @param onAnimationEnd defines the function to be executed when the animation ends
  72507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72509. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72510. * @param onAnimationLoop defines the callback to call when an animation loops
  72511. * @returns the list of created animatables
  72512. */
  72513. 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[];
  72514. /**
  72515. * Begin a new animation on a given node
  72516. * @param target defines the target where the animation will take place
  72517. * @param animations defines the list of animations to start
  72518. * @param from defines the initial value
  72519. * @param to defines the final value
  72520. * @param loop defines if you want animation to loop (off by default)
  72521. * @param speedRatio defines the speed ratio to apply to all animations
  72522. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72523. * @param onAnimationLoop defines the callback to call when an animation loops
  72524. * @returns the list of created animatables
  72525. */
  72526. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72527. /**
  72528. * Begin a new animation on a given node and its hierarchy
  72529. * @param target defines the root node where the animation will take place
  72530. * @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.
  72531. * @param animations defines the list of animations to start
  72532. * @param from defines the initial value
  72533. * @param to defines the final value
  72534. * @param loop defines if you want animation to loop (off by default)
  72535. * @param speedRatio defines the speed ratio to apply to all animations
  72536. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72537. * @param onAnimationLoop defines the callback to call when an animation loops
  72538. * @returns the list of animatables created for all nodes
  72539. */
  72540. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72541. /**
  72542. * Gets the animatable associated with a specific target
  72543. * @param target defines the target of the animatable
  72544. * @returns the required animatable if found
  72545. */
  72546. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72547. /**
  72548. * Gets all animatables associated with a given target
  72549. * @param target defines the target to look animatables for
  72550. * @returns an array of Animatables
  72551. */
  72552. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72553. /**
  72554. * Stops and removes all animations that have been applied to the scene
  72555. */
  72556. stopAllAnimations(): void;
  72557. }
  72558. interface Bone {
  72559. /**
  72560. * Copy an animation range from another bone
  72561. * @param source defines the source bone
  72562. * @param rangeName defines the range name to copy
  72563. * @param frameOffset defines the frame offset
  72564. * @param rescaleAsRequired defines if rescaling must be applied if required
  72565. * @param skelDimensionsRatio defines the scaling ratio
  72566. * @returns true if operation was successful
  72567. */
  72568. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72569. }
  72570. }
  72571. declare module BABYLON {
  72572. /**
  72573. * Class used to handle skinning animations
  72574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72575. */
  72576. export class Skeleton implements IAnimatable {
  72577. /** defines the skeleton name */
  72578. name: string;
  72579. /** defines the skeleton Id */
  72580. id: string;
  72581. /**
  72582. * Defines the list of child bones
  72583. */
  72584. bones: Bone[];
  72585. /**
  72586. * Defines an estimate of the dimension of the skeleton at rest
  72587. */
  72588. dimensionsAtRest: Vector3;
  72589. /**
  72590. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72591. */
  72592. needInitialSkinMatrix: boolean;
  72593. /**
  72594. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72595. */
  72596. overrideMesh: Nullable<AbstractMesh>;
  72597. /**
  72598. * Gets the list of animations attached to this skeleton
  72599. */
  72600. animations: Array<Animation>;
  72601. private _scene;
  72602. private _isDirty;
  72603. private _transformMatrices;
  72604. private _transformMatrixTexture;
  72605. private _meshesWithPoseMatrix;
  72606. private _animatables;
  72607. private _identity;
  72608. private _synchronizedWithMesh;
  72609. private _ranges;
  72610. private _lastAbsoluteTransformsUpdateId;
  72611. private _canUseTextureForBones;
  72612. private _uniqueId;
  72613. /** @hidden */
  72614. _numBonesWithLinkedTransformNode: number;
  72615. /** @hidden */
  72616. _hasWaitingData: Nullable<boolean>;
  72617. /**
  72618. * Specifies if the skeleton should be serialized
  72619. */
  72620. doNotSerialize: boolean;
  72621. private _useTextureToStoreBoneMatrices;
  72622. /**
  72623. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72624. * Please note that this option is not available if the hardware does not support it
  72625. */
  72626. useTextureToStoreBoneMatrices: boolean;
  72627. private _animationPropertiesOverride;
  72628. /**
  72629. * Gets or sets the animation properties override
  72630. */
  72631. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72632. /**
  72633. * List of inspectable custom properties (used by the Inspector)
  72634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72635. */
  72636. inspectableCustomProperties: IInspectable[];
  72637. /**
  72638. * An observable triggered before computing the skeleton's matrices
  72639. */
  72640. onBeforeComputeObservable: Observable<Skeleton>;
  72641. /**
  72642. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72643. */
  72644. readonly isUsingTextureForMatrices: boolean;
  72645. /**
  72646. * Gets the unique ID of this skeleton
  72647. */
  72648. readonly uniqueId: number;
  72649. /**
  72650. * Creates a new skeleton
  72651. * @param name defines the skeleton name
  72652. * @param id defines the skeleton Id
  72653. * @param scene defines the hosting scene
  72654. */
  72655. constructor(
  72656. /** defines the skeleton name */
  72657. name: string,
  72658. /** defines the skeleton Id */
  72659. id: string, scene: Scene);
  72660. /**
  72661. * Gets the current object class name.
  72662. * @return the class name
  72663. */
  72664. getClassName(): string;
  72665. /**
  72666. * Returns an array containing the root bones
  72667. * @returns an array containing the root bones
  72668. */
  72669. getChildren(): Array<Bone>;
  72670. /**
  72671. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72673. * @returns a Float32Array containing matrices data
  72674. */
  72675. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72676. /**
  72677. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72678. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72679. * @returns a raw texture containing the data
  72680. */
  72681. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  72682. /**
  72683. * Gets the current hosting scene
  72684. * @returns a scene object
  72685. */
  72686. getScene(): Scene;
  72687. /**
  72688. * Gets a string representing the current skeleton data
  72689. * @param fullDetails defines a boolean indicating if we want a verbose version
  72690. * @returns a string representing the current skeleton data
  72691. */
  72692. toString(fullDetails?: boolean): string;
  72693. /**
  72694. * Get bone's index searching by name
  72695. * @param name defines bone's name to search for
  72696. * @return the indice of the bone. Returns -1 if not found
  72697. */
  72698. getBoneIndexByName(name: string): number;
  72699. /**
  72700. * Creater a new animation range
  72701. * @param name defines the name of the range
  72702. * @param from defines the start key
  72703. * @param to defines the end key
  72704. */
  72705. createAnimationRange(name: string, from: number, to: number): void;
  72706. /**
  72707. * Delete a specific animation range
  72708. * @param name defines the name of the range
  72709. * @param deleteFrames defines if frames must be removed as well
  72710. */
  72711. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72712. /**
  72713. * Gets a specific animation range
  72714. * @param name defines the name of the range to look for
  72715. * @returns the requested animation range or null if not found
  72716. */
  72717. getAnimationRange(name: string): Nullable<AnimationRange>;
  72718. /**
  72719. * Gets the list of all animation ranges defined on this skeleton
  72720. * @returns an array
  72721. */
  72722. getAnimationRanges(): Nullable<AnimationRange>[];
  72723. /**
  72724. * Copy animation range from a source skeleton.
  72725. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72726. * @param source defines the source skeleton
  72727. * @param name defines the name of the range to copy
  72728. * @param rescaleAsRequired defines if rescaling must be applied if required
  72729. * @returns true if operation was successful
  72730. */
  72731. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72732. /**
  72733. * Forces the skeleton to go to rest pose
  72734. */
  72735. returnToRest(): void;
  72736. private _getHighestAnimationFrame;
  72737. /**
  72738. * Begin a specific animation range
  72739. * @param name defines the name of the range to start
  72740. * @param loop defines if looping must be turned on (false by default)
  72741. * @param speedRatio defines the speed ratio to apply (1 by default)
  72742. * @param onAnimationEnd defines a callback which will be called when animation will end
  72743. * @returns a new animatable
  72744. */
  72745. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72746. /** @hidden */
  72747. _markAsDirty(): void;
  72748. /** @hidden */
  72749. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72750. /** @hidden */
  72751. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72752. private _computeTransformMatrices;
  72753. /**
  72754. * Build all resources required to render a skeleton
  72755. */
  72756. prepare(): void;
  72757. /**
  72758. * Gets the list of animatables currently running for this skeleton
  72759. * @returns an array of animatables
  72760. */
  72761. getAnimatables(): IAnimatable[];
  72762. /**
  72763. * Clone the current skeleton
  72764. * @param name defines the name of the new skeleton
  72765. * @param id defines the id of the new skeleton
  72766. * @returns the new skeleton
  72767. */
  72768. clone(name: string, id: string): Skeleton;
  72769. /**
  72770. * Enable animation blending for this skeleton
  72771. * @param blendingSpeed defines the blending speed to apply
  72772. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72773. */
  72774. enableBlending(blendingSpeed?: number): void;
  72775. /**
  72776. * Releases all resources associated with the current skeleton
  72777. */
  72778. dispose(): void;
  72779. /**
  72780. * Serialize the skeleton in a JSON object
  72781. * @returns a JSON object
  72782. */
  72783. serialize(): any;
  72784. /**
  72785. * Creates a new skeleton from serialized data
  72786. * @param parsedSkeleton defines the serialized data
  72787. * @param scene defines the hosting scene
  72788. * @returns a new skeleton
  72789. */
  72790. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72791. /**
  72792. * Compute all node absolute transforms
  72793. * @param forceUpdate defines if computation must be done even if cache is up to date
  72794. */
  72795. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72796. /**
  72797. * Gets the root pose matrix
  72798. * @returns a matrix
  72799. */
  72800. getPoseMatrix(): Nullable<Matrix>;
  72801. /**
  72802. * Sorts bones per internal index
  72803. */
  72804. sortBones(): void;
  72805. private _sortBones;
  72806. }
  72807. }
  72808. declare module BABYLON {
  72809. /**
  72810. * Defines a target to use with MorphTargetManager
  72811. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72812. */
  72813. export class MorphTarget implements IAnimatable {
  72814. /** defines the name of the target */
  72815. name: string;
  72816. /**
  72817. * Gets or sets the list of animations
  72818. */
  72819. animations: Animation[];
  72820. private _scene;
  72821. private _positions;
  72822. private _normals;
  72823. private _tangents;
  72824. private _uvs;
  72825. private _influence;
  72826. /**
  72827. * Observable raised when the influence changes
  72828. */
  72829. onInfluenceChanged: Observable<boolean>;
  72830. /** @hidden */
  72831. _onDataLayoutChanged: Observable<void>;
  72832. /**
  72833. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72834. */
  72835. influence: number;
  72836. /**
  72837. * Gets or sets the id of the morph Target
  72838. */
  72839. id: string;
  72840. private _animationPropertiesOverride;
  72841. /**
  72842. * Gets or sets the animation properties override
  72843. */
  72844. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72845. /**
  72846. * Creates a new MorphTarget
  72847. * @param name defines the name of the target
  72848. * @param influence defines the influence to use
  72849. * @param scene defines the scene the morphtarget belongs to
  72850. */
  72851. constructor(
  72852. /** defines the name of the target */
  72853. name: string, influence?: number, scene?: Nullable<Scene>);
  72854. /**
  72855. * Gets a boolean defining if the target contains position data
  72856. */
  72857. readonly hasPositions: boolean;
  72858. /**
  72859. * Gets a boolean defining if the target contains normal data
  72860. */
  72861. readonly hasNormals: boolean;
  72862. /**
  72863. * Gets a boolean defining if the target contains tangent data
  72864. */
  72865. readonly hasTangents: boolean;
  72866. /**
  72867. * Gets a boolean defining if the target contains texture coordinates data
  72868. */
  72869. readonly hasUVs: boolean;
  72870. /**
  72871. * Affects position data to this target
  72872. * @param data defines the position data to use
  72873. */
  72874. setPositions(data: Nullable<FloatArray>): void;
  72875. /**
  72876. * Gets the position data stored in this target
  72877. * @returns a FloatArray containing the position data (or null if not present)
  72878. */
  72879. getPositions(): Nullable<FloatArray>;
  72880. /**
  72881. * Affects normal data to this target
  72882. * @param data defines the normal data to use
  72883. */
  72884. setNormals(data: Nullable<FloatArray>): void;
  72885. /**
  72886. * Gets the normal data stored in this target
  72887. * @returns a FloatArray containing the normal data (or null if not present)
  72888. */
  72889. getNormals(): Nullable<FloatArray>;
  72890. /**
  72891. * Affects tangent data to this target
  72892. * @param data defines the tangent data to use
  72893. */
  72894. setTangents(data: Nullable<FloatArray>): void;
  72895. /**
  72896. * Gets the tangent data stored in this target
  72897. * @returns a FloatArray containing the tangent data (or null if not present)
  72898. */
  72899. getTangents(): Nullable<FloatArray>;
  72900. /**
  72901. * Affects texture coordinates data to this target
  72902. * @param data defines the texture coordinates data to use
  72903. */
  72904. setUVs(data: Nullable<FloatArray>): void;
  72905. /**
  72906. * Gets the texture coordinates data stored in this target
  72907. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  72908. */
  72909. getUVs(): Nullable<FloatArray>;
  72910. /**
  72911. * Serializes the current target into a Serialization object
  72912. * @returns the serialized object
  72913. */
  72914. serialize(): any;
  72915. /**
  72916. * Returns the string "MorphTarget"
  72917. * @returns "MorphTarget"
  72918. */
  72919. getClassName(): string;
  72920. /**
  72921. * Creates a new target from serialized data
  72922. * @param serializationObject defines the serialized data to use
  72923. * @returns a new MorphTarget
  72924. */
  72925. static Parse(serializationObject: any): MorphTarget;
  72926. /**
  72927. * Creates a MorphTarget from mesh data
  72928. * @param mesh defines the source mesh
  72929. * @param name defines the name to use for the new target
  72930. * @param influence defines the influence to attach to the target
  72931. * @returns a new MorphTarget
  72932. */
  72933. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72934. }
  72935. }
  72936. declare module BABYLON {
  72937. /**
  72938. * This class is used to deform meshes using morphing between different targets
  72939. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72940. */
  72941. export class MorphTargetManager {
  72942. private _targets;
  72943. private _targetInfluenceChangedObservers;
  72944. private _targetDataLayoutChangedObservers;
  72945. private _activeTargets;
  72946. private _scene;
  72947. private _influences;
  72948. private _supportsNormals;
  72949. private _supportsTangents;
  72950. private _supportsUVs;
  72951. private _vertexCount;
  72952. private _uniqueId;
  72953. private _tempInfluences;
  72954. /**
  72955. * Gets or sets a boolean indicating if normals must be morphed
  72956. */
  72957. enableNormalMorphing: boolean;
  72958. /**
  72959. * Gets or sets a boolean indicating if tangents must be morphed
  72960. */
  72961. enableTangentMorphing: boolean;
  72962. /**
  72963. * Gets or sets a boolean indicating if UV must be morphed
  72964. */
  72965. enableUVMorphing: boolean;
  72966. /**
  72967. * Creates a new MorphTargetManager
  72968. * @param scene defines the current scene
  72969. */
  72970. constructor(scene?: Nullable<Scene>);
  72971. /**
  72972. * Gets the unique ID of this manager
  72973. */
  72974. readonly uniqueId: number;
  72975. /**
  72976. * Gets the number of vertices handled by this manager
  72977. */
  72978. readonly vertexCount: number;
  72979. /**
  72980. * Gets a boolean indicating if this manager supports morphing of normals
  72981. */
  72982. readonly supportsNormals: boolean;
  72983. /**
  72984. * Gets a boolean indicating if this manager supports morphing of tangents
  72985. */
  72986. readonly supportsTangents: boolean;
  72987. /**
  72988. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  72989. */
  72990. readonly supportsUVs: boolean;
  72991. /**
  72992. * Gets the number of targets stored in this manager
  72993. */
  72994. readonly numTargets: number;
  72995. /**
  72996. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72997. */
  72998. readonly numInfluencers: number;
  72999. /**
  73000. * Gets the list of influences (one per target)
  73001. */
  73002. readonly influences: Float32Array;
  73003. /**
  73004. * Gets the active target at specified index. An active target is a target with an influence > 0
  73005. * @param index defines the index to check
  73006. * @returns the requested target
  73007. */
  73008. getActiveTarget(index: number): MorphTarget;
  73009. /**
  73010. * Gets the target at specified index
  73011. * @param index defines the index to check
  73012. * @returns the requested target
  73013. */
  73014. getTarget(index: number): MorphTarget;
  73015. /**
  73016. * Add a new target to this manager
  73017. * @param target defines the target to add
  73018. */
  73019. addTarget(target: MorphTarget): void;
  73020. /**
  73021. * Removes a target from the manager
  73022. * @param target defines the target to remove
  73023. */
  73024. removeTarget(target: MorphTarget): void;
  73025. /**
  73026. * Serializes the current manager into a Serialization object
  73027. * @returns the serialized object
  73028. */
  73029. serialize(): any;
  73030. private _syncActiveTargets;
  73031. /**
  73032. * Syncrhonize the targets with all the meshes using this morph target manager
  73033. */
  73034. synchronize(): void;
  73035. /**
  73036. * Creates a new MorphTargetManager from serialized data
  73037. * @param serializationObject defines the serialized data
  73038. * @param scene defines the hosting scene
  73039. * @returns the new MorphTargetManager
  73040. */
  73041. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73042. }
  73043. }
  73044. declare module BABYLON {
  73045. /**
  73046. * Groups all the scene component constants in one place to ease maintenance.
  73047. * @hidden
  73048. */
  73049. export class SceneComponentConstants {
  73050. static readonly NAME_EFFECTLAYER: string;
  73051. static readonly NAME_LAYER: string;
  73052. static readonly NAME_LENSFLARESYSTEM: string;
  73053. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73054. static readonly NAME_PARTICLESYSTEM: string;
  73055. static readonly NAME_GAMEPAD: string;
  73056. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73057. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73058. static readonly NAME_DEPTHRENDERER: string;
  73059. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73060. static readonly NAME_SPRITE: string;
  73061. static readonly NAME_OUTLINERENDERER: string;
  73062. static readonly NAME_PROCEDURALTEXTURE: string;
  73063. static readonly NAME_SHADOWGENERATOR: string;
  73064. static readonly NAME_OCTREE: string;
  73065. static readonly NAME_PHYSICSENGINE: string;
  73066. static readonly NAME_AUDIO: string;
  73067. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73068. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73069. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73070. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73071. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73072. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73073. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73074. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73075. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73076. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73077. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73078. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73079. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73080. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73081. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73082. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73083. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73084. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73085. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73086. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73087. static readonly STEP_AFTERRENDER_AUDIO: number;
  73088. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73089. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73090. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73091. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73092. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73093. static readonly STEP_POINTERMOVE_SPRITE: number;
  73094. static readonly STEP_POINTERDOWN_SPRITE: number;
  73095. static readonly STEP_POINTERUP_SPRITE: number;
  73096. }
  73097. /**
  73098. * This represents a scene component.
  73099. *
  73100. * This is used to decouple the dependency the scene is having on the different workloads like
  73101. * layers, post processes...
  73102. */
  73103. export interface ISceneComponent {
  73104. /**
  73105. * The name of the component. Each component must have a unique name.
  73106. */
  73107. name: string;
  73108. /**
  73109. * The scene the component belongs to.
  73110. */
  73111. scene: Scene;
  73112. /**
  73113. * Register the component to one instance of a scene.
  73114. */
  73115. register(): void;
  73116. /**
  73117. * Rebuilds the elements related to this component in case of
  73118. * context lost for instance.
  73119. */
  73120. rebuild(): void;
  73121. /**
  73122. * Disposes the component and the associated ressources.
  73123. */
  73124. dispose(): void;
  73125. }
  73126. /**
  73127. * This represents a SERIALIZABLE scene component.
  73128. *
  73129. * This extends Scene Component to add Serialization methods on top.
  73130. */
  73131. export interface ISceneSerializableComponent extends ISceneComponent {
  73132. /**
  73133. * Adds all the elements from the container to the scene
  73134. * @param container the container holding the elements
  73135. */
  73136. addFromContainer(container: AbstractScene): void;
  73137. /**
  73138. * Removes all the elements in the container from the scene
  73139. * @param container contains the elements to remove
  73140. * @param dispose if the removed element should be disposed (default: false)
  73141. */
  73142. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73143. /**
  73144. * Serializes the component data to the specified json object
  73145. * @param serializationObject The object to serialize to
  73146. */
  73147. serialize(serializationObject: any): void;
  73148. }
  73149. /**
  73150. * Strong typing of a Mesh related stage step action
  73151. */
  73152. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73153. /**
  73154. * Strong typing of a Evaluate Sub Mesh related stage step action
  73155. */
  73156. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73157. /**
  73158. * Strong typing of a Active Mesh related stage step action
  73159. */
  73160. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73161. /**
  73162. * Strong typing of a Camera related stage step action
  73163. */
  73164. export type CameraStageAction = (camera: Camera) => void;
  73165. /**
  73166. * Strong typing of a Camera Frame buffer related stage step action
  73167. */
  73168. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73169. /**
  73170. * Strong typing of a Render Target related stage step action
  73171. */
  73172. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73173. /**
  73174. * Strong typing of a RenderingGroup related stage step action
  73175. */
  73176. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73177. /**
  73178. * Strong typing of a Mesh Render related stage step action
  73179. */
  73180. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73181. /**
  73182. * Strong typing of a simple stage step action
  73183. */
  73184. export type SimpleStageAction = () => void;
  73185. /**
  73186. * Strong typing of a render target action.
  73187. */
  73188. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73189. /**
  73190. * Strong typing of a pointer move action.
  73191. */
  73192. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73193. /**
  73194. * Strong typing of a pointer up/down action.
  73195. */
  73196. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73197. /**
  73198. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73199. * @hidden
  73200. */
  73201. export class Stage<T extends Function> extends Array<{
  73202. index: number;
  73203. component: ISceneComponent;
  73204. action: T;
  73205. }> {
  73206. /**
  73207. * Hide ctor from the rest of the world.
  73208. * @param items The items to add.
  73209. */
  73210. private constructor();
  73211. /**
  73212. * Creates a new Stage.
  73213. * @returns A new instance of a Stage
  73214. */
  73215. static Create<T extends Function>(): Stage<T>;
  73216. /**
  73217. * Registers a step in an ordered way in the targeted stage.
  73218. * @param index Defines the position to register the step in
  73219. * @param component Defines the component attached to the step
  73220. * @param action Defines the action to launch during the step
  73221. */
  73222. registerStep(index: number, component: ISceneComponent, action: T): void;
  73223. /**
  73224. * Clears all the steps from the stage.
  73225. */
  73226. clear(): void;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /**
  73231. * Class used to represent a specific level of detail of a mesh
  73232. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73233. */
  73234. export class MeshLODLevel {
  73235. /** Defines the distance where this level should star being displayed */
  73236. distance: number;
  73237. /** Defines the mesh to use to render this level */
  73238. mesh: Nullable<Mesh>;
  73239. /**
  73240. * Creates a new LOD level
  73241. * @param distance defines the distance where this level should star being displayed
  73242. * @param mesh defines the mesh to use to render this level
  73243. */
  73244. constructor(
  73245. /** Defines the distance where this level should star being displayed */
  73246. distance: number,
  73247. /** Defines the mesh to use to render this level */
  73248. mesh: Nullable<Mesh>);
  73249. }
  73250. }
  73251. declare module BABYLON {
  73252. /**
  73253. * Interface describing all the common properties and methods a shadow light needs to implement.
  73254. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73255. * as well as binding the different shadow properties to the effects.
  73256. */
  73257. export interface IShadowLight extends Light {
  73258. /**
  73259. * The light id in the scene (used in scene.findLighById for instance)
  73260. */
  73261. id: string;
  73262. /**
  73263. * The position the shdow will be casted from.
  73264. */
  73265. position: Vector3;
  73266. /**
  73267. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73268. */
  73269. direction: Vector3;
  73270. /**
  73271. * The transformed position. Position of the light in world space taking parenting in account.
  73272. */
  73273. transformedPosition: Vector3;
  73274. /**
  73275. * The transformed direction. Direction of the light in world space taking parenting in account.
  73276. */
  73277. transformedDirection: Vector3;
  73278. /**
  73279. * The friendly name of the light in the scene.
  73280. */
  73281. name: string;
  73282. /**
  73283. * Defines the shadow projection clipping minimum z value.
  73284. */
  73285. shadowMinZ: number;
  73286. /**
  73287. * Defines the shadow projection clipping maximum z value.
  73288. */
  73289. shadowMaxZ: number;
  73290. /**
  73291. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73292. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73293. */
  73294. computeTransformedInformation(): boolean;
  73295. /**
  73296. * Gets the scene the light belongs to.
  73297. * @returns The scene
  73298. */
  73299. getScene(): Scene;
  73300. /**
  73301. * Callback defining a custom Projection Matrix Builder.
  73302. * This can be used to override the default projection matrix computation.
  73303. */
  73304. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73305. /**
  73306. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73307. * @param matrix The materix to updated with the projection information
  73308. * @param viewMatrix The transform matrix of the light
  73309. * @param renderList The list of mesh to render in the map
  73310. * @returns The current light
  73311. */
  73312. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73313. /**
  73314. * Gets the current depth scale used in ESM.
  73315. * @returns The scale
  73316. */
  73317. getDepthScale(): number;
  73318. /**
  73319. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73320. * @returns true if a cube texture needs to be use
  73321. */
  73322. needCube(): boolean;
  73323. /**
  73324. * Detects if the projection matrix requires to be recomputed this frame.
  73325. * @returns true if it requires to be recomputed otherwise, false.
  73326. */
  73327. needProjectionMatrixCompute(): boolean;
  73328. /**
  73329. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73330. */
  73331. forceProjectionMatrixCompute(): void;
  73332. /**
  73333. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73334. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73335. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73336. */
  73337. getShadowDirection(faceIndex?: number): Vector3;
  73338. /**
  73339. * Gets the minZ used for shadow according to both the scene and the light.
  73340. * @param activeCamera The camera we are returning the min for
  73341. * @returns the depth min z
  73342. */
  73343. getDepthMinZ(activeCamera: Camera): number;
  73344. /**
  73345. * Gets the maxZ used for shadow according to both the scene and the light.
  73346. * @param activeCamera The camera we are returning the max for
  73347. * @returns the depth max z
  73348. */
  73349. getDepthMaxZ(activeCamera: Camera): number;
  73350. }
  73351. /**
  73352. * Base implementation IShadowLight
  73353. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73354. */
  73355. export abstract class ShadowLight extends Light implements IShadowLight {
  73356. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73357. protected _position: Vector3;
  73358. protected _setPosition(value: Vector3): void;
  73359. /**
  73360. * Sets the position the shadow will be casted from. Also use as the light position for both
  73361. * point and spot lights.
  73362. */
  73363. /**
  73364. * Sets the position the shadow will be casted from. Also use as the light position for both
  73365. * point and spot lights.
  73366. */
  73367. position: Vector3;
  73368. protected _direction: Vector3;
  73369. protected _setDirection(value: Vector3): void;
  73370. /**
  73371. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73372. * Also use as the light direction on spot and directional lights.
  73373. */
  73374. /**
  73375. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73376. * Also use as the light direction on spot and directional lights.
  73377. */
  73378. direction: Vector3;
  73379. private _shadowMinZ;
  73380. /**
  73381. * Gets the shadow projection clipping minimum z value.
  73382. */
  73383. /**
  73384. * Sets the shadow projection clipping minimum z value.
  73385. */
  73386. shadowMinZ: number;
  73387. private _shadowMaxZ;
  73388. /**
  73389. * Sets the shadow projection clipping maximum z value.
  73390. */
  73391. /**
  73392. * Gets the shadow projection clipping maximum z value.
  73393. */
  73394. shadowMaxZ: number;
  73395. /**
  73396. * Callback defining a custom Projection Matrix Builder.
  73397. * This can be used to override the default projection matrix computation.
  73398. */
  73399. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73400. /**
  73401. * The transformed position. Position of the light in world space taking parenting in account.
  73402. */
  73403. transformedPosition: Vector3;
  73404. /**
  73405. * The transformed direction. Direction of the light in world space taking parenting in account.
  73406. */
  73407. transformedDirection: Vector3;
  73408. private _needProjectionMatrixCompute;
  73409. /**
  73410. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73411. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73412. */
  73413. computeTransformedInformation(): boolean;
  73414. /**
  73415. * Return the depth scale used for the shadow map.
  73416. * @returns the depth scale.
  73417. */
  73418. getDepthScale(): number;
  73419. /**
  73420. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73423. */
  73424. getShadowDirection(faceIndex?: number): Vector3;
  73425. /**
  73426. * Returns the ShadowLight absolute position in the World.
  73427. * @returns the position vector in world space
  73428. */
  73429. getAbsolutePosition(): Vector3;
  73430. /**
  73431. * Sets the ShadowLight direction toward the passed target.
  73432. * @param target The point to target in local space
  73433. * @returns the updated ShadowLight direction
  73434. */
  73435. setDirectionToTarget(target: Vector3): Vector3;
  73436. /**
  73437. * Returns the light rotation in euler definition.
  73438. * @returns the x y z rotation in local space.
  73439. */
  73440. getRotation(): Vector3;
  73441. /**
  73442. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73443. * @returns true if a cube texture needs to be use
  73444. */
  73445. needCube(): boolean;
  73446. /**
  73447. * Detects if the projection matrix requires to be recomputed this frame.
  73448. * @returns true if it requires to be recomputed otherwise, false.
  73449. */
  73450. needProjectionMatrixCompute(): boolean;
  73451. /**
  73452. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73453. */
  73454. forceProjectionMatrixCompute(): void;
  73455. /** @hidden */
  73456. _initCache(): void;
  73457. /** @hidden */
  73458. _isSynchronized(): boolean;
  73459. /**
  73460. * Computes the world matrix of the node
  73461. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73462. * @returns the world matrix
  73463. */
  73464. computeWorldMatrix(force?: boolean): Matrix;
  73465. /**
  73466. * Gets the minZ used for shadow according to both the scene and the light.
  73467. * @param activeCamera The camera we are returning the min for
  73468. * @returns the depth min z
  73469. */
  73470. getDepthMinZ(activeCamera: Camera): number;
  73471. /**
  73472. * Gets the maxZ used for shadow according to both the scene and the light.
  73473. * @param activeCamera The camera we are returning the max for
  73474. * @returns the depth max z
  73475. */
  73476. getDepthMaxZ(activeCamera: Camera): number;
  73477. /**
  73478. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73479. * @param matrix The materix to updated with the projection information
  73480. * @param viewMatrix The transform matrix of the light
  73481. * @param renderList The list of mesh to render in the map
  73482. * @returns The current light
  73483. */
  73484. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73485. }
  73486. }
  73487. declare module BABYLON {
  73488. /**
  73489. * "Static Class" containing the most commonly used helper while dealing with material for
  73490. * rendering purpose.
  73491. *
  73492. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73493. *
  73494. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73495. */
  73496. export class MaterialHelper {
  73497. /**
  73498. * Bind the current view position to an effect.
  73499. * @param effect The effect to be bound
  73500. * @param scene The scene the eyes position is used from
  73501. */
  73502. static BindEyePosition(effect: Effect, scene: Scene): void;
  73503. /**
  73504. * Helps preparing the defines values about the UVs in used in the effect.
  73505. * UVs are shared as much as we can accross channels in the shaders.
  73506. * @param texture The texture we are preparing the UVs for
  73507. * @param defines The defines to update
  73508. * @param key The channel key "diffuse", "specular"... used in the shader
  73509. */
  73510. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73511. /**
  73512. * Binds a texture matrix value to its corrsponding uniform
  73513. * @param texture The texture to bind the matrix for
  73514. * @param uniformBuffer The uniform buffer receivin the data
  73515. * @param key The channel key "diffuse", "specular"... used in the shader
  73516. */
  73517. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73518. /**
  73519. * Gets the current status of the fog (should it be enabled?)
  73520. * @param mesh defines the mesh to evaluate for fog support
  73521. * @param scene defines the hosting scene
  73522. * @returns true if fog must be enabled
  73523. */
  73524. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73525. /**
  73526. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73527. * @param mesh defines the current mesh
  73528. * @param scene defines the current scene
  73529. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73530. * @param pointsCloud defines if point cloud rendering has to be turned on
  73531. * @param fogEnabled defines if fog has to be turned on
  73532. * @param alphaTest defines if alpha testing has to be turned on
  73533. * @param defines defines the current list of defines
  73534. */
  73535. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73536. /**
  73537. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73538. * @param scene defines the current scene
  73539. * @param engine defines the current engine
  73540. * @param defines specifies the list of active defines
  73541. * @param useInstances defines if instances have to be turned on
  73542. * @param useClipPlane defines if clip plane have to be turned on
  73543. */
  73544. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73545. /**
  73546. * Prepares the defines for bones
  73547. * @param mesh The mesh containing the geometry data we will draw
  73548. * @param defines The defines to update
  73549. */
  73550. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73551. /**
  73552. * Prepares the defines for morph targets
  73553. * @param mesh The mesh containing the geometry data we will draw
  73554. * @param defines The defines to update
  73555. */
  73556. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73557. /**
  73558. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73559. * @param mesh The mesh containing the geometry data we will draw
  73560. * @param defines The defines to update
  73561. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73562. * @param useBones Precise whether bones should be used or not (override mesh info)
  73563. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73564. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73565. * @returns false if defines are considered not dirty and have not been checked
  73566. */
  73567. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73568. /**
  73569. * Prepares the defines related to multiview
  73570. * @param scene The scene we are intending to draw
  73571. * @param defines The defines to update
  73572. */
  73573. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73574. /**
  73575. * Prepares the defines related to the light information passed in parameter
  73576. * @param scene The scene we are intending to draw
  73577. * @param mesh The mesh the effect is compiling for
  73578. * @param light The light the effect is compiling for
  73579. * @param lightIndex The index of the light
  73580. * @param defines The defines to update
  73581. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73582. * @param state Defines the current state regarding what is needed (normals, etc...)
  73583. */
  73584. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73585. needNormals: boolean;
  73586. needRebuild: boolean;
  73587. shadowEnabled: boolean;
  73588. specularEnabled: boolean;
  73589. lightmapMode: boolean;
  73590. }): void;
  73591. /**
  73592. * Prepares the defines related to the light information passed in parameter
  73593. * @param scene The scene we are intending to draw
  73594. * @param mesh The mesh the effect is compiling for
  73595. * @param defines The defines to update
  73596. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73597. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73598. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73599. * @returns true if normals will be required for the rest of the effect
  73600. */
  73601. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73602. /**
  73603. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73604. * @param lightIndex defines the light index
  73605. * @param uniformsList The uniform list
  73606. * @param samplersList The sampler list
  73607. * @param projectedLightTexture defines if projected texture must be used
  73608. * @param uniformBuffersList defines an optional list of uniform buffers
  73609. */
  73610. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73611. /**
  73612. * Prepares the uniforms and samplers list to be used in the effect
  73613. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73614. * @param samplersList The sampler list
  73615. * @param defines The defines helping in the list generation
  73616. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73617. */
  73618. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73619. /**
  73620. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73621. * @param defines The defines to update while falling back
  73622. * @param fallbacks The authorized effect fallbacks
  73623. * @param maxSimultaneousLights The maximum number of lights allowed
  73624. * @param rank the current rank of the Effect
  73625. * @returns The newly affected rank
  73626. */
  73627. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73628. private static _TmpMorphInfluencers;
  73629. /**
  73630. * Prepares the list of attributes required for morph targets according to the effect defines.
  73631. * @param attribs The current list of supported attribs
  73632. * @param mesh The mesh to prepare the morph targets attributes for
  73633. * @param influencers The number of influencers
  73634. */
  73635. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73636. /**
  73637. * Prepares the list of attributes required for morph targets according to the effect defines.
  73638. * @param attribs The current list of supported attribs
  73639. * @param mesh The mesh to prepare the morph targets attributes for
  73640. * @param defines The current Defines of the effect
  73641. */
  73642. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73643. /**
  73644. * Prepares the list of attributes required for bones according to the effect defines.
  73645. * @param attribs The current list of supported attribs
  73646. * @param mesh The mesh to prepare the bones attributes for
  73647. * @param defines The current Defines of the effect
  73648. * @param fallbacks The current efffect fallback strategy
  73649. */
  73650. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73651. /**
  73652. * Check and prepare the list of attributes required for instances according to the effect defines.
  73653. * @param attribs The current list of supported attribs
  73654. * @param defines The current MaterialDefines of the effect
  73655. */
  73656. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73657. /**
  73658. * Add the list of attributes required for instances to the attribs array.
  73659. * @param attribs The current list of supported attribs
  73660. */
  73661. static PushAttributesForInstances(attribs: string[]): void;
  73662. /**
  73663. * Binds the light shadow information to the effect for the given mesh.
  73664. * @param light The light containing the generator
  73665. * @param scene The scene the lights belongs to
  73666. * @param mesh The mesh we are binding the information to render
  73667. * @param lightIndex The light index in the effect used to render the mesh
  73668. * @param effect The effect we are binding the data to
  73669. */
  73670. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73671. /**
  73672. * Binds the light information to the effect.
  73673. * @param light The light containing the generator
  73674. * @param effect The effect we are binding the data to
  73675. * @param lightIndex The light index in the effect used to render
  73676. */
  73677. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73678. /**
  73679. * Binds the lights information from the scene to the effect for the given mesh.
  73680. * @param light Light to bind
  73681. * @param lightIndex Light index
  73682. * @param scene The scene where the light belongs to
  73683. * @param mesh The mesh we are binding the information to render
  73684. * @param effect The effect we are binding the data to
  73685. * @param useSpecular Defines if specular is supported
  73686. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73687. */
  73688. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73689. /**
  73690. * Binds the lights information from the scene to the effect for the given mesh.
  73691. * @param scene The scene the lights belongs to
  73692. * @param mesh The mesh we are binding the information to render
  73693. * @param effect The effect we are binding the data to
  73694. * @param defines The generated defines for the effect
  73695. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73696. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73697. */
  73698. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73699. private static _tempFogColor;
  73700. /**
  73701. * Binds the fog information from the scene to the effect for the given mesh.
  73702. * @param scene The scene the lights belongs to
  73703. * @param mesh The mesh we are binding the information to render
  73704. * @param effect The effect we are binding the data to
  73705. * @param linearSpace Defines if the fog effect is applied in linear space
  73706. */
  73707. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73708. /**
  73709. * Binds the bones information from the mesh to the effect.
  73710. * @param mesh The mesh we are binding the information to render
  73711. * @param effect The effect we are binding the data to
  73712. */
  73713. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73714. /**
  73715. * Binds the morph targets information from the mesh to the effect.
  73716. * @param abstractMesh The mesh we are binding the information to render
  73717. * @param effect The effect we are binding the data to
  73718. */
  73719. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73720. /**
  73721. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73722. * @param defines The generated defines used in the effect
  73723. * @param effect The effect we are binding the data to
  73724. * @param scene The scene we are willing to render with logarithmic scale for
  73725. */
  73726. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73727. /**
  73728. * Binds the clip plane information from the scene to the effect.
  73729. * @param scene The scene the clip plane information are extracted from
  73730. * @param effect The effect we are binding the data to
  73731. */
  73732. static BindClipPlane(effect: Effect, scene: Scene): void;
  73733. }
  73734. }
  73735. declare module BABYLON {
  73736. /** @hidden */
  73737. export var packingFunctions: {
  73738. name: string;
  73739. shader: string;
  73740. };
  73741. }
  73742. declare module BABYLON {
  73743. /** @hidden */
  73744. export var shadowMapPixelShader: {
  73745. name: string;
  73746. shader: string;
  73747. };
  73748. }
  73749. declare module BABYLON {
  73750. /** @hidden */
  73751. export var bonesDeclaration: {
  73752. name: string;
  73753. shader: string;
  73754. };
  73755. }
  73756. declare module BABYLON {
  73757. /** @hidden */
  73758. export var morphTargetsVertexGlobalDeclaration: {
  73759. name: string;
  73760. shader: string;
  73761. };
  73762. }
  73763. declare module BABYLON {
  73764. /** @hidden */
  73765. export var morphTargetsVertexDeclaration: {
  73766. name: string;
  73767. shader: string;
  73768. };
  73769. }
  73770. declare module BABYLON {
  73771. /** @hidden */
  73772. export var instancesDeclaration: {
  73773. name: string;
  73774. shader: string;
  73775. };
  73776. }
  73777. declare module BABYLON {
  73778. /** @hidden */
  73779. export var helperFunctions: {
  73780. name: string;
  73781. shader: string;
  73782. };
  73783. }
  73784. declare module BABYLON {
  73785. /** @hidden */
  73786. export var morphTargetsVertex: {
  73787. name: string;
  73788. shader: string;
  73789. };
  73790. }
  73791. declare module BABYLON {
  73792. /** @hidden */
  73793. export var instancesVertex: {
  73794. name: string;
  73795. shader: string;
  73796. };
  73797. }
  73798. declare module BABYLON {
  73799. /** @hidden */
  73800. export var bonesVertex: {
  73801. name: string;
  73802. shader: string;
  73803. };
  73804. }
  73805. declare module BABYLON {
  73806. /** @hidden */
  73807. export var shadowMapVertexShader: {
  73808. name: string;
  73809. shader: string;
  73810. };
  73811. }
  73812. declare module BABYLON {
  73813. /** @hidden */
  73814. export var depthBoxBlurPixelShader: {
  73815. name: string;
  73816. shader: string;
  73817. };
  73818. }
  73819. declare module BABYLON {
  73820. /**
  73821. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73822. */
  73823. export interface ICustomShaderOptions {
  73824. /**
  73825. * Gets or sets the custom shader name to use
  73826. */
  73827. shaderName: string;
  73828. /**
  73829. * The list of attribute names used in the shader
  73830. */
  73831. attributes?: string[];
  73832. /**
  73833. * The list of unifrom names used in the shader
  73834. */
  73835. uniforms?: string[];
  73836. /**
  73837. * The list of sampler names used in the shader
  73838. */
  73839. samplers?: string[];
  73840. /**
  73841. * The list of defines used in the shader
  73842. */
  73843. defines?: string[];
  73844. }
  73845. /**
  73846. * Interface to implement to create a shadow generator compatible with BJS.
  73847. */
  73848. export interface IShadowGenerator {
  73849. /**
  73850. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73851. * @returns The render target texture if present otherwise, null
  73852. */
  73853. getShadowMap(): Nullable<RenderTargetTexture>;
  73854. /**
  73855. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73856. * @returns The render target texture if the shadow map is present otherwise, null
  73857. */
  73858. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73859. /**
  73860. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73861. * @param subMesh The submesh we want to render in the shadow map
  73862. * @param useInstances Defines wether will draw in the map using instances
  73863. * @returns true if ready otherwise, false
  73864. */
  73865. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73866. /**
  73867. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73868. * @param defines Defines of the material we want to update
  73869. * @param lightIndex Index of the light in the enabled light list of the material
  73870. */
  73871. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73872. /**
  73873. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73874. * defined in the generator but impacting the effect).
  73875. * It implies the unifroms available on the materials are the standard BJS ones.
  73876. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73877. * @param effect The effect we are binfing the information for
  73878. */
  73879. bindShadowLight(lightIndex: string, effect: Effect): void;
  73880. /**
  73881. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73882. * (eq to shadow prjection matrix * light transform matrix)
  73883. * @returns The transform matrix used to create the shadow map
  73884. */
  73885. getTransformMatrix(): Matrix;
  73886. /**
  73887. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73888. * Cube and 2D textures for instance.
  73889. */
  73890. recreateShadowMap(): void;
  73891. /**
  73892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73893. * @param onCompiled Callback triggered at the and of the effects compilation
  73894. * @param options Sets of optional options forcing the compilation with different modes
  73895. */
  73896. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73897. useInstances: boolean;
  73898. }>): void;
  73899. /**
  73900. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73901. * @param options Sets of optional options forcing the compilation with different modes
  73902. * @returns A promise that resolves when the compilation completes
  73903. */
  73904. forceCompilationAsync(options?: Partial<{
  73905. useInstances: boolean;
  73906. }>): Promise<void>;
  73907. /**
  73908. * Serializes the shadow generator setup to a json object.
  73909. * @returns The serialized JSON object
  73910. */
  73911. serialize(): any;
  73912. /**
  73913. * Disposes the Shadow map and related Textures and effects.
  73914. */
  73915. dispose(): void;
  73916. }
  73917. /**
  73918. * Default implementation IShadowGenerator.
  73919. * This is the main object responsible of generating shadows in the framework.
  73920. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73921. */
  73922. export class ShadowGenerator implements IShadowGenerator {
  73923. /**
  73924. * Shadow generator mode None: no filtering applied.
  73925. */
  73926. static readonly FILTER_NONE: number;
  73927. /**
  73928. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73929. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73930. */
  73931. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73932. /**
  73933. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73934. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73935. */
  73936. static readonly FILTER_POISSONSAMPLING: number;
  73937. /**
  73938. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73940. */
  73941. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73942. /**
  73943. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73944. * edge artifacts on steep falloff.
  73945. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73946. */
  73947. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73948. /**
  73949. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73950. * edge artifacts on steep falloff.
  73951. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73952. */
  73953. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73954. /**
  73955. * Shadow generator mode PCF: Percentage Closer Filtering
  73956. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73957. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73958. */
  73959. static readonly FILTER_PCF: number;
  73960. /**
  73961. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73962. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73963. * Contact Hardening
  73964. */
  73965. static readonly FILTER_PCSS: number;
  73966. /**
  73967. * Reserved for PCF and PCSS
  73968. * Highest Quality.
  73969. *
  73970. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73971. *
  73972. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73973. */
  73974. static readonly QUALITY_HIGH: number;
  73975. /**
  73976. * Reserved for PCF and PCSS
  73977. * Good tradeoff for quality/perf cross devices
  73978. *
  73979. * Execute PCF on a 3*3 kernel.
  73980. *
  73981. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73982. */
  73983. static readonly QUALITY_MEDIUM: number;
  73984. /**
  73985. * Reserved for PCF and PCSS
  73986. * The lowest quality but the fastest.
  73987. *
  73988. * Execute PCF on a 1*1 kernel.
  73989. *
  73990. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73991. */
  73992. static readonly QUALITY_LOW: number;
  73993. /** Gets or sets the custom shader name to use */
  73994. customShaderOptions: ICustomShaderOptions;
  73995. /**
  73996. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73997. */
  73998. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73999. /**
  74000. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74001. */
  74002. onAfterShadowMapRenderObservable: Observable<Effect>;
  74003. /**
  74004. * Observable triggered before a mesh is rendered in the shadow map.
  74005. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74006. */
  74007. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74008. /**
  74009. * Observable triggered after a mesh is rendered in the shadow map.
  74010. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74011. */
  74012. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74013. private _bias;
  74014. /**
  74015. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74016. */
  74017. /**
  74018. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74019. */
  74020. bias: number;
  74021. private _normalBias;
  74022. /**
  74023. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74024. */
  74025. /**
  74026. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74027. */
  74028. normalBias: number;
  74029. private _blurBoxOffset;
  74030. /**
  74031. * Gets the blur box offset: offset applied during the blur pass.
  74032. * Only useful if useKernelBlur = false
  74033. */
  74034. /**
  74035. * Sets the blur box offset: offset applied during the blur pass.
  74036. * Only useful if useKernelBlur = false
  74037. */
  74038. blurBoxOffset: number;
  74039. private _blurScale;
  74040. /**
  74041. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74042. * 2 means half of the size.
  74043. */
  74044. /**
  74045. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74046. * 2 means half of the size.
  74047. */
  74048. blurScale: number;
  74049. private _blurKernel;
  74050. /**
  74051. * Gets the blur kernel: kernel size of the blur pass.
  74052. * Only useful if useKernelBlur = true
  74053. */
  74054. /**
  74055. * Sets the blur kernel: kernel size of the blur pass.
  74056. * Only useful if useKernelBlur = true
  74057. */
  74058. blurKernel: number;
  74059. private _useKernelBlur;
  74060. /**
  74061. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74062. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74063. */
  74064. /**
  74065. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74066. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74067. */
  74068. useKernelBlur: boolean;
  74069. private _depthScale;
  74070. /**
  74071. * Gets the depth scale used in ESM mode.
  74072. */
  74073. /**
  74074. * Sets the depth scale used in ESM mode.
  74075. * This can override the scale stored on the light.
  74076. */
  74077. depthScale: number;
  74078. private _filter;
  74079. /**
  74080. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74081. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74082. */
  74083. /**
  74084. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74085. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74086. */
  74087. filter: number;
  74088. /**
  74089. * Gets if the current filter is set to Poisson Sampling.
  74090. */
  74091. /**
  74092. * Sets the current filter to Poisson Sampling.
  74093. */
  74094. usePoissonSampling: boolean;
  74095. /**
  74096. * Gets if the current filter is set to ESM.
  74097. */
  74098. /**
  74099. * Sets the current filter is to ESM.
  74100. */
  74101. useExponentialShadowMap: boolean;
  74102. /**
  74103. * Gets if the current filter is set to filtered ESM.
  74104. */
  74105. /**
  74106. * Gets if the current filter is set to filtered ESM.
  74107. */
  74108. useBlurExponentialShadowMap: boolean;
  74109. /**
  74110. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74111. * exponential to prevent steep falloff artifacts).
  74112. */
  74113. /**
  74114. * Sets the current filter to "close ESM" (using the inverse of the
  74115. * exponential to prevent steep falloff artifacts).
  74116. */
  74117. useCloseExponentialShadowMap: boolean;
  74118. /**
  74119. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74120. * exponential to prevent steep falloff artifacts).
  74121. */
  74122. /**
  74123. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74124. * exponential to prevent steep falloff artifacts).
  74125. */
  74126. useBlurCloseExponentialShadowMap: boolean;
  74127. /**
  74128. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74129. */
  74130. /**
  74131. * Sets the current filter to "PCF" (percentage closer filtering).
  74132. */
  74133. usePercentageCloserFiltering: boolean;
  74134. private _filteringQuality;
  74135. /**
  74136. * Gets the PCF or PCSS Quality.
  74137. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74138. */
  74139. /**
  74140. * Sets the PCF or PCSS Quality.
  74141. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74142. */
  74143. filteringQuality: number;
  74144. /**
  74145. * Gets if the current filter is set to "PCSS" (contact hardening).
  74146. */
  74147. /**
  74148. * Sets the current filter to "PCSS" (contact hardening).
  74149. */
  74150. useContactHardeningShadow: boolean;
  74151. private _contactHardeningLightSizeUVRatio;
  74152. /**
  74153. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74154. * Using a ratio helps keeping shape stability independently of the map size.
  74155. *
  74156. * It does not account for the light projection as it was having too much
  74157. * instability during the light setup or during light position changes.
  74158. *
  74159. * Only valid if useContactHardeningShadow is true.
  74160. */
  74161. /**
  74162. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74163. * Using a ratio helps keeping shape stability independently of the map size.
  74164. *
  74165. * It does not account for the light projection as it was having too much
  74166. * instability during the light setup or during light position changes.
  74167. *
  74168. * Only valid if useContactHardeningShadow is true.
  74169. */
  74170. contactHardeningLightSizeUVRatio: number;
  74171. private _darkness;
  74172. /** Gets or sets the actual darkness of a shadow */
  74173. darkness: number;
  74174. /**
  74175. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74176. * 0 means strongest and 1 would means no shadow.
  74177. * @returns the darkness.
  74178. */
  74179. getDarkness(): number;
  74180. /**
  74181. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74182. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74183. * @returns the shadow generator allowing fluent coding.
  74184. */
  74185. setDarkness(darkness: number): ShadowGenerator;
  74186. private _transparencyShadow;
  74187. /** Gets or sets the ability to have transparent shadow */
  74188. transparencyShadow: boolean;
  74189. /**
  74190. * Sets the ability to have transparent shadow (boolean).
  74191. * @param transparent True if transparent else False
  74192. * @returns the shadow generator allowing fluent coding
  74193. */
  74194. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74195. private _shadowMap;
  74196. private _shadowMap2;
  74197. /**
  74198. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74199. * @returns The render target texture if present otherwise, null
  74200. */
  74201. getShadowMap(): Nullable<RenderTargetTexture>;
  74202. /**
  74203. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74204. * @returns The render target texture if the shadow map is present otherwise, null
  74205. */
  74206. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74207. /**
  74208. * Gets the class name of that object
  74209. * @returns "ShadowGenerator"
  74210. */
  74211. getClassName(): string;
  74212. /**
  74213. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74214. * @param mesh Mesh to add
  74215. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74216. * @returns the Shadow Generator itself
  74217. */
  74218. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74219. /**
  74220. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74221. * @param mesh Mesh to remove
  74222. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74223. * @returns the Shadow Generator itself
  74224. */
  74225. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74226. /**
  74227. * Controls the extent to which the shadows fade out at the edge of the frustum
  74228. * Used only by directionals and spots
  74229. */
  74230. frustumEdgeFalloff: number;
  74231. private _light;
  74232. /**
  74233. * Returns the associated light object.
  74234. * @returns the light generating the shadow
  74235. */
  74236. getLight(): IShadowLight;
  74237. /**
  74238. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74239. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74240. * It might on the other hand introduce peter panning.
  74241. */
  74242. forceBackFacesOnly: boolean;
  74243. private _scene;
  74244. private _lightDirection;
  74245. private _effect;
  74246. private _viewMatrix;
  74247. private _projectionMatrix;
  74248. private _transformMatrix;
  74249. private _cachedPosition;
  74250. private _cachedDirection;
  74251. private _cachedDefines;
  74252. private _currentRenderID;
  74253. private _boxBlurPostprocess;
  74254. private _kernelBlurXPostprocess;
  74255. private _kernelBlurYPostprocess;
  74256. private _blurPostProcesses;
  74257. private _mapSize;
  74258. private _currentFaceIndex;
  74259. private _currentFaceIndexCache;
  74260. private _textureType;
  74261. private _defaultTextureMatrix;
  74262. /** @hidden */
  74263. static _SceneComponentInitialization: (scene: Scene) => void;
  74264. /**
  74265. * Creates a ShadowGenerator object.
  74266. * A ShadowGenerator is the required tool to use the shadows.
  74267. * Each light casting shadows needs to use its own ShadowGenerator.
  74268. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74269. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74270. * @param light The light object generating the shadows.
  74271. * @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.
  74272. */
  74273. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74274. private _initializeGenerator;
  74275. private _initializeShadowMap;
  74276. private _initializeBlurRTTAndPostProcesses;
  74277. private _renderForShadowMap;
  74278. private _renderSubMeshForShadowMap;
  74279. private _applyFilterValues;
  74280. /**
  74281. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74282. * @param onCompiled Callback triggered at the and of the effects compilation
  74283. * @param options Sets of optional options forcing the compilation with different modes
  74284. */
  74285. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74286. useInstances: boolean;
  74287. }>): void;
  74288. /**
  74289. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74290. * @param options Sets of optional options forcing the compilation with different modes
  74291. * @returns A promise that resolves when the compilation completes
  74292. */
  74293. forceCompilationAsync(options?: Partial<{
  74294. useInstances: boolean;
  74295. }>): Promise<void>;
  74296. /**
  74297. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74298. * @param subMesh The submesh we want to render in the shadow map
  74299. * @param useInstances Defines wether will draw in the map using instances
  74300. * @returns true if ready otherwise, false
  74301. */
  74302. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74303. /**
  74304. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74305. * @param defines Defines of the material we want to update
  74306. * @param lightIndex Index of the light in the enabled light list of the material
  74307. */
  74308. prepareDefines(defines: any, lightIndex: number): void;
  74309. /**
  74310. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74311. * defined in the generator but impacting the effect).
  74312. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74313. * @param effect The effect we are binfing the information for
  74314. */
  74315. bindShadowLight(lightIndex: string, effect: Effect): void;
  74316. /**
  74317. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74318. * (eq to shadow prjection matrix * light transform matrix)
  74319. * @returns The transform matrix used to create the shadow map
  74320. */
  74321. getTransformMatrix(): Matrix;
  74322. /**
  74323. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74324. * Cube and 2D textures for instance.
  74325. */
  74326. recreateShadowMap(): void;
  74327. private _disposeBlurPostProcesses;
  74328. private _disposeRTTandPostProcesses;
  74329. /**
  74330. * Disposes the ShadowGenerator.
  74331. * Returns nothing.
  74332. */
  74333. dispose(): void;
  74334. /**
  74335. * Serializes the shadow generator setup to a json object.
  74336. * @returns The serialized JSON object
  74337. */
  74338. serialize(): any;
  74339. /**
  74340. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74341. * @param parsedShadowGenerator The JSON object to parse
  74342. * @param scene The scene to create the shadow map for
  74343. * @returns The parsed shadow generator
  74344. */
  74345. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74346. }
  74347. }
  74348. declare module BABYLON {
  74349. /**
  74350. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74351. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74352. * 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.
  74353. */
  74354. export abstract class Light extends Node {
  74355. /**
  74356. * Falloff Default: light is falling off following the material specification:
  74357. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74358. */
  74359. static readonly FALLOFF_DEFAULT: number;
  74360. /**
  74361. * Falloff Physical: light is falling off following the inverse squared distance law.
  74362. */
  74363. static readonly FALLOFF_PHYSICAL: number;
  74364. /**
  74365. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74366. * to enhance interoperability with other engines.
  74367. */
  74368. static readonly FALLOFF_GLTF: number;
  74369. /**
  74370. * Falloff Standard: light is falling off like in the standard material
  74371. * to enhance interoperability with other materials.
  74372. */
  74373. static readonly FALLOFF_STANDARD: number;
  74374. /**
  74375. * If every light affecting the material is in this lightmapMode,
  74376. * material.lightmapTexture adds or multiplies
  74377. * (depends on material.useLightmapAsShadowmap)
  74378. * after every other light calculations.
  74379. */
  74380. static readonly LIGHTMAP_DEFAULT: number;
  74381. /**
  74382. * material.lightmapTexture as only diffuse lighting from this light
  74383. * adds only specular lighting from this light
  74384. * adds dynamic shadows
  74385. */
  74386. static readonly LIGHTMAP_SPECULAR: number;
  74387. /**
  74388. * material.lightmapTexture as only lighting
  74389. * no light calculation from this light
  74390. * only adds dynamic shadows from this light
  74391. */
  74392. static readonly LIGHTMAP_SHADOWSONLY: number;
  74393. /**
  74394. * Each light type uses the default quantity according to its type:
  74395. * point/spot lights use luminous intensity
  74396. * directional lights use illuminance
  74397. */
  74398. static readonly INTENSITYMODE_AUTOMATIC: number;
  74399. /**
  74400. * lumen (lm)
  74401. */
  74402. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74403. /**
  74404. * candela (lm/sr)
  74405. */
  74406. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74407. /**
  74408. * lux (lm/m^2)
  74409. */
  74410. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74411. /**
  74412. * nit (cd/m^2)
  74413. */
  74414. static readonly INTENSITYMODE_LUMINANCE: number;
  74415. /**
  74416. * Light type const id of the point light.
  74417. */
  74418. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74419. /**
  74420. * Light type const id of the directional light.
  74421. */
  74422. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74423. /**
  74424. * Light type const id of the spot light.
  74425. */
  74426. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74427. /**
  74428. * Light type const id of the hemispheric light.
  74429. */
  74430. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74431. /**
  74432. * Diffuse gives the basic color to an object.
  74433. */
  74434. diffuse: Color3;
  74435. /**
  74436. * Specular produces a highlight color on an object.
  74437. * Note: This is note affecting PBR materials.
  74438. */
  74439. specular: Color3;
  74440. /**
  74441. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74442. * falling off base on range or angle.
  74443. * This can be set to any values in Light.FALLOFF_x.
  74444. *
  74445. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74446. * other types of materials.
  74447. */
  74448. falloffType: number;
  74449. /**
  74450. * Strength of the light.
  74451. * Note: By default it is define in the framework own unit.
  74452. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74453. */
  74454. intensity: number;
  74455. private _range;
  74456. protected _inverseSquaredRange: number;
  74457. /**
  74458. * Defines how far from the source the light is impacting in scene units.
  74459. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74460. */
  74461. /**
  74462. * Defines how far from the source the light is impacting in scene units.
  74463. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74464. */
  74465. range: number;
  74466. /**
  74467. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74468. * of light.
  74469. */
  74470. private _photometricScale;
  74471. private _intensityMode;
  74472. /**
  74473. * Gets the photometric scale used to interpret the intensity.
  74474. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74475. */
  74476. /**
  74477. * Sets the photometric scale used to interpret the intensity.
  74478. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74479. */
  74480. intensityMode: number;
  74481. private _radius;
  74482. /**
  74483. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74484. */
  74485. /**
  74486. * sets the light radius used by PBR Materials to simulate soft area lights.
  74487. */
  74488. radius: number;
  74489. private _renderPriority;
  74490. /**
  74491. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74492. * exceeding the number allowed of the materials.
  74493. */
  74494. renderPriority: number;
  74495. private _shadowEnabled;
  74496. /**
  74497. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74498. * the current shadow generator.
  74499. */
  74500. /**
  74501. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74502. * the current shadow generator.
  74503. */
  74504. shadowEnabled: boolean;
  74505. private _includedOnlyMeshes;
  74506. /**
  74507. * Gets the only meshes impacted by this light.
  74508. */
  74509. /**
  74510. * Sets the only meshes impacted by this light.
  74511. */
  74512. includedOnlyMeshes: AbstractMesh[];
  74513. private _excludedMeshes;
  74514. /**
  74515. * Gets the meshes not impacted by this light.
  74516. */
  74517. /**
  74518. * Sets the meshes not impacted by this light.
  74519. */
  74520. excludedMeshes: AbstractMesh[];
  74521. private _excludeWithLayerMask;
  74522. /**
  74523. * Gets the layer id use to find what meshes are not impacted by the light.
  74524. * Inactive if 0
  74525. */
  74526. /**
  74527. * Sets the layer id use to find what meshes are not impacted by the light.
  74528. * Inactive if 0
  74529. */
  74530. excludeWithLayerMask: number;
  74531. private _includeOnlyWithLayerMask;
  74532. /**
  74533. * Gets the layer id use to find what meshes are impacted by the light.
  74534. * Inactive if 0
  74535. */
  74536. /**
  74537. * Sets the layer id use to find what meshes are impacted by the light.
  74538. * Inactive if 0
  74539. */
  74540. includeOnlyWithLayerMask: number;
  74541. private _lightmapMode;
  74542. /**
  74543. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74544. */
  74545. /**
  74546. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74547. */
  74548. lightmapMode: number;
  74549. /**
  74550. * Shadow generator associted to the light.
  74551. * @hidden Internal use only.
  74552. */
  74553. _shadowGenerator: Nullable<IShadowGenerator>;
  74554. /**
  74555. * @hidden Internal use only.
  74556. */
  74557. _excludedMeshesIds: string[];
  74558. /**
  74559. * @hidden Internal use only.
  74560. */
  74561. _includedOnlyMeshesIds: string[];
  74562. /**
  74563. * The current light unifom buffer.
  74564. * @hidden Internal use only.
  74565. */
  74566. _uniformBuffer: UniformBuffer;
  74567. /**
  74568. * Creates a Light object in the scene.
  74569. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74570. * @param name The firendly name of the light
  74571. * @param scene The scene the light belongs too
  74572. */
  74573. constructor(name: string, scene: Scene);
  74574. protected abstract _buildUniformLayout(): void;
  74575. /**
  74576. * Sets the passed Effect "effect" with the Light information.
  74577. * @param effect The effect to update
  74578. * @param lightIndex The index of the light in the effect to update
  74579. * @returns The light
  74580. */
  74581. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74582. /**
  74583. * Returns the string "Light".
  74584. * @returns the class name
  74585. */
  74586. getClassName(): string;
  74587. /** @hidden */
  74588. readonly _isLight: boolean;
  74589. /**
  74590. * Converts the light information to a readable string for debug purpose.
  74591. * @param fullDetails Supports for multiple levels of logging within scene loading
  74592. * @returns the human readable light info
  74593. */
  74594. toString(fullDetails?: boolean): string;
  74595. /** @hidden */
  74596. protected _syncParentEnabledState(): void;
  74597. /**
  74598. * Set the enabled state of this node.
  74599. * @param value - the new enabled state
  74600. */
  74601. setEnabled(value: boolean): void;
  74602. /**
  74603. * Returns the Light associated shadow generator if any.
  74604. * @return the associated shadow generator.
  74605. */
  74606. getShadowGenerator(): Nullable<IShadowGenerator>;
  74607. /**
  74608. * Returns a Vector3, the absolute light position in the World.
  74609. * @returns the world space position of the light
  74610. */
  74611. getAbsolutePosition(): Vector3;
  74612. /**
  74613. * Specifies if the light will affect the passed mesh.
  74614. * @param mesh The mesh to test against the light
  74615. * @return true the mesh is affected otherwise, false.
  74616. */
  74617. canAffectMesh(mesh: AbstractMesh): boolean;
  74618. /**
  74619. * Sort function to order lights for rendering.
  74620. * @param a First Light object to compare to second.
  74621. * @param b Second Light object to compare first.
  74622. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74623. */
  74624. static CompareLightsPriority(a: Light, b: Light): number;
  74625. /**
  74626. * Releases resources associated with this node.
  74627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74629. */
  74630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74631. /**
  74632. * Returns the light type ID (integer).
  74633. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74634. */
  74635. getTypeID(): number;
  74636. /**
  74637. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74638. * @returns the scaled intensity in intensity mode unit
  74639. */
  74640. getScaledIntensity(): number;
  74641. /**
  74642. * Returns a new Light object, named "name", from the current one.
  74643. * @param name The name of the cloned light
  74644. * @returns the new created light
  74645. */
  74646. clone(name: string): Nullable<Light>;
  74647. /**
  74648. * Serializes the current light into a Serialization object.
  74649. * @returns the serialized object.
  74650. */
  74651. serialize(): any;
  74652. /**
  74653. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74654. * This new light is named "name" and added to the passed scene.
  74655. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74656. * @param name The friendly name of the light
  74657. * @param scene The scene the new light will belong to
  74658. * @returns the constructor function
  74659. */
  74660. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74661. /**
  74662. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74663. * @param parsedLight The JSON representation of the light
  74664. * @param scene The scene to create the parsed light in
  74665. * @returns the created light after parsing
  74666. */
  74667. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74668. private _hookArrayForExcluded;
  74669. private _hookArrayForIncludedOnly;
  74670. private _resyncMeshes;
  74671. /**
  74672. * Forces the meshes to update their light related information in their rendering used effects
  74673. * @hidden Internal Use Only
  74674. */
  74675. _markMeshesAsLightDirty(): void;
  74676. /**
  74677. * Recomputes the cached photometric scale if needed.
  74678. */
  74679. private _computePhotometricScale;
  74680. /**
  74681. * Returns the Photometric Scale according to the light type and intensity mode.
  74682. */
  74683. private _getPhotometricScale;
  74684. /**
  74685. * Reorder the light in the scene according to their defined priority.
  74686. * @hidden Internal Use Only
  74687. */
  74688. _reorderLightsInScene(): void;
  74689. /**
  74690. * Prepares the list of defines specific to the light type.
  74691. * @param defines the list of defines
  74692. * @param lightIndex defines the index of the light for the effect
  74693. */
  74694. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74695. }
  74696. }
  74697. declare module BABYLON {
  74698. /**
  74699. * Creates an instance based on a source mesh.
  74700. */
  74701. export class InstancedMesh extends AbstractMesh {
  74702. private _sourceMesh;
  74703. private _currentLOD;
  74704. /** @hidden */
  74705. _indexInSourceMeshInstanceArray: number;
  74706. constructor(name: string, source: Mesh);
  74707. /**
  74708. * Returns the string "InstancedMesh".
  74709. */
  74710. getClassName(): string;
  74711. /** Gets the list of lights affecting that mesh */
  74712. readonly lightSources: Light[];
  74713. _resyncLightSources(): void;
  74714. _resyncLighSource(light: Light): void;
  74715. _removeLightSource(light: Light): void;
  74716. /**
  74717. * If the source mesh receives shadows
  74718. */
  74719. readonly receiveShadows: boolean;
  74720. /**
  74721. * The material of the source mesh
  74722. */
  74723. readonly material: Nullable<Material>;
  74724. /**
  74725. * Visibility of the source mesh
  74726. */
  74727. readonly visibility: number;
  74728. /**
  74729. * Skeleton of the source mesh
  74730. */
  74731. readonly skeleton: Nullable<Skeleton>;
  74732. /**
  74733. * Rendering ground id of the source mesh
  74734. */
  74735. renderingGroupId: number;
  74736. /**
  74737. * Returns the total number of vertices (integer).
  74738. */
  74739. getTotalVertices(): number;
  74740. /**
  74741. * Returns a positive integer : the total number of indices in this mesh geometry.
  74742. * @returns the numner of indices or zero if the mesh has no geometry.
  74743. */
  74744. getTotalIndices(): number;
  74745. /**
  74746. * The source mesh of the instance
  74747. */
  74748. readonly sourceMesh: Mesh;
  74749. /**
  74750. * Is this node ready to be used/rendered
  74751. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74752. * @return {boolean} is it ready
  74753. */
  74754. isReady(completeCheck?: boolean): boolean;
  74755. /**
  74756. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74757. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74758. * @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.
  74759. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74760. */
  74761. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74762. /**
  74763. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74764. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74765. * The `data` are either a numeric array either a Float32Array.
  74766. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74767. * 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).
  74768. * Note that a new underlying VertexBuffer object is created each call.
  74769. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74770. *
  74771. * Possible `kind` values :
  74772. * - VertexBuffer.PositionKind
  74773. * - VertexBuffer.UVKind
  74774. * - VertexBuffer.UV2Kind
  74775. * - VertexBuffer.UV3Kind
  74776. * - VertexBuffer.UV4Kind
  74777. * - VertexBuffer.UV5Kind
  74778. * - VertexBuffer.UV6Kind
  74779. * - VertexBuffer.ColorKind
  74780. * - VertexBuffer.MatricesIndicesKind
  74781. * - VertexBuffer.MatricesIndicesExtraKind
  74782. * - VertexBuffer.MatricesWeightsKind
  74783. * - VertexBuffer.MatricesWeightsExtraKind
  74784. *
  74785. * Returns the Mesh.
  74786. */
  74787. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74788. /**
  74789. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74790. * If the mesh has no geometry, it is simply returned as it is.
  74791. * The `data` are either a numeric array either a Float32Array.
  74792. * No new underlying VertexBuffer object is created.
  74793. * 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.
  74794. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74795. *
  74796. * Possible `kind` values :
  74797. * - VertexBuffer.PositionKind
  74798. * - VertexBuffer.UVKind
  74799. * - VertexBuffer.UV2Kind
  74800. * - VertexBuffer.UV3Kind
  74801. * - VertexBuffer.UV4Kind
  74802. * - VertexBuffer.UV5Kind
  74803. * - VertexBuffer.UV6Kind
  74804. * - VertexBuffer.ColorKind
  74805. * - VertexBuffer.MatricesIndicesKind
  74806. * - VertexBuffer.MatricesIndicesExtraKind
  74807. * - VertexBuffer.MatricesWeightsKind
  74808. * - VertexBuffer.MatricesWeightsExtraKind
  74809. *
  74810. * Returns the Mesh.
  74811. */
  74812. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74813. /**
  74814. * Sets the mesh indices.
  74815. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74816. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74817. * This method creates a new index buffer each call.
  74818. * Returns the Mesh.
  74819. */
  74820. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74821. /**
  74822. * Boolean : True if the mesh owns the requested kind of data.
  74823. */
  74824. isVerticesDataPresent(kind: string): boolean;
  74825. /**
  74826. * Returns an array of indices (IndicesArray).
  74827. */
  74828. getIndices(): Nullable<IndicesArray>;
  74829. readonly _positions: Nullable<Vector3[]>;
  74830. /**
  74831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74832. * This means the mesh underlying bounding box and sphere are recomputed.
  74833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74834. * @returns the current mesh
  74835. */
  74836. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74837. /** @hidden */
  74838. _preActivate(): InstancedMesh;
  74839. /** @hidden */
  74840. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74841. /** @hidden */
  74842. _postActivate(): void;
  74843. getWorldMatrix(): Matrix;
  74844. readonly isAnInstance: boolean;
  74845. /**
  74846. * Returns the current associated LOD AbstractMesh.
  74847. */
  74848. getLOD(camera: Camera): AbstractMesh;
  74849. /** @hidden */
  74850. _syncSubMeshes(): InstancedMesh;
  74851. /** @hidden */
  74852. _generatePointsArray(): boolean;
  74853. /**
  74854. * Creates a new InstancedMesh from the current mesh.
  74855. * - name (string) : the cloned mesh name
  74856. * - newParent (optional Node) : the optional Node to parent the clone to.
  74857. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74858. *
  74859. * Returns the clone.
  74860. */
  74861. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74862. /**
  74863. * Disposes the InstancedMesh.
  74864. * Returns nothing.
  74865. */
  74866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74867. }
  74868. }
  74869. declare module BABYLON {
  74870. /**
  74871. * Defines the options associated with the creation of a shader material.
  74872. */
  74873. export interface IShaderMaterialOptions {
  74874. /**
  74875. * Does the material work in alpha blend mode
  74876. */
  74877. needAlphaBlending: boolean;
  74878. /**
  74879. * Does the material work in alpha test mode
  74880. */
  74881. needAlphaTesting: boolean;
  74882. /**
  74883. * The list of attribute names used in the shader
  74884. */
  74885. attributes: string[];
  74886. /**
  74887. * The list of unifrom names used in the shader
  74888. */
  74889. uniforms: string[];
  74890. /**
  74891. * The list of UBO names used in the shader
  74892. */
  74893. uniformBuffers: string[];
  74894. /**
  74895. * The list of sampler names used in the shader
  74896. */
  74897. samplers: string[];
  74898. /**
  74899. * The list of defines used in the shader
  74900. */
  74901. defines: string[];
  74902. }
  74903. /**
  74904. * 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.
  74905. *
  74906. * This returned material effects how the mesh will look based on the code in the shaders.
  74907. *
  74908. * @see http://doc.babylonjs.com/how_to/shader_material
  74909. */
  74910. export class ShaderMaterial extends Material {
  74911. private _shaderPath;
  74912. private _options;
  74913. private _textures;
  74914. private _textureArrays;
  74915. private _floats;
  74916. private _ints;
  74917. private _floatsArrays;
  74918. private _colors3;
  74919. private _colors3Arrays;
  74920. private _colors4;
  74921. private _colors4Arrays;
  74922. private _vectors2;
  74923. private _vectors3;
  74924. private _vectors4;
  74925. private _matrices;
  74926. private _matrices3x3;
  74927. private _matrices2x2;
  74928. private _vectors2Arrays;
  74929. private _vectors3Arrays;
  74930. private _vectors4Arrays;
  74931. private _cachedWorldViewMatrix;
  74932. private _cachedWorldViewProjectionMatrix;
  74933. private _renderId;
  74934. /**
  74935. * Instantiate a new shader material.
  74936. * 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.
  74937. * This returned material effects how the mesh will look based on the code in the shaders.
  74938. * @see http://doc.babylonjs.com/how_to/shader_material
  74939. * @param name Define the name of the material in the scene
  74940. * @param scene Define the scene the material belongs to
  74941. * @param shaderPath Defines the route to the shader code in one of three ways:
  74942. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74943. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74944. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74945. * @param options Define the options used to create the shader
  74946. */
  74947. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74948. /**
  74949. * Gets the options used to compile the shader.
  74950. * They can be modified to trigger a new compilation
  74951. */
  74952. readonly options: IShaderMaterialOptions;
  74953. /**
  74954. * Gets the current class name of the material e.g. "ShaderMaterial"
  74955. * Mainly use in serialization.
  74956. * @returns the class name
  74957. */
  74958. getClassName(): string;
  74959. /**
  74960. * Specifies if the material will require alpha blending
  74961. * @returns a boolean specifying if alpha blending is needed
  74962. */
  74963. needAlphaBlending(): boolean;
  74964. /**
  74965. * Specifies if this material should be rendered in alpha test mode
  74966. * @returns a boolean specifying if an alpha test is needed.
  74967. */
  74968. needAlphaTesting(): boolean;
  74969. private _checkUniform;
  74970. /**
  74971. * Set a texture in the shader.
  74972. * @param name Define the name of the uniform samplers as defined in the shader
  74973. * @param texture Define the texture to bind to this sampler
  74974. * @return the material itself allowing "fluent" like uniform updates
  74975. */
  74976. setTexture(name: string, texture: Texture): ShaderMaterial;
  74977. /**
  74978. * Set a texture array in the shader.
  74979. * @param name Define the name of the uniform sampler array as defined in the shader
  74980. * @param textures Define the list of textures to bind to this sampler
  74981. * @return the material itself allowing "fluent" like uniform updates
  74982. */
  74983. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74984. /**
  74985. * Set a float in the shader.
  74986. * @param name Define the name of the uniform as defined in the shader
  74987. * @param value Define the value to give to the uniform
  74988. * @return the material itself allowing "fluent" like uniform updates
  74989. */
  74990. setFloat(name: string, value: number): ShaderMaterial;
  74991. /**
  74992. * Set a int in the shader.
  74993. * @param name Define the name of the uniform as defined in the shader
  74994. * @param value Define the value to give to the uniform
  74995. * @return the material itself allowing "fluent" like uniform updates
  74996. */
  74997. setInt(name: string, value: number): ShaderMaterial;
  74998. /**
  74999. * Set an array of floats in the shader.
  75000. * @param name Define the name of the uniform as defined in the shader
  75001. * @param value Define the value to give to the uniform
  75002. * @return the material itself allowing "fluent" like uniform updates
  75003. */
  75004. setFloats(name: string, value: number[]): ShaderMaterial;
  75005. /**
  75006. * Set a vec3 in the shader from a Color3.
  75007. * @param name Define the name of the uniform as defined in the shader
  75008. * @param value Define the value to give to the uniform
  75009. * @return the material itself allowing "fluent" like uniform updates
  75010. */
  75011. setColor3(name: string, value: Color3): ShaderMaterial;
  75012. /**
  75013. * Set a vec3 array in the shader from a Color3 array.
  75014. * @param name Define the name of the uniform as defined in the shader
  75015. * @param value Define the value to give to the uniform
  75016. * @return the material itself allowing "fluent" like uniform updates
  75017. */
  75018. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75019. /**
  75020. * Set a vec4 in the shader from a Color4.
  75021. * @param name Define the name of the uniform as defined in the shader
  75022. * @param value Define the value to give to the uniform
  75023. * @return the material itself allowing "fluent" like uniform updates
  75024. */
  75025. setColor4(name: string, value: Color4): ShaderMaterial;
  75026. /**
  75027. * Set a vec4 array in the shader from a Color4 array.
  75028. * @param name Define the name of the uniform as defined in the shader
  75029. * @param value Define the value to give to the uniform
  75030. * @return the material itself allowing "fluent" like uniform updates
  75031. */
  75032. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75033. /**
  75034. * Set a vec2 in the shader from a Vector2.
  75035. * @param name Define the name of the uniform as defined in the shader
  75036. * @param value Define the value to give to the uniform
  75037. * @return the material itself allowing "fluent" like uniform updates
  75038. */
  75039. setVector2(name: string, value: Vector2): ShaderMaterial;
  75040. /**
  75041. * Set a vec3 in the shader from a Vector3.
  75042. * @param name Define the name of the uniform as defined in the shader
  75043. * @param value Define the value to give to the uniform
  75044. * @return the material itself allowing "fluent" like uniform updates
  75045. */
  75046. setVector3(name: string, value: Vector3): ShaderMaterial;
  75047. /**
  75048. * Set a vec4 in the shader from a Vector4.
  75049. * @param name Define the name of the uniform as defined in the shader
  75050. * @param value Define the value to give to the uniform
  75051. * @return the material itself allowing "fluent" like uniform updates
  75052. */
  75053. setVector4(name: string, value: Vector4): ShaderMaterial;
  75054. /**
  75055. * Set a mat4 in the shader from a Matrix.
  75056. * @param name Define the name of the uniform as defined in the shader
  75057. * @param value Define the value to give to the uniform
  75058. * @return the material itself allowing "fluent" like uniform updates
  75059. */
  75060. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75061. /**
  75062. * Set a mat3 in the shader from a Float32Array.
  75063. * @param name Define the name of the uniform as defined in the shader
  75064. * @param value Define the value to give to the uniform
  75065. * @return the material itself allowing "fluent" like uniform updates
  75066. */
  75067. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75068. /**
  75069. * Set a mat2 in the shader from a Float32Array.
  75070. * @param name Define the name of the uniform as defined in the shader
  75071. * @param value Define the value to give to the uniform
  75072. * @return the material itself allowing "fluent" like uniform updates
  75073. */
  75074. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75075. /**
  75076. * Set a vec2 array in the shader from a number array.
  75077. * @param name Define the name of the uniform as defined in the shader
  75078. * @param value Define the value to give to the uniform
  75079. * @return the material itself allowing "fluent" like uniform updates
  75080. */
  75081. setArray2(name: string, value: number[]): ShaderMaterial;
  75082. /**
  75083. * Set a vec3 array in the shader from a number array.
  75084. * @param name Define the name of the uniform as defined in the shader
  75085. * @param value Define the value to give to the uniform
  75086. * @return the material itself allowing "fluent" like uniform updates
  75087. */
  75088. setArray3(name: string, value: number[]): ShaderMaterial;
  75089. /**
  75090. * Set a vec4 array in the shader from a number array.
  75091. * @param name Define the name of the uniform as defined in the shader
  75092. * @param value Define the value to give to the uniform
  75093. * @return the material itself allowing "fluent" like uniform updates
  75094. */
  75095. setArray4(name: string, value: number[]): ShaderMaterial;
  75096. private _checkCache;
  75097. /**
  75098. * Specifies that the submesh is ready to be used
  75099. * @param mesh defines the mesh to check
  75100. * @param subMesh defines which submesh to check
  75101. * @param useInstances specifies that instances should be used
  75102. * @returns a boolean indicating that the submesh is ready or not
  75103. */
  75104. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75105. /**
  75106. * Checks if the material is ready to render the requested mesh
  75107. * @param mesh Define the mesh to render
  75108. * @param useInstances Define whether or not the material is used with instances
  75109. * @returns true if ready, otherwise false
  75110. */
  75111. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75112. /**
  75113. * Binds the world matrix to the material
  75114. * @param world defines the world transformation matrix
  75115. */
  75116. bindOnlyWorldMatrix(world: Matrix): void;
  75117. /**
  75118. * Binds the material to the mesh
  75119. * @param world defines the world transformation matrix
  75120. * @param mesh defines the mesh to bind the material to
  75121. */
  75122. bind(world: Matrix, mesh?: Mesh): void;
  75123. /**
  75124. * Gets the active textures from the material
  75125. * @returns an array of textures
  75126. */
  75127. getActiveTextures(): BaseTexture[];
  75128. /**
  75129. * Specifies if the material uses a texture
  75130. * @param texture defines the texture to check against the material
  75131. * @returns a boolean specifying if the material uses the texture
  75132. */
  75133. hasTexture(texture: BaseTexture): boolean;
  75134. /**
  75135. * Makes a duplicate of the material, and gives it a new name
  75136. * @param name defines the new name for the duplicated material
  75137. * @returns the cloned material
  75138. */
  75139. clone(name: string): ShaderMaterial;
  75140. /**
  75141. * Disposes the material
  75142. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75143. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75144. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75145. */
  75146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75147. /**
  75148. * Serializes this material in a JSON representation
  75149. * @returns the serialized material object
  75150. */
  75151. serialize(): any;
  75152. /**
  75153. * Creates a shader material from parsed shader material data
  75154. * @param source defines the JSON represnetation of the material
  75155. * @param scene defines the hosting scene
  75156. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75157. * @returns a new material
  75158. */
  75159. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75160. }
  75161. }
  75162. declare module BABYLON {
  75163. /** @hidden */
  75164. export var clipPlaneFragmentDeclaration: {
  75165. name: string;
  75166. shader: string;
  75167. };
  75168. }
  75169. declare module BABYLON {
  75170. /** @hidden */
  75171. export var clipPlaneFragment: {
  75172. name: string;
  75173. shader: string;
  75174. };
  75175. }
  75176. declare module BABYLON {
  75177. /** @hidden */
  75178. export var colorPixelShader: {
  75179. name: string;
  75180. shader: string;
  75181. };
  75182. }
  75183. declare module BABYLON {
  75184. /** @hidden */
  75185. export var clipPlaneVertexDeclaration: {
  75186. name: string;
  75187. shader: string;
  75188. };
  75189. }
  75190. declare module BABYLON {
  75191. /** @hidden */
  75192. export var clipPlaneVertex: {
  75193. name: string;
  75194. shader: string;
  75195. };
  75196. }
  75197. declare module BABYLON {
  75198. /** @hidden */
  75199. export var colorVertexShader: {
  75200. name: string;
  75201. shader: string;
  75202. };
  75203. }
  75204. declare module BABYLON {
  75205. /**
  75206. * Line mesh
  75207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75208. */
  75209. export class LinesMesh extends Mesh {
  75210. /**
  75211. * If vertex color should be applied to the mesh
  75212. */
  75213. readonly useVertexColor?: boolean | undefined;
  75214. /**
  75215. * If vertex alpha should be applied to the mesh
  75216. */
  75217. readonly useVertexAlpha?: boolean | undefined;
  75218. /**
  75219. * Color of the line (Default: White)
  75220. */
  75221. color: Color3;
  75222. /**
  75223. * Alpha of the line (Default: 1)
  75224. */
  75225. alpha: number;
  75226. /**
  75227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75228. * This margin is expressed in world space coordinates, so its value may vary.
  75229. * Default value is 0.1
  75230. */
  75231. intersectionThreshold: number;
  75232. private _colorShader;
  75233. private color4;
  75234. /**
  75235. * Creates a new LinesMesh
  75236. * @param name defines the name
  75237. * @param scene defines the hosting scene
  75238. * @param parent defines the parent mesh if any
  75239. * @param source defines the optional source LinesMesh used to clone data from
  75240. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75241. * When false, achieved by calling a clone(), also passing False.
  75242. * This will make creation of children, recursive.
  75243. * @param useVertexColor defines if this LinesMesh supports vertex color
  75244. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75245. */
  75246. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75247. /**
  75248. * If vertex color should be applied to the mesh
  75249. */
  75250. useVertexColor?: boolean | undefined,
  75251. /**
  75252. * If vertex alpha should be applied to the mesh
  75253. */
  75254. useVertexAlpha?: boolean | undefined);
  75255. private _addClipPlaneDefine;
  75256. private _removeClipPlaneDefine;
  75257. isReady(): boolean;
  75258. /**
  75259. * Returns the string "LineMesh"
  75260. */
  75261. getClassName(): string;
  75262. /**
  75263. * @hidden
  75264. */
  75265. /**
  75266. * @hidden
  75267. */
  75268. material: Material;
  75269. /**
  75270. * @hidden
  75271. */
  75272. readonly checkCollisions: boolean;
  75273. /** @hidden */
  75274. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75275. /** @hidden */
  75276. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75277. /**
  75278. * Disposes of the line mesh
  75279. * @param doNotRecurse If children should be disposed
  75280. */
  75281. dispose(doNotRecurse?: boolean): void;
  75282. /**
  75283. * Returns a new LineMesh object cloned from the current one.
  75284. */
  75285. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75286. /**
  75287. * Creates a new InstancedLinesMesh object from the mesh model.
  75288. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75289. * @param name defines the name of the new instance
  75290. * @returns a new InstancedLinesMesh
  75291. */
  75292. createInstance(name: string): InstancedLinesMesh;
  75293. }
  75294. /**
  75295. * Creates an instance based on a source LinesMesh
  75296. */
  75297. export class InstancedLinesMesh extends InstancedMesh {
  75298. /**
  75299. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75300. * This margin is expressed in world space coordinates, so its value may vary.
  75301. * Initilized with the intersectionThreshold value of the source LinesMesh
  75302. */
  75303. intersectionThreshold: number;
  75304. constructor(name: string, source: LinesMesh);
  75305. /**
  75306. * Returns the string "InstancedLinesMesh".
  75307. */
  75308. getClassName(): string;
  75309. }
  75310. }
  75311. declare module BABYLON {
  75312. /**
  75313. * Mesh representing the gorund
  75314. */
  75315. export class GroundMesh extends Mesh {
  75316. /** If octree should be generated */
  75317. generateOctree: boolean;
  75318. private _heightQuads;
  75319. /** @hidden */
  75320. _subdivisionsX: number;
  75321. /** @hidden */
  75322. _subdivisionsY: number;
  75323. /** @hidden */
  75324. _width: number;
  75325. /** @hidden */
  75326. _height: number;
  75327. /** @hidden */
  75328. _minX: number;
  75329. /** @hidden */
  75330. _maxX: number;
  75331. /** @hidden */
  75332. _minZ: number;
  75333. /** @hidden */
  75334. _maxZ: number;
  75335. constructor(name: string, scene: Scene);
  75336. /**
  75337. * "GroundMesh"
  75338. * @returns "GroundMesh"
  75339. */
  75340. getClassName(): string;
  75341. /**
  75342. * The minimum of x and y subdivisions
  75343. */
  75344. readonly subdivisions: number;
  75345. /**
  75346. * X subdivisions
  75347. */
  75348. readonly subdivisionsX: number;
  75349. /**
  75350. * Y subdivisions
  75351. */
  75352. readonly subdivisionsY: number;
  75353. /**
  75354. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75355. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75356. * @param chunksCount the number of subdivisions for x and y
  75357. * @param octreeBlocksSize (Default: 32)
  75358. */
  75359. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75360. /**
  75361. * Returns a height (y) value in the Worl system :
  75362. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75363. * @param x x coordinate
  75364. * @param z z coordinate
  75365. * @returns the ground y position if (x, z) are outside the ground surface.
  75366. */
  75367. getHeightAtCoordinates(x: number, z: number): number;
  75368. /**
  75369. * Returns a normalized vector (Vector3) orthogonal to the ground
  75370. * at the ground coordinates (x, z) expressed in the World system.
  75371. * @param x x coordinate
  75372. * @param z z coordinate
  75373. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75374. */
  75375. getNormalAtCoordinates(x: number, z: number): Vector3;
  75376. /**
  75377. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75378. * at the ground coordinates (x, z) expressed in the World system.
  75379. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75380. * @param x x coordinate
  75381. * @param z z coordinate
  75382. * @param ref vector to store the result
  75383. * @returns the GroundMesh.
  75384. */
  75385. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75386. /**
  75387. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75388. * if the ground has been updated.
  75389. * This can be used in the render loop.
  75390. * @returns the GroundMesh.
  75391. */
  75392. updateCoordinateHeights(): GroundMesh;
  75393. private _getFacetAt;
  75394. private _initHeightQuads;
  75395. private _computeHeightQuads;
  75396. /**
  75397. * Serializes this ground mesh
  75398. * @param serializationObject object to write serialization to
  75399. */
  75400. serialize(serializationObject: any): void;
  75401. /**
  75402. * Parses a serialized ground mesh
  75403. * @param parsedMesh the serialized mesh
  75404. * @param scene the scene to create the ground mesh in
  75405. * @returns the created ground mesh
  75406. */
  75407. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75408. }
  75409. }
  75410. declare module BABYLON {
  75411. /**
  75412. * Interface for Physics-Joint data
  75413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75414. */
  75415. export interface PhysicsJointData {
  75416. /**
  75417. * The main pivot of the joint
  75418. */
  75419. mainPivot?: Vector3;
  75420. /**
  75421. * The connected pivot of the joint
  75422. */
  75423. connectedPivot?: Vector3;
  75424. /**
  75425. * The main axis of the joint
  75426. */
  75427. mainAxis?: Vector3;
  75428. /**
  75429. * The connected axis of the joint
  75430. */
  75431. connectedAxis?: Vector3;
  75432. /**
  75433. * The collision of the joint
  75434. */
  75435. collision?: boolean;
  75436. /**
  75437. * Native Oimo/Cannon/Energy data
  75438. */
  75439. nativeParams?: any;
  75440. }
  75441. /**
  75442. * This is a holder class for the physics joint created by the physics plugin
  75443. * It holds a set of functions to control the underlying joint
  75444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75445. */
  75446. export class PhysicsJoint {
  75447. /**
  75448. * The type of the physics joint
  75449. */
  75450. type: number;
  75451. /**
  75452. * The data for the physics joint
  75453. */
  75454. jointData: PhysicsJointData;
  75455. private _physicsJoint;
  75456. protected _physicsPlugin: IPhysicsEnginePlugin;
  75457. /**
  75458. * Initializes the physics joint
  75459. * @param type The type of the physics joint
  75460. * @param jointData The data for the physics joint
  75461. */
  75462. constructor(
  75463. /**
  75464. * The type of the physics joint
  75465. */
  75466. type: number,
  75467. /**
  75468. * The data for the physics joint
  75469. */
  75470. jointData: PhysicsJointData);
  75471. /**
  75472. * Gets the physics joint
  75473. */
  75474. /**
  75475. * Sets the physics joint
  75476. */
  75477. physicsJoint: any;
  75478. /**
  75479. * Sets the physics plugin
  75480. */
  75481. physicsPlugin: IPhysicsEnginePlugin;
  75482. /**
  75483. * Execute a function that is physics-plugin specific.
  75484. * @param {Function} func the function that will be executed.
  75485. * It accepts two parameters: the physics world and the physics joint
  75486. */
  75487. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75488. /**
  75489. * Distance-Joint type
  75490. */
  75491. static DistanceJoint: number;
  75492. /**
  75493. * Hinge-Joint type
  75494. */
  75495. static HingeJoint: number;
  75496. /**
  75497. * Ball-and-Socket joint type
  75498. */
  75499. static BallAndSocketJoint: number;
  75500. /**
  75501. * Wheel-Joint type
  75502. */
  75503. static WheelJoint: number;
  75504. /**
  75505. * Slider-Joint type
  75506. */
  75507. static SliderJoint: number;
  75508. /**
  75509. * Prismatic-Joint type
  75510. */
  75511. static PrismaticJoint: number;
  75512. /**
  75513. * Universal-Joint type
  75514. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75515. */
  75516. static UniversalJoint: number;
  75517. /**
  75518. * Hinge-Joint 2 type
  75519. */
  75520. static Hinge2Joint: number;
  75521. /**
  75522. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75523. */
  75524. static PointToPointJoint: number;
  75525. /**
  75526. * Spring-Joint type
  75527. */
  75528. static SpringJoint: number;
  75529. /**
  75530. * Lock-Joint type
  75531. */
  75532. static LockJoint: number;
  75533. }
  75534. /**
  75535. * A class representing a physics distance joint
  75536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75537. */
  75538. export class DistanceJoint extends PhysicsJoint {
  75539. /**
  75540. *
  75541. * @param jointData The data for the Distance-Joint
  75542. */
  75543. constructor(jointData: DistanceJointData);
  75544. /**
  75545. * Update the predefined distance.
  75546. * @param maxDistance The maximum preferred distance
  75547. * @param minDistance The minimum preferred distance
  75548. */
  75549. updateDistance(maxDistance: number, minDistance?: number): void;
  75550. }
  75551. /**
  75552. * Represents a Motor-Enabled Joint
  75553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75554. */
  75555. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75556. /**
  75557. * Initializes the Motor-Enabled Joint
  75558. * @param type The type of the joint
  75559. * @param jointData The physica joint data for the joint
  75560. */
  75561. constructor(type: number, jointData: PhysicsJointData);
  75562. /**
  75563. * Set the motor values.
  75564. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75565. * @param force the force to apply
  75566. * @param maxForce max force for this motor.
  75567. */
  75568. setMotor(force?: number, maxForce?: number): void;
  75569. /**
  75570. * Set the motor's limits.
  75571. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75572. * @param upperLimit The upper limit of the motor
  75573. * @param lowerLimit The lower limit of the motor
  75574. */
  75575. setLimit(upperLimit: number, lowerLimit?: number): void;
  75576. }
  75577. /**
  75578. * This class represents a single physics Hinge-Joint
  75579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75580. */
  75581. export class HingeJoint extends MotorEnabledJoint {
  75582. /**
  75583. * Initializes the Hinge-Joint
  75584. * @param jointData The joint data for the Hinge-Joint
  75585. */
  75586. constructor(jointData: PhysicsJointData);
  75587. /**
  75588. * Set the motor values.
  75589. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75590. * @param {number} force the force to apply
  75591. * @param {number} maxForce max force for this motor.
  75592. */
  75593. setMotor(force?: number, maxForce?: number): void;
  75594. /**
  75595. * Set the motor's limits.
  75596. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75597. * @param upperLimit The upper limit of the motor
  75598. * @param lowerLimit The lower limit of the motor
  75599. */
  75600. setLimit(upperLimit: number, lowerLimit?: number): void;
  75601. }
  75602. /**
  75603. * This class represents a dual hinge physics joint (same as wheel joint)
  75604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75605. */
  75606. export class Hinge2Joint extends MotorEnabledJoint {
  75607. /**
  75608. * Initializes the Hinge2-Joint
  75609. * @param jointData The joint data for the Hinge2-Joint
  75610. */
  75611. constructor(jointData: PhysicsJointData);
  75612. /**
  75613. * Set the motor values.
  75614. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75615. * @param {number} targetSpeed the speed the motor is to reach
  75616. * @param {number} maxForce max force for this motor.
  75617. * @param {motorIndex} the motor's index, 0 or 1.
  75618. */
  75619. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75620. /**
  75621. * Set the motor limits.
  75622. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75623. * @param {number} upperLimit the upper limit
  75624. * @param {number} lowerLimit lower limit
  75625. * @param {motorIndex} the motor's index, 0 or 1.
  75626. */
  75627. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75628. }
  75629. /**
  75630. * Interface for a motor enabled joint
  75631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75632. */
  75633. export interface IMotorEnabledJoint {
  75634. /**
  75635. * Physics joint
  75636. */
  75637. physicsJoint: any;
  75638. /**
  75639. * Sets the motor of the motor-enabled joint
  75640. * @param force The force of the motor
  75641. * @param maxForce The maximum force of the motor
  75642. * @param motorIndex The index of the motor
  75643. */
  75644. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75645. /**
  75646. * Sets the limit of the motor
  75647. * @param upperLimit The upper limit of the motor
  75648. * @param lowerLimit The lower limit of the motor
  75649. * @param motorIndex The index of the motor
  75650. */
  75651. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75652. }
  75653. /**
  75654. * Joint data for a Distance-Joint
  75655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75656. */
  75657. export interface DistanceJointData extends PhysicsJointData {
  75658. /**
  75659. * Max distance the 2 joint objects can be apart
  75660. */
  75661. maxDistance: number;
  75662. }
  75663. /**
  75664. * Joint data from a spring joint
  75665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75666. */
  75667. export interface SpringJointData extends PhysicsJointData {
  75668. /**
  75669. * Length of the spring
  75670. */
  75671. length: number;
  75672. /**
  75673. * Stiffness of the spring
  75674. */
  75675. stiffness: number;
  75676. /**
  75677. * Damping of the spring
  75678. */
  75679. damping: number;
  75680. /** this callback will be called when applying the force to the impostors. */
  75681. forceApplicationCallback: () => void;
  75682. }
  75683. }
  75684. declare module BABYLON {
  75685. /**
  75686. * Holds the data for the raycast result
  75687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75688. */
  75689. export class PhysicsRaycastResult {
  75690. private _hasHit;
  75691. private _hitDistance;
  75692. private _hitNormalWorld;
  75693. private _hitPointWorld;
  75694. private _rayFromWorld;
  75695. private _rayToWorld;
  75696. /**
  75697. * Gets if there was a hit
  75698. */
  75699. readonly hasHit: boolean;
  75700. /**
  75701. * Gets the distance from the hit
  75702. */
  75703. readonly hitDistance: number;
  75704. /**
  75705. * Gets the hit normal/direction in the world
  75706. */
  75707. readonly hitNormalWorld: Vector3;
  75708. /**
  75709. * Gets the hit point in the world
  75710. */
  75711. readonly hitPointWorld: Vector3;
  75712. /**
  75713. * Gets the ray "start point" of the ray in the world
  75714. */
  75715. readonly rayFromWorld: Vector3;
  75716. /**
  75717. * Gets the ray "end point" of the ray in the world
  75718. */
  75719. readonly rayToWorld: Vector3;
  75720. /**
  75721. * Sets the hit data (normal & point in world space)
  75722. * @param hitNormalWorld defines the normal in world space
  75723. * @param hitPointWorld defines the point in world space
  75724. */
  75725. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75726. /**
  75727. * Sets the distance from the start point to the hit point
  75728. * @param distance
  75729. */
  75730. setHitDistance(distance: number): void;
  75731. /**
  75732. * Calculates the distance manually
  75733. */
  75734. calculateHitDistance(): void;
  75735. /**
  75736. * Resets all the values to default
  75737. * @param from The from point on world space
  75738. * @param to The to point on world space
  75739. */
  75740. reset(from?: Vector3, to?: Vector3): void;
  75741. }
  75742. /**
  75743. * Interface for the size containing width and height
  75744. */
  75745. interface IXYZ {
  75746. /**
  75747. * X
  75748. */
  75749. x: number;
  75750. /**
  75751. * Y
  75752. */
  75753. y: number;
  75754. /**
  75755. * Z
  75756. */
  75757. z: number;
  75758. }
  75759. }
  75760. declare module BABYLON {
  75761. /**
  75762. * Interface used to describe a physics joint
  75763. */
  75764. export interface PhysicsImpostorJoint {
  75765. /** Defines the main impostor to which the joint is linked */
  75766. mainImpostor: PhysicsImpostor;
  75767. /** Defines the impostor that is connected to the main impostor using this joint */
  75768. connectedImpostor: PhysicsImpostor;
  75769. /** Defines the joint itself */
  75770. joint: PhysicsJoint;
  75771. }
  75772. /** @hidden */
  75773. export interface IPhysicsEnginePlugin {
  75774. world: any;
  75775. name: string;
  75776. setGravity(gravity: Vector3): void;
  75777. setTimeStep(timeStep: number): void;
  75778. getTimeStep(): number;
  75779. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75780. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75781. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75782. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75783. removePhysicsBody(impostor: PhysicsImpostor): void;
  75784. generateJoint(joint: PhysicsImpostorJoint): void;
  75785. removeJoint(joint: PhysicsImpostorJoint): void;
  75786. isSupported(): boolean;
  75787. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75788. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75789. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75790. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75791. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75792. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75793. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75794. getBodyMass(impostor: PhysicsImpostor): number;
  75795. getBodyFriction(impostor: PhysicsImpostor): number;
  75796. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75797. getBodyRestitution(impostor: PhysicsImpostor): number;
  75798. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75799. getBodyPressure?(impostor: PhysicsImpostor): number;
  75800. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75801. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75802. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75803. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75804. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75805. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75806. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75807. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75808. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75809. sleepBody(impostor: PhysicsImpostor): void;
  75810. wakeUpBody(impostor: PhysicsImpostor): void;
  75811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75813. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75815. getRadius(impostor: PhysicsImpostor): number;
  75816. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75818. dispose(): void;
  75819. }
  75820. /**
  75821. * Interface used to define a physics engine
  75822. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75823. */
  75824. export interface IPhysicsEngine {
  75825. /**
  75826. * Gets the gravity vector used by the simulation
  75827. */
  75828. gravity: Vector3;
  75829. /**
  75830. * Sets the gravity vector used by the simulation
  75831. * @param gravity defines the gravity vector to use
  75832. */
  75833. setGravity(gravity: Vector3): void;
  75834. /**
  75835. * Set the time step of the physics engine.
  75836. * Default is 1/60.
  75837. * To slow it down, enter 1/600 for example.
  75838. * To speed it up, 1/30
  75839. * @param newTimeStep the new timestep to apply to this world.
  75840. */
  75841. setTimeStep(newTimeStep: number): void;
  75842. /**
  75843. * Get the time step of the physics engine.
  75844. * @returns the current time step
  75845. */
  75846. getTimeStep(): number;
  75847. /**
  75848. * Release all resources
  75849. */
  75850. dispose(): void;
  75851. /**
  75852. * Gets the name of the current physics plugin
  75853. * @returns the name of the plugin
  75854. */
  75855. getPhysicsPluginName(): string;
  75856. /**
  75857. * Adding a new impostor for the impostor tracking.
  75858. * This will be done by the impostor itself.
  75859. * @param impostor the impostor to add
  75860. */
  75861. addImpostor(impostor: PhysicsImpostor): void;
  75862. /**
  75863. * Remove an impostor from the engine.
  75864. * This impostor and its mesh will not longer be updated by the physics engine.
  75865. * @param impostor the impostor to remove
  75866. */
  75867. removeImpostor(impostor: PhysicsImpostor): void;
  75868. /**
  75869. * Add a joint to the physics engine
  75870. * @param mainImpostor defines the main impostor to which the joint is added.
  75871. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75872. * @param joint defines the joint that will connect both impostors.
  75873. */
  75874. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75875. /**
  75876. * Removes a joint from the simulation
  75877. * @param mainImpostor defines the impostor used with the joint
  75878. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75879. * @param joint defines the joint to remove
  75880. */
  75881. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75882. /**
  75883. * Gets the current plugin used to run the simulation
  75884. * @returns current plugin
  75885. */
  75886. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75887. /**
  75888. * Gets the list of physic impostors
  75889. * @returns an array of PhysicsImpostor
  75890. */
  75891. getImpostors(): Array<PhysicsImpostor>;
  75892. /**
  75893. * Gets the impostor for a physics enabled object
  75894. * @param object defines the object impersonated by the impostor
  75895. * @returns the PhysicsImpostor or null if not found
  75896. */
  75897. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75898. /**
  75899. * Gets the impostor for a physics body object
  75900. * @param body defines physics body used by the impostor
  75901. * @returns the PhysicsImpostor or null if not found
  75902. */
  75903. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75904. /**
  75905. * Does a raycast in the physics world
  75906. * @param from when should the ray start?
  75907. * @param to when should the ray end?
  75908. * @returns PhysicsRaycastResult
  75909. */
  75910. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75911. /**
  75912. * Called by the scene. No need to call it.
  75913. * @param delta defines the timespam between frames
  75914. */
  75915. _step(delta: number): void;
  75916. }
  75917. }
  75918. declare module BABYLON {
  75919. /**
  75920. * The interface for the physics imposter parameters
  75921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75922. */
  75923. export interface PhysicsImpostorParameters {
  75924. /**
  75925. * The mass of the physics imposter
  75926. */
  75927. mass: number;
  75928. /**
  75929. * The friction of the physics imposter
  75930. */
  75931. friction?: number;
  75932. /**
  75933. * The coefficient of restitution of the physics imposter
  75934. */
  75935. restitution?: number;
  75936. /**
  75937. * The native options of the physics imposter
  75938. */
  75939. nativeOptions?: any;
  75940. /**
  75941. * Specifies if the parent should be ignored
  75942. */
  75943. ignoreParent?: boolean;
  75944. /**
  75945. * Specifies if bi-directional transformations should be disabled
  75946. */
  75947. disableBidirectionalTransformation?: boolean;
  75948. /**
  75949. * The pressure inside the physics imposter, soft object only
  75950. */
  75951. pressure?: number;
  75952. /**
  75953. * The stiffness the physics imposter, soft object only
  75954. */
  75955. stiffness?: number;
  75956. /**
  75957. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75958. */
  75959. velocityIterations?: number;
  75960. /**
  75961. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75962. */
  75963. positionIterations?: number;
  75964. /**
  75965. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75966. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75967. * Add to fix multiple points
  75968. */
  75969. fixedPoints?: number;
  75970. /**
  75971. * The collision margin around a soft object
  75972. */
  75973. margin?: number;
  75974. /**
  75975. * The collision margin around a soft object
  75976. */
  75977. damping?: number;
  75978. /**
  75979. * The path for a rope based on an extrusion
  75980. */
  75981. path?: any;
  75982. /**
  75983. * The shape of an extrusion used for a rope based on an extrusion
  75984. */
  75985. shape?: any;
  75986. }
  75987. /**
  75988. * Interface for a physics-enabled object
  75989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75990. */
  75991. export interface IPhysicsEnabledObject {
  75992. /**
  75993. * The position of the physics-enabled object
  75994. */
  75995. position: Vector3;
  75996. /**
  75997. * The rotation of the physics-enabled object
  75998. */
  75999. rotationQuaternion: Nullable<Quaternion>;
  76000. /**
  76001. * The scale of the physics-enabled object
  76002. */
  76003. scaling: Vector3;
  76004. /**
  76005. * The rotation of the physics-enabled object
  76006. */
  76007. rotation?: Vector3;
  76008. /**
  76009. * The parent of the physics-enabled object
  76010. */
  76011. parent?: any;
  76012. /**
  76013. * The bounding info of the physics-enabled object
  76014. * @returns The bounding info of the physics-enabled object
  76015. */
  76016. getBoundingInfo(): BoundingInfo;
  76017. /**
  76018. * Computes the world matrix
  76019. * @param force Specifies if the world matrix should be computed by force
  76020. * @returns A world matrix
  76021. */
  76022. computeWorldMatrix(force: boolean): Matrix;
  76023. /**
  76024. * Gets the world matrix
  76025. * @returns A world matrix
  76026. */
  76027. getWorldMatrix?(): Matrix;
  76028. /**
  76029. * Gets the child meshes
  76030. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76031. * @returns An array of abstract meshes
  76032. */
  76033. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76034. /**
  76035. * Gets the vertex data
  76036. * @param kind The type of vertex data
  76037. * @returns A nullable array of numbers, or a float32 array
  76038. */
  76039. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76040. /**
  76041. * Gets the indices from the mesh
  76042. * @returns A nullable array of index arrays
  76043. */
  76044. getIndices?(): Nullable<IndicesArray>;
  76045. /**
  76046. * Gets the scene from the mesh
  76047. * @returns the indices array or null
  76048. */
  76049. getScene?(): Scene;
  76050. /**
  76051. * Gets the absolute position from the mesh
  76052. * @returns the absolute position
  76053. */
  76054. getAbsolutePosition(): Vector3;
  76055. /**
  76056. * Gets the absolute pivot point from the mesh
  76057. * @returns the absolute pivot point
  76058. */
  76059. getAbsolutePivotPoint(): Vector3;
  76060. /**
  76061. * Rotates the mesh
  76062. * @param axis The axis of rotation
  76063. * @param amount The amount of rotation
  76064. * @param space The space of the rotation
  76065. * @returns The rotation transform node
  76066. */
  76067. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76068. /**
  76069. * Translates the mesh
  76070. * @param axis The axis of translation
  76071. * @param distance The distance of translation
  76072. * @param space The space of the translation
  76073. * @returns The transform node
  76074. */
  76075. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76076. /**
  76077. * Sets the absolute position of the mesh
  76078. * @param absolutePosition The absolute position of the mesh
  76079. * @returns The transform node
  76080. */
  76081. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76082. /**
  76083. * Gets the class name of the mesh
  76084. * @returns The class name
  76085. */
  76086. getClassName(): string;
  76087. }
  76088. /**
  76089. * Represents a physics imposter
  76090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76091. */
  76092. export class PhysicsImpostor {
  76093. /**
  76094. * The physics-enabled object used as the physics imposter
  76095. */
  76096. object: IPhysicsEnabledObject;
  76097. /**
  76098. * The type of the physics imposter
  76099. */
  76100. type: number;
  76101. private _options;
  76102. private _scene?;
  76103. /**
  76104. * The default object size of the imposter
  76105. */
  76106. static DEFAULT_OBJECT_SIZE: Vector3;
  76107. /**
  76108. * The identity quaternion of the imposter
  76109. */
  76110. static IDENTITY_QUATERNION: Quaternion;
  76111. /** @hidden */
  76112. _pluginData: any;
  76113. private _physicsEngine;
  76114. private _physicsBody;
  76115. private _bodyUpdateRequired;
  76116. private _onBeforePhysicsStepCallbacks;
  76117. private _onAfterPhysicsStepCallbacks;
  76118. /** @hidden */
  76119. _onPhysicsCollideCallbacks: Array<{
  76120. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76121. otherImpostors: Array<PhysicsImpostor>;
  76122. }>;
  76123. private _deltaPosition;
  76124. private _deltaRotation;
  76125. private _deltaRotationConjugated;
  76126. /** @hidden */
  76127. _isFromLine: boolean;
  76128. private _parent;
  76129. private _isDisposed;
  76130. private static _tmpVecs;
  76131. private static _tmpQuat;
  76132. /**
  76133. * Specifies if the physics imposter is disposed
  76134. */
  76135. readonly isDisposed: boolean;
  76136. /**
  76137. * Gets the mass of the physics imposter
  76138. */
  76139. mass: number;
  76140. /**
  76141. * Gets the coefficient of friction
  76142. */
  76143. /**
  76144. * Sets the coefficient of friction
  76145. */
  76146. friction: number;
  76147. /**
  76148. * Gets the coefficient of restitution
  76149. */
  76150. /**
  76151. * Sets the coefficient of restitution
  76152. */
  76153. restitution: number;
  76154. /**
  76155. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76156. */
  76157. /**
  76158. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76159. */
  76160. pressure: number;
  76161. /**
  76162. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76163. */
  76164. /**
  76165. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76166. */
  76167. stiffness: number;
  76168. /**
  76169. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76170. */
  76171. /**
  76172. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76173. */
  76174. velocityIterations: number;
  76175. /**
  76176. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76177. */
  76178. /**
  76179. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76180. */
  76181. positionIterations: number;
  76182. /**
  76183. * The unique id of the physics imposter
  76184. * set by the physics engine when adding this impostor to the array
  76185. */
  76186. uniqueId: number;
  76187. /**
  76188. * @hidden
  76189. */
  76190. soft: boolean;
  76191. /**
  76192. * @hidden
  76193. */
  76194. segments: number;
  76195. private _joints;
  76196. /**
  76197. * Initializes the physics imposter
  76198. * @param object The physics-enabled object used as the physics imposter
  76199. * @param type The type of the physics imposter
  76200. * @param _options The options for the physics imposter
  76201. * @param _scene The Babylon scene
  76202. */
  76203. constructor(
  76204. /**
  76205. * The physics-enabled object used as the physics imposter
  76206. */
  76207. object: IPhysicsEnabledObject,
  76208. /**
  76209. * The type of the physics imposter
  76210. */
  76211. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76212. /**
  76213. * This function will completly initialize this impostor.
  76214. * It will create a new body - but only if this mesh has no parent.
  76215. * If it has, this impostor will not be used other than to define the impostor
  76216. * of the child mesh.
  76217. * @hidden
  76218. */
  76219. _init(): void;
  76220. private _getPhysicsParent;
  76221. /**
  76222. * Should a new body be generated.
  76223. * @returns boolean specifying if body initialization is required
  76224. */
  76225. isBodyInitRequired(): boolean;
  76226. /**
  76227. * Sets the updated scaling
  76228. * @param updated Specifies if the scaling is updated
  76229. */
  76230. setScalingUpdated(): void;
  76231. /**
  76232. * Force a regeneration of this or the parent's impostor's body.
  76233. * Use under cautious - This will remove all joints already implemented.
  76234. */
  76235. forceUpdate(): void;
  76236. /**
  76237. * Gets the body that holds this impostor. Either its own, or its parent.
  76238. */
  76239. /**
  76240. * Set the physics body. Used mainly by the physics engine/plugin
  76241. */
  76242. physicsBody: any;
  76243. /**
  76244. * Get the parent of the physics imposter
  76245. * @returns Physics imposter or null
  76246. */
  76247. /**
  76248. * Sets the parent of the physics imposter
  76249. */
  76250. parent: Nullable<PhysicsImpostor>;
  76251. /**
  76252. * Resets the update flags
  76253. */
  76254. resetUpdateFlags(): void;
  76255. /**
  76256. * Gets the object extend size
  76257. * @returns the object extend size
  76258. */
  76259. getObjectExtendSize(): Vector3;
  76260. /**
  76261. * Gets the object center
  76262. * @returns The object center
  76263. */
  76264. getObjectCenter(): Vector3;
  76265. /**
  76266. * Get a specific parametes from the options parameter
  76267. * @param paramName The object parameter name
  76268. * @returns The object parameter
  76269. */
  76270. getParam(paramName: string): any;
  76271. /**
  76272. * Sets a specific parameter in the options given to the physics plugin
  76273. * @param paramName The parameter name
  76274. * @param value The value of the parameter
  76275. */
  76276. setParam(paramName: string, value: number): void;
  76277. /**
  76278. * Specifically change the body's mass option. Won't recreate the physics body object
  76279. * @param mass The mass of the physics imposter
  76280. */
  76281. setMass(mass: number): void;
  76282. /**
  76283. * Gets the linear velocity
  76284. * @returns linear velocity or null
  76285. */
  76286. getLinearVelocity(): Nullable<Vector3>;
  76287. /**
  76288. * Sets the linear velocity
  76289. * @param velocity linear velocity or null
  76290. */
  76291. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76292. /**
  76293. * Gets the angular velocity
  76294. * @returns angular velocity or null
  76295. */
  76296. getAngularVelocity(): Nullable<Vector3>;
  76297. /**
  76298. * Sets the angular velocity
  76299. * @param velocity The velocity or null
  76300. */
  76301. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76302. /**
  76303. * Execute a function with the physics plugin native code
  76304. * Provide a function the will have two variables - the world object and the physics body object
  76305. * @param func The function to execute with the physics plugin native code
  76306. */
  76307. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76308. /**
  76309. * Register a function that will be executed before the physics world is stepping forward
  76310. * @param func The function to execute before the physics world is stepped forward
  76311. */
  76312. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76313. /**
  76314. * Unregister a function that will be executed before the physics world is stepping forward
  76315. * @param func The function to execute before the physics world is stepped forward
  76316. */
  76317. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76318. /**
  76319. * Register a function that will be executed after the physics step
  76320. * @param func The function to execute after physics step
  76321. */
  76322. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76323. /**
  76324. * Unregisters a function that will be executed after the physics step
  76325. * @param func The function to execute after physics step
  76326. */
  76327. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76328. /**
  76329. * register a function that will be executed when this impostor collides against a different body
  76330. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76331. * @param func Callback that is executed on collision
  76332. */
  76333. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76334. /**
  76335. * Unregisters the physics imposter on contact
  76336. * @param collideAgainst The physics object to collide against
  76337. * @param func Callback to execute on collision
  76338. */
  76339. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76340. private _tmpQuat;
  76341. private _tmpQuat2;
  76342. /**
  76343. * Get the parent rotation
  76344. * @returns The parent rotation
  76345. */
  76346. getParentsRotation(): Quaternion;
  76347. /**
  76348. * this function is executed by the physics engine.
  76349. */
  76350. beforeStep: () => void;
  76351. /**
  76352. * this function is executed by the physics engine
  76353. */
  76354. afterStep: () => void;
  76355. /**
  76356. * Legacy collision detection event support
  76357. */
  76358. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76359. /**
  76360. * event and body object due to cannon's event-based architecture.
  76361. */
  76362. onCollide: (e: {
  76363. body: any;
  76364. }) => void;
  76365. /**
  76366. * Apply a force
  76367. * @param force The force to apply
  76368. * @param contactPoint The contact point for the force
  76369. * @returns The physics imposter
  76370. */
  76371. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76372. /**
  76373. * Apply an impulse
  76374. * @param force The impulse force
  76375. * @param contactPoint The contact point for the impulse force
  76376. * @returns The physics imposter
  76377. */
  76378. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76379. /**
  76380. * A help function to create a joint
  76381. * @param otherImpostor A physics imposter used to create a joint
  76382. * @param jointType The type of joint
  76383. * @param jointData The data for the joint
  76384. * @returns The physics imposter
  76385. */
  76386. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76387. /**
  76388. * Add a joint to this impostor with a different impostor
  76389. * @param otherImpostor A physics imposter used to add a joint
  76390. * @param joint The joint to add
  76391. * @returns The physics imposter
  76392. */
  76393. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76394. /**
  76395. * Add an anchor to a cloth impostor
  76396. * @param otherImpostor rigid impostor to anchor to
  76397. * @param width ratio across width from 0 to 1
  76398. * @param height ratio up height from 0 to 1
  76399. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76400. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76401. * @returns impostor the soft imposter
  76402. */
  76403. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76404. /**
  76405. * Add a hook to a rope impostor
  76406. * @param otherImpostor rigid impostor to anchor to
  76407. * @param length ratio across rope from 0 to 1
  76408. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76409. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76410. * @returns impostor the rope imposter
  76411. */
  76412. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76413. /**
  76414. * Will keep this body still, in a sleep mode.
  76415. * @returns the physics imposter
  76416. */
  76417. sleep(): PhysicsImpostor;
  76418. /**
  76419. * Wake the body up.
  76420. * @returns The physics imposter
  76421. */
  76422. wakeUp(): PhysicsImpostor;
  76423. /**
  76424. * Clones the physics imposter
  76425. * @param newObject The physics imposter clones to this physics-enabled object
  76426. * @returns A nullable physics imposter
  76427. */
  76428. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76429. /**
  76430. * Disposes the physics imposter
  76431. */
  76432. dispose(): void;
  76433. /**
  76434. * Sets the delta position
  76435. * @param position The delta position amount
  76436. */
  76437. setDeltaPosition(position: Vector3): void;
  76438. /**
  76439. * Sets the delta rotation
  76440. * @param rotation The delta rotation amount
  76441. */
  76442. setDeltaRotation(rotation: Quaternion): void;
  76443. /**
  76444. * Gets the box size of the physics imposter and stores the result in the input parameter
  76445. * @param result Stores the box size
  76446. * @returns The physics imposter
  76447. */
  76448. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76449. /**
  76450. * Gets the radius of the physics imposter
  76451. * @returns Radius of the physics imposter
  76452. */
  76453. getRadius(): number;
  76454. /**
  76455. * Sync a bone with this impostor
  76456. * @param bone The bone to sync to the impostor.
  76457. * @param boneMesh The mesh that the bone is influencing.
  76458. * @param jointPivot The pivot of the joint / bone in local space.
  76459. * @param distToJoint Optional distance from the impostor to the joint.
  76460. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76461. */
  76462. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76463. /**
  76464. * Sync impostor to a bone
  76465. * @param bone The bone that the impostor will be synced to.
  76466. * @param boneMesh The mesh that the bone is influencing.
  76467. * @param jointPivot The pivot of the joint / bone in local space.
  76468. * @param distToJoint Optional distance from the impostor to the joint.
  76469. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76470. * @param boneAxis Optional vector3 axis the bone is aligned with
  76471. */
  76472. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76473. /**
  76474. * No-Imposter type
  76475. */
  76476. static NoImpostor: number;
  76477. /**
  76478. * Sphere-Imposter type
  76479. */
  76480. static SphereImpostor: number;
  76481. /**
  76482. * Box-Imposter type
  76483. */
  76484. static BoxImpostor: number;
  76485. /**
  76486. * Plane-Imposter type
  76487. */
  76488. static PlaneImpostor: number;
  76489. /**
  76490. * Mesh-imposter type
  76491. */
  76492. static MeshImpostor: number;
  76493. /**
  76494. * Capsule-Impostor type (Ammo.js plugin only)
  76495. */
  76496. static CapsuleImpostor: number;
  76497. /**
  76498. * Cylinder-Imposter type
  76499. */
  76500. static CylinderImpostor: number;
  76501. /**
  76502. * Particle-Imposter type
  76503. */
  76504. static ParticleImpostor: number;
  76505. /**
  76506. * Heightmap-Imposter type
  76507. */
  76508. static HeightmapImpostor: number;
  76509. /**
  76510. * ConvexHull-Impostor type (Ammo.js plugin only)
  76511. */
  76512. static ConvexHullImpostor: number;
  76513. /**
  76514. * Rope-Imposter type
  76515. */
  76516. static RopeImpostor: number;
  76517. /**
  76518. * Cloth-Imposter type
  76519. */
  76520. static ClothImpostor: number;
  76521. /**
  76522. * Softbody-Imposter type
  76523. */
  76524. static SoftbodyImpostor: number;
  76525. }
  76526. }
  76527. declare module BABYLON {
  76528. /**
  76529. * @hidden
  76530. **/
  76531. export class _CreationDataStorage {
  76532. closePath?: boolean;
  76533. closeArray?: boolean;
  76534. idx: number[];
  76535. dashSize: number;
  76536. gapSize: number;
  76537. path3D: Path3D;
  76538. pathArray: Vector3[][];
  76539. arc: number;
  76540. radius: number;
  76541. cap: number;
  76542. tessellation: number;
  76543. }
  76544. /**
  76545. * @hidden
  76546. **/
  76547. class _InstanceDataStorage {
  76548. visibleInstances: any;
  76549. batchCache: _InstancesBatch;
  76550. instancesBufferSize: number;
  76551. instancesBuffer: Nullable<Buffer>;
  76552. instancesData: Float32Array;
  76553. overridenInstanceCount: number;
  76554. isFrozen: boolean;
  76555. previousBatch: Nullable<_InstancesBatch>;
  76556. hardwareInstancedRendering: boolean;
  76557. sideOrientation: number;
  76558. }
  76559. /**
  76560. * @hidden
  76561. **/
  76562. export class _InstancesBatch {
  76563. mustReturn: boolean;
  76564. visibleInstances: Nullable<InstancedMesh[]>[];
  76565. renderSelf: boolean[];
  76566. hardwareInstancedRendering: boolean[];
  76567. }
  76568. /**
  76569. * Class used to represent renderable models
  76570. */
  76571. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76572. /**
  76573. * Mesh side orientation : usually the external or front surface
  76574. */
  76575. static readonly FRONTSIDE: number;
  76576. /**
  76577. * Mesh side orientation : usually the internal or back surface
  76578. */
  76579. static readonly BACKSIDE: number;
  76580. /**
  76581. * Mesh side orientation : both internal and external or front and back surfaces
  76582. */
  76583. static readonly DOUBLESIDE: number;
  76584. /**
  76585. * Mesh side orientation : by default, `FRONTSIDE`
  76586. */
  76587. static readonly DEFAULTSIDE: number;
  76588. /**
  76589. * Mesh cap setting : no cap
  76590. */
  76591. static readonly NO_CAP: number;
  76592. /**
  76593. * Mesh cap setting : one cap at the beginning of the mesh
  76594. */
  76595. static readonly CAP_START: number;
  76596. /**
  76597. * Mesh cap setting : one cap at the end of the mesh
  76598. */
  76599. static readonly CAP_END: number;
  76600. /**
  76601. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76602. */
  76603. static readonly CAP_ALL: number;
  76604. /**
  76605. * Mesh pattern setting : no flip or rotate
  76606. */
  76607. static readonly NO_FLIP: number;
  76608. /**
  76609. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76610. */
  76611. static readonly FLIP_TILE: number;
  76612. /**
  76613. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76614. */
  76615. static readonly ROTATE_TILE: number;
  76616. /**
  76617. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76618. */
  76619. static readonly FLIP_ROW: number;
  76620. /**
  76621. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76622. */
  76623. static readonly ROTATE_ROW: number;
  76624. /**
  76625. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76626. */
  76627. static readonly FLIP_N_ROTATE_TILE: number;
  76628. /**
  76629. * Mesh pattern setting : rotate pattern and rotate
  76630. */
  76631. static readonly FLIP_N_ROTATE_ROW: number;
  76632. /**
  76633. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76634. */
  76635. static readonly CENTER: number;
  76636. /**
  76637. * Mesh tile positioning : part tiles on left
  76638. */
  76639. static readonly LEFT: number;
  76640. /**
  76641. * Mesh tile positioning : part tiles on right
  76642. */
  76643. static readonly RIGHT: number;
  76644. /**
  76645. * Mesh tile positioning : part tiles on top
  76646. */
  76647. static readonly TOP: number;
  76648. /**
  76649. * Mesh tile positioning : part tiles on bottom
  76650. */
  76651. static readonly BOTTOM: number;
  76652. /**
  76653. * Gets the default side orientation.
  76654. * @param orientation the orientation to value to attempt to get
  76655. * @returns the default orientation
  76656. * @hidden
  76657. */
  76658. static _GetDefaultSideOrientation(orientation?: number): number;
  76659. private _internalMeshDataInfo;
  76660. /**
  76661. * An event triggered before rendering the mesh
  76662. */
  76663. readonly onBeforeRenderObservable: Observable<Mesh>;
  76664. /**
  76665. * An event triggered before binding the mesh
  76666. */
  76667. readonly onBeforeBindObservable: Observable<Mesh>;
  76668. /**
  76669. * An event triggered after rendering the mesh
  76670. */
  76671. readonly onAfterRenderObservable: Observable<Mesh>;
  76672. /**
  76673. * An event triggered before drawing the mesh
  76674. */
  76675. readonly onBeforeDrawObservable: Observable<Mesh>;
  76676. private _onBeforeDrawObserver;
  76677. /**
  76678. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76679. */
  76680. onBeforeDraw: () => void;
  76681. /**
  76682. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76683. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76684. */
  76685. delayLoadState: number;
  76686. /**
  76687. * Gets the list of instances created from this mesh
  76688. * it is not supposed to be modified manually.
  76689. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76690. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76691. */
  76692. instances: InstancedMesh[];
  76693. /**
  76694. * Gets the file containing delay loading data for this mesh
  76695. */
  76696. delayLoadingFile: string;
  76697. /** @hidden */
  76698. _binaryInfo: any;
  76699. /**
  76700. * User defined function used to change how LOD level selection is done
  76701. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76702. */
  76703. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76704. /**
  76705. * Gets or sets the morph target manager
  76706. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76707. */
  76708. morphTargetManager: Nullable<MorphTargetManager>;
  76709. /** @hidden */
  76710. _creationDataStorage: Nullable<_CreationDataStorage>;
  76711. /** @hidden */
  76712. _geometry: Nullable<Geometry>;
  76713. /** @hidden */
  76714. _delayInfo: Array<string>;
  76715. /** @hidden */
  76716. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76717. /** @hidden */
  76718. _instanceDataStorage: _InstanceDataStorage;
  76719. private _effectiveMaterial;
  76720. /** @hidden */
  76721. _shouldGenerateFlatShading: boolean;
  76722. /** @hidden */
  76723. _originalBuilderSideOrientation: number;
  76724. /**
  76725. * Use this property to change the original side orientation defined at construction time
  76726. */
  76727. overrideMaterialSideOrientation: Nullable<number>;
  76728. /**
  76729. * Gets the source mesh (the one used to clone this one from)
  76730. */
  76731. readonly source: Nullable<Mesh>;
  76732. /**
  76733. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76734. */
  76735. isUnIndexed: boolean;
  76736. /**
  76737. * @constructor
  76738. * @param name The value used by scene.getMeshByName() to do a lookup.
  76739. * @param scene The scene to add this mesh to.
  76740. * @param parent The parent of this mesh, if it has one
  76741. * @param source An optional Mesh from which geometry is shared, cloned.
  76742. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76743. * When false, achieved by calling a clone(), also passing False.
  76744. * This will make creation of children, recursive.
  76745. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76746. */
  76747. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76748. /**
  76749. * Gets the class name
  76750. * @returns the string "Mesh".
  76751. */
  76752. getClassName(): string;
  76753. /** @hidden */
  76754. readonly _isMesh: boolean;
  76755. /**
  76756. * Returns a description of this mesh
  76757. * @param fullDetails define if full details about this mesh must be used
  76758. * @returns a descriptive string representing this mesh
  76759. */
  76760. toString(fullDetails?: boolean): string;
  76761. /** @hidden */
  76762. _unBindEffect(): void;
  76763. /**
  76764. * Gets a boolean indicating if this mesh has LOD
  76765. */
  76766. readonly hasLODLevels: boolean;
  76767. /**
  76768. * Gets the list of MeshLODLevel associated with the current mesh
  76769. * @returns an array of MeshLODLevel
  76770. */
  76771. getLODLevels(): MeshLODLevel[];
  76772. private _sortLODLevels;
  76773. /**
  76774. * Add a mesh as LOD level triggered at the given distance.
  76775. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76776. * @param distance The distance from the center of the object to show this level
  76777. * @param mesh The mesh to be added as LOD level (can be null)
  76778. * @return This mesh (for chaining)
  76779. */
  76780. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76781. /**
  76782. * Returns the LOD level mesh at the passed distance or null if not found.
  76783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76784. * @param distance The distance from the center of the object to show this level
  76785. * @returns a Mesh or `null`
  76786. */
  76787. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76788. /**
  76789. * Remove a mesh from the LOD array
  76790. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76791. * @param mesh defines the mesh to be removed
  76792. * @return This mesh (for chaining)
  76793. */
  76794. removeLODLevel(mesh: Mesh): Mesh;
  76795. /**
  76796. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76797. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76798. * @param camera defines the camera to use to compute distance
  76799. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76800. * @return This mesh (for chaining)
  76801. */
  76802. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76803. /**
  76804. * Gets the mesh internal Geometry object
  76805. */
  76806. readonly geometry: Nullable<Geometry>;
  76807. /**
  76808. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76809. * @returns the total number of vertices
  76810. */
  76811. getTotalVertices(): number;
  76812. /**
  76813. * Returns the content of an associated vertex buffer
  76814. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76815. * - VertexBuffer.PositionKind
  76816. * - VertexBuffer.UVKind
  76817. * - VertexBuffer.UV2Kind
  76818. * - VertexBuffer.UV3Kind
  76819. * - VertexBuffer.UV4Kind
  76820. * - VertexBuffer.UV5Kind
  76821. * - VertexBuffer.UV6Kind
  76822. * - VertexBuffer.ColorKind
  76823. * - VertexBuffer.MatricesIndicesKind
  76824. * - VertexBuffer.MatricesIndicesExtraKind
  76825. * - VertexBuffer.MatricesWeightsKind
  76826. * - VertexBuffer.MatricesWeightsExtraKind
  76827. * @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
  76828. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76829. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76830. */
  76831. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76832. /**
  76833. * Returns the mesh VertexBuffer object from the requested `kind`
  76834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76835. * - VertexBuffer.PositionKind
  76836. * - VertexBuffer.NormalKind
  76837. * - VertexBuffer.UVKind
  76838. * - VertexBuffer.UV2Kind
  76839. * - VertexBuffer.UV3Kind
  76840. * - VertexBuffer.UV4Kind
  76841. * - VertexBuffer.UV5Kind
  76842. * - VertexBuffer.UV6Kind
  76843. * - VertexBuffer.ColorKind
  76844. * - VertexBuffer.MatricesIndicesKind
  76845. * - VertexBuffer.MatricesIndicesExtraKind
  76846. * - VertexBuffer.MatricesWeightsKind
  76847. * - VertexBuffer.MatricesWeightsExtraKind
  76848. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76849. */
  76850. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76851. /**
  76852. * Tests if a specific vertex buffer is associated with this mesh
  76853. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76854. * - VertexBuffer.PositionKind
  76855. * - VertexBuffer.NormalKind
  76856. * - VertexBuffer.UVKind
  76857. * - VertexBuffer.UV2Kind
  76858. * - VertexBuffer.UV3Kind
  76859. * - VertexBuffer.UV4Kind
  76860. * - VertexBuffer.UV5Kind
  76861. * - VertexBuffer.UV6Kind
  76862. * - VertexBuffer.ColorKind
  76863. * - VertexBuffer.MatricesIndicesKind
  76864. * - VertexBuffer.MatricesIndicesExtraKind
  76865. * - VertexBuffer.MatricesWeightsKind
  76866. * - VertexBuffer.MatricesWeightsExtraKind
  76867. * @returns a boolean
  76868. */
  76869. isVerticesDataPresent(kind: string): boolean;
  76870. /**
  76871. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76872. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76873. * - VertexBuffer.PositionKind
  76874. * - VertexBuffer.UVKind
  76875. * - VertexBuffer.UV2Kind
  76876. * - VertexBuffer.UV3Kind
  76877. * - VertexBuffer.UV4Kind
  76878. * - VertexBuffer.UV5Kind
  76879. * - VertexBuffer.UV6Kind
  76880. * - VertexBuffer.ColorKind
  76881. * - VertexBuffer.MatricesIndicesKind
  76882. * - VertexBuffer.MatricesIndicesExtraKind
  76883. * - VertexBuffer.MatricesWeightsKind
  76884. * - VertexBuffer.MatricesWeightsExtraKind
  76885. * @returns a boolean
  76886. */
  76887. isVertexBufferUpdatable(kind: string): boolean;
  76888. /**
  76889. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76890. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76891. * - VertexBuffer.PositionKind
  76892. * - VertexBuffer.NormalKind
  76893. * - VertexBuffer.UVKind
  76894. * - VertexBuffer.UV2Kind
  76895. * - VertexBuffer.UV3Kind
  76896. * - VertexBuffer.UV4Kind
  76897. * - VertexBuffer.UV5Kind
  76898. * - VertexBuffer.UV6Kind
  76899. * - VertexBuffer.ColorKind
  76900. * - VertexBuffer.MatricesIndicesKind
  76901. * - VertexBuffer.MatricesIndicesExtraKind
  76902. * - VertexBuffer.MatricesWeightsKind
  76903. * - VertexBuffer.MatricesWeightsExtraKind
  76904. * @returns an array of strings
  76905. */
  76906. getVerticesDataKinds(): string[];
  76907. /**
  76908. * Returns a positive integer : the total number of indices in this mesh geometry.
  76909. * @returns the numner of indices or zero if the mesh has no geometry.
  76910. */
  76911. getTotalIndices(): number;
  76912. /**
  76913. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76914. * @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.
  76915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76916. * @returns the indices array or an empty array if the mesh has no geometry
  76917. */
  76918. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76919. readonly isBlocked: boolean;
  76920. /**
  76921. * Determine if the current mesh is ready to be rendered
  76922. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76923. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76924. * @returns true if all associated assets are ready (material, textures, shaders)
  76925. */
  76926. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76927. /**
  76928. * 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.
  76929. */
  76930. readonly areNormalsFrozen: boolean;
  76931. /**
  76932. * 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.
  76933. * @returns the current mesh
  76934. */
  76935. freezeNormals(): Mesh;
  76936. /**
  76937. * 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
  76938. * @returns the current mesh
  76939. */
  76940. unfreezeNormals(): Mesh;
  76941. /**
  76942. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76943. */
  76944. overridenInstanceCount: number;
  76945. /** @hidden */
  76946. _preActivate(): Mesh;
  76947. /** @hidden */
  76948. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76949. /** @hidden */
  76950. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76951. /**
  76952. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76953. * This means the mesh underlying bounding box and sphere are recomputed.
  76954. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76955. * @returns the current mesh
  76956. */
  76957. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76958. /** @hidden */
  76959. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76960. /**
  76961. * This function will subdivide the mesh into multiple submeshes
  76962. * @param count defines the expected number of submeshes
  76963. */
  76964. subdivide(count: number): void;
  76965. /**
  76966. * Copy a FloatArray into a specific associated vertex buffer
  76967. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76968. * - VertexBuffer.PositionKind
  76969. * - VertexBuffer.UVKind
  76970. * - VertexBuffer.UV2Kind
  76971. * - VertexBuffer.UV3Kind
  76972. * - VertexBuffer.UV4Kind
  76973. * - VertexBuffer.UV5Kind
  76974. * - VertexBuffer.UV6Kind
  76975. * - VertexBuffer.ColorKind
  76976. * - VertexBuffer.MatricesIndicesKind
  76977. * - VertexBuffer.MatricesIndicesExtraKind
  76978. * - VertexBuffer.MatricesWeightsKind
  76979. * - VertexBuffer.MatricesWeightsExtraKind
  76980. * @param data defines the data source
  76981. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76982. * @param stride defines the data stride size (can be null)
  76983. * @returns the current mesh
  76984. */
  76985. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76986. /**
  76987. * Flags an associated vertex buffer as updatable
  76988. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76989. * - VertexBuffer.PositionKind
  76990. * - VertexBuffer.UVKind
  76991. * - VertexBuffer.UV2Kind
  76992. * - VertexBuffer.UV3Kind
  76993. * - VertexBuffer.UV4Kind
  76994. * - VertexBuffer.UV5Kind
  76995. * - VertexBuffer.UV6Kind
  76996. * - VertexBuffer.ColorKind
  76997. * - VertexBuffer.MatricesIndicesKind
  76998. * - VertexBuffer.MatricesIndicesExtraKind
  76999. * - VertexBuffer.MatricesWeightsKind
  77000. * - VertexBuffer.MatricesWeightsExtraKind
  77001. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77002. */
  77003. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77004. /**
  77005. * Sets the mesh global Vertex Buffer
  77006. * @param buffer defines the buffer to use
  77007. * @returns the current mesh
  77008. */
  77009. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77010. /**
  77011. * Update a specific associated vertex buffer
  77012. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77013. * - VertexBuffer.PositionKind
  77014. * - VertexBuffer.UVKind
  77015. * - VertexBuffer.UV2Kind
  77016. * - VertexBuffer.UV3Kind
  77017. * - VertexBuffer.UV4Kind
  77018. * - VertexBuffer.UV5Kind
  77019. * - VertexBuffer.UV6Kind
  77020. * - VertexBuffer.ColorKind
  77021. * - VertexBuffer.MatricesIndicesKind
  77022. * - VertexBuffer.MatricesIndicesExtraKind
  77023. * - VertexBuffer.MatricesWeightsKind
  77024. * - VertexBuffer.MatricesWeightsExtraKind
  77025. * @param data defines the data source
  77026. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77027. * @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)
  77028. * @returns the current mesh
  77029. */
  77030. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77031. /**
  77032. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77033. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77034. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77035. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77036. * @returns the current mesh
  77037. */
  77038. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77039. /**
  77040. * Creates a un-shared specific occurence of the geometry for the mesh.
  77041. * @returns the current mesh
  77042. */
  77043. makeGeometryUnique(): Mesh;
  77044. /**
  77045. * Set the index buffer of this mesh
  77046. * @param indices defines the source data
  77047. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77048. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77049. * @returns the current mesh
  77050. */
  77051. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77052. /**
  77053. * Update the current index buffer
  77054. * @param indices defines the source data
  77055. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77056. * @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)
  77057. * @returns the current mesh
  77058. */
  77059. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77060. /**
  77061. * Invert the geometry to move from a right handed system to a left handed one.
  77062. * @returns the current mesh
  77063. */
  77064. toLeftHanded(): Mesh;
  77065. /** @hidden */
  77066. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77067. /** @hidden */
  77068. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77069. /**
  77070. * Registers for this mesh a javascript function called just before the rendering process
  77071. * @param func defines the function to call before rendering this mesh
  77072. * @returns the current mesh
  77073. */
  77074. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77075. /**
  77076. * Disposes a previously registered javascript function called before the rendering
  77077. * @param func defines the function to remove
  77078. * @returns the current mesh
  77079. */
  77080. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77081. /**
  77082. * Registers for this mesh a javascript function called just after the rendering is complete
  77083. * @param func defines the function to call after rendering this mesh
  77084. * @returns the current mesh
  77085. */
  77086. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77087. /**
  77088. * Disposes a previously registered javascript function called after the rendering.
  77089. * @param func defines the function to remove
  77090. * @returns the current mesh
  77091. */
  77092. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77093. /** @hidden */
  77094. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77095. /** @hidden */
  77096. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77097. /** @hidden */
  77098. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77099. /** @hidden */
  77100. _rebuild(): void;
  77101. /** @hidden */
  77102. _freeze(): void;
  77103. /** @hidden */
  77104. _unFreeze(): void;
  77105. /**
  77106. * 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
  77107. * @param subMesh defines the subMesh to render
  77108. * @param enableAlphaMode defines if alpha mode can be changed
  77109. * @returns the current mesh
  77110. */
  77111. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77112. private _onBeforeDraw;
  77113. /**
  77114. * Renormalize the mesh and patch it up if there are no weights
  77115. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77116. * However in the case of zero weights then we set just a single influence to 1.
  77117. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77118. */
  77119. cleanMatrixWeights(): void;
  77120. private normalizeSkinFourWeights;
  77121. private normalizeSkinWeightsAndExtra;
  77122. /**
  77123. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77124. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77125. * the user know there was an issue with importing the mesh
  77126. * @returns a validation object with skinned, valid and report string
  77127. */
  77128. validateSkinning(): {
  77129. skinned: boolean;
  77130. valid: boolean;
  77131. report: string;
  77132. };
  77133. /** @hidden */
  77134. _checkDelayState(): Mesh;
  77135. private _queueLoad;
  77136. /**
  77137. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77138. * A mesh is in the frustum if its bounding box intersects the frustum
  77139. * @param frustumPlanes defines the frustum to test
  77140. * @returns true if the mesh is in the frustum planes
  77141. */
  77142. isInFrustum(frustumPlanes: Plane[]): boolean;
  77143. /**
  77144. * Sets the mesh material by the material or multiMaterial `id` property
  77145. * @param id is a string identifying the material or the multiMaterial
  77146. * @returns the current mesh
  77147. */
  77148. setMaterialByID(id: string): Mesh;
  77149. /**
  77150. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77151. * @returns an array of IAnimatable
  77152. */
  77153. getAnimatables(): IAnimatable[];
  77154. /**
  77155. * Modifies the mesh geometry according to the passed transformation matrix.
  77156. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77157. * The mesh normals are modified using the same transformation.
  77158. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77159. * @param transform defines the transform matrix to use
  77160. * @see http://doc.babylonjs.com/resources/baking_transformations
  77161. * @returns the current mesh
  77162. */
  77163. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77164. /**
  77165. * Modifies the mesh geometry according to its own current World Matrix.
  77166. * The mesh World Matrix is then reset.
  77167. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77169. * @see http://doc.babylonjs.com/resources/baking_transformations
  77170. * @returns the current mesh
  77171. */
  77172. bakeCurrentTransformIntoVertices(): Mesh;
  77173. /** @hidden */
  77174. readonly _positions: Nullable<Vector3[]>;
  77175. /** @hidden */
  77176. _resetPointsArrayCache(): Mesh;
  77177. /** @hidden */
  77178. _generatePointsArray(): boolean;
  77179. /**
  77180. * Returns a new Mesh object generated from the current mesh properties.
  77181. * This method must not get confused with createInstance()
  77182. * @param name is a string, the name given to the new mesh
  77183. * @param newParent can be any Node object (default `null`)
  77184. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77185. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77186. * @returns a new mesh
  77187. */
  77188. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77189. /**
  77190. * Releases resources associated with this mesh.
  77191. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77192. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77193. */
  77194. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77195. /**
  77196. * Modifies the mesh geometry according to a displacement map.
  77197. * 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.
  77198. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77199. * @param url is a string, the URL from the image file is to be downloaded.
  77200. * @param minHeight is the lower limit of the displacement.
  77201. * @param maxHeight is the upper limit of the displacement.
  77202. * @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.
  77203. * @param uvOffset is an optional vector2 used to offset UV.
  77204. * @param uvScale is an optional vector2 used to scale UV.
  77205. * @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.
  77206. * @returns the Mesh.
  77207. */
  77208. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77209. /**
  77210. * Modifies the mesh geometry according to a displacementMap buffer.
  77211. * 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.
  77212. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77213. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77214. * @param heightMapWidth is the width of the buffer image.
  77215. * @param heightMapHeight is the height of the buffer image.
  77216. * @param minHeight is the lower limit of the displacement.
  77217. * @param maxHeight is the upper limit of the displacement.
  77218. * @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.
  77219. * @param uvOffset is an optional vector2 used to offset UV.
  77220. * @param uvScale is an optional vector2 used to scale UV.
  77221. * @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.
  77222. * @returns the Mesh.
  77223. */
  77224. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77225. /**
  77226. * Modify the mesh to get a flat shading rendering.
  77227. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77228. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77229. * @returns current mesh
  77230. */
  77231. convertToFlatShadedMesh(): Mesh;
  77232. /**
  77233. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77234. * In other words, more vertices, no more indices and a single bigger VBO.
  77235. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77236. * @returns current mesh
  77237. */
  77238. convertToUnIndexedMesh(): Mesh;
  77239. /**
  77240. * Inverses facet orientations.
  77241. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77242. * @param flipNormals will also inverts the normals
  77243. * @returns current mesh
  77244. */
  77245. flipFaces(flipNormals?: boolean): Mesh;
  77246. /**
  77247. * Increase the number of facets and hence vertices in a mesh
  77248. * Vertex normals are interpolated from existing vertex normals
  77249. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77250. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77251. */
  77252. increaseVertices(numberPerEdge: number): void;
  77253. /**
  77254. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77255. * This will undo any application of covertToFlatShadedMesh
  77256. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77257. */
  77258. forceSharedVertices(): void;
  77259. /** @hidden */
  77260. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77261. /** @hidden */
  77262. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77263. /**
  77264. * Creates a new InstancedMesh object from the mesh model.
  77265. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77266. * @param name defines the name of the new instance
  77267. * @returns a new InstancedMesh
  77268. */
  77269. createInstance(name: string): InstancedMesh;
  77270. /**
  77271. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77272. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77273. * @returns the current mesh
  77274. */
  77275. synchronizeInstances(): Mesh;
  77276. /**
  77277. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77278. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77279. * This should be used together with the simplification to avoid disappearing triangles.
  77280. * @param successCallback an optional success callback to be called after the optimization finished.
  77281. * @returns the current mesh
  77282. */
  77283. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77284. /**
  77285. * Serialize current mesh
  77286. * @param serializationObject defines the object which will receive the serialization data
  77287. */
  77288. serialize(serializationObject: any): void;
  77289. /** @hidden */
  77290. _syncGeometryWithMorphTargetManager(): void;
  77291. /** @hidden */
  77292. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77293. /**
  77294. * Returns a new Mesh object parsed from the source provided.
  77295. * @param parsedMesh is the source
  77296. * @param scene defines the hosting scene
  77297. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77298. * @returns a new Mesh
  77299. */
  77300. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77301. /**
  77302. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77303. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77304. * @param name defines the name of the mesh to create
  77305. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77306. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77307. * @param closePath creates a seam between the first and the last points of each path of the path array
  77308. * @param offset is taken in account only if the `pathArray` is containing a single path
  77309. * @param scene defines the hosting scene
  77310. * @param updatable defines if the mesh must be flagged as updatable
  77311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77312. * @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)
  77313. * @returns a new Mesh
  77314. */
  77315. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77316. /**
  77317. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77318. * @param name defines the name of the mesh to create
  77319. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77320. * @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
  77321. * @param scene defines the hosting scene
  77322. * @param updatable defines if the mesh must be flagged as updatable
  77323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77324. * @returns a new Mesh
  77325. */
  77326. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77327. /**
  77328. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77329. * @param name defines the name of the mesh to create
  77330. * @param size sets the size (float) of each box side (default 1)
  77331. * @param scene defines the hosting scene
  77332. * @param updatable defines if the mesh must be flagged as updatable
  77333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77334. * @returns a new Mesh
  77335. */
  77336. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77337. /**
  77338. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77339. * @param name defines the name of the mesh to create
  77340. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77341. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77342. * @param scene defines the hosting scene
  77343. * @param updatable defines if the mesh must be flagged as updatable
  77344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77345. * @returns a new Mesh
  77346. */
  77347. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77348. /**
  77349. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77350. * @param name defines the name of the mesh to create
  77351. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77353. * @param scene defines the hosting scene
  77354. * @returns a new Mesh
  77355. */
  77356. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77357. /**
  77358. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77359. * @param name defines the name of the mesh to create
  77360. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77361. * @param diameterTop set the top cap diameter (floats, default 1)
  77362. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77363. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77364. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77365. * @param scene defines the hosting scene
  77366. * @param updatable defines if the mesh must be flagged as updatable
  77367. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77368. * @returns a new Mesh
  77369. */
  77370. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77371. /**
  77372. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77373. * @param name defines the name of the mesh to create
  77374. * @param diameter sets the diameter size (float) of the torus (default 1)
  77375. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77376. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77377. * @param scene defines the hosting scene
  77378. * @param updatable defines if the mesh must be flagged as updatable
  77379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77380. * @returns a new Mesh
  77381. */
  77382. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77383. /**
  77384. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77385. * @param name defines the name of the mesh to create
  77386. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77387. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77388. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77389. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77390. * @param p the number of windings on X axis (positive integers, default 2)
  77391. * @param q the number of windings on Y axis (positive integers, default 3)
  77392. * @param scene defines the hosting scene
  77393. * @param updatable defines if the mesh must be flagged as updatable
  77394. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77395. * @returns a new Mesh
  77396. */
  77397. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77398. /**
  77399. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77400. * @param name defines the name of the mesh to create
  77401. * @param points is an array successive Vector3
  77402. * @param scene defines the hosting scene
  77403. * @param updatable defines if the mesh must be flagged as updatable
  77404. * @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).
  77405. * @returns a new Mesh
  77406. */
  77407. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77408. /**
  77409. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77410. * @param name defines the name of the mesh to create
  77411. * @param points is an array successive Vector3
  77412. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77413. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77414. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77415. * @param scene defines the hosting scene
  77416. * @param updatable defines if the mesh must be flagged as updatable
  77417. * @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)
  77418. * @returns a new Mesh
  77419. */
  77420. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77421. /**
  77422. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77423. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77424. * 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.
  77425. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77426. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77427. * Remember you can only change the shape positions, not their number when updating a polygon.
  77428. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77429. * @param name defines the name of the mesh to create
  77430. * @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
  77431. * @param scene defines the hosting scene
  77432. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77433. * @param updatable defines if the mesh must be flagged as updatable
  77434. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77435. * @param earcutInjection can be used to inject your own earcut reference
  77436. * @returns a new Mesh
  77437. */
  77438. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77439. /**
  77440. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77441. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77442. * @param name defines the name of the mesh to create
  77443. * @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
  77444. * @param depth defines the height of extrusion
  77445. * @param scene defines the hosting scene
  77446. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77447. * @param updatable defines if the mesh must be flagged as updatable
  77448. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77449. * @param earcutInjection can be used to inject your own earcut reference
  77450. * @returns a new Mesh
  77451. */
  77452. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77453. /**
  77454. * Creates an extruded shape mesh.
  77455. * 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
  77456. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77458. * @param name defines the name of the mesh to create
  77459. * @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
  77460. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77461. * @param scale is the value to scale the shape
  77462. * @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
  77463. * @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
  77464. * @param scene defines the hosting scene
  77465. * @param updatable defines if the mesh must be flagged as updatable
  77466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77467. * @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)
  77468. * @returns a new Mesh
  77469. */
  77470. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77471. /**
  77472. * Creates an custom extruded shape mesh.
  77473. * The custom extrusion is a parametric shape.
  77474. * It has no predefined shape. Its final shape will depend on the input parameters.
  77475. * Please consider using the same method from the MeshBuilder class instead
  77476. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77477. * @param name defines the name of the mesh to create
  77478. * @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
  77479. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77480. * @param scaleFunction is a custom Javascript function called on each path point
  77481. * @param rotationFunction is a custom Javascript function called on each path point
  77482. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77483. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77484. * @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
  77485. * @param scene defines the hosting scene
  77486. * @param updatable defines if the mesh must be flagged as updatable
  77487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77488. * @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)
  77489. * @returns a new Mesh
  77490. */
  77491. 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;
  77492. /**
  77493. * Creates lathe mesh.
  77494. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77495. * Please consider using the same method from the MeshBuilder class instead
  77496. * @param name defines the name of the mesh to create
  77497. * @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
  77498. * @param radius is the radius value of the lathe
  77499. * @param tessellation is the side number of the lathe.
  77500. * @param scene defines the hosting scene
  77501. * @param updatable defines if the mesh must be flagged as updatable
  77502. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77503. * @returns a new Mesh
  77504. */
  77505. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77506. /**
  77507. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77508. * @param name defines the name of the mesh to create
  77509. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77510. * @param scene defines the hosting scene
  77511. * @param updatable defines if the mesh must be flagged as updatable
  77512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77513. * @returns a new Mesh
  77514. */
  77515. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77516. /**
  77517. * Creates a ground mesh.
  77518. * Please consider using the same method from the MeshBuilder class instead
  77519. * @param name defines the name of the mesh to create
  77520. * @param width set the width of the ground
  77521. * @param height set the height of the ground
  77522. * @param subdivisions sets the number of subdivisions per side
  77523. * @param scene defines the hosting scene
  77524. * @param updatable defines if the mesh must be flagged as updatable
  77525. * @returns a new Mesh
  77526. */
  77527. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77528. /**
  77529. * Creates a tiled ground mesh.
  77530. * Please consider using the same method from the MeshBuilder class instead
  77531. * @param name defines the name of the mesh to create
  77532. * @param xmin set the ground minimum X coordinate
  77533. * @param zmin set the ground minimum Y coordinate
  77534. * @param xmax set the ground maximum X coordinate
  77535. * @param zmax set the ground maximum Z coordinate
  77536. * @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
  77537. * @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
  77538. * @param scene defines the hosting scene
  77539. * @param updatable defines if the mesh must be flagged as updatable
  77540. * @returns a new Mesh
  77541. */
  77542. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77543. w: number;
  77544. h: number;
  77545. }, precision: {
  77546. w: number;
  77547. h: number;
  77548. }, scene: Scene, updatable?: boolean): Mesh;
  77549. /**
  77550. * Creates a ground mesh from a height map.
  77551. * Please consider using the same method from the MeshBuilder class instead
  77552. * @see http://doc.babylonjs.com/babylon101/height_map
  77553. * @param name defines the name of the mesh to create
  77554. * @param url sets the URL of the height map image resource
  77555. * @param width set the ground width size
  77556. * @param height set the ground height size
  77557. * @param subdivisions sets the number of subdivision per side
  77558. * @param minHeight is the minimum altitude on the ground
  77559. * @param maxHeight is the maximum altitude on the ground
  77560. * @param scene defines the hosting scene
  77561. * @param updatable defines if the mesh must be flagged as updatable
  77562. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77563. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77564. * @returns a new Mesh
  77565. */
  77566. 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;
  77567. /**
  77568. * Creates a tube mesh.
  77569. * The tube is a parametric shape.
  77570. * It has no predefined shape. Its final shape will depend on the input parameters.
  77571. * Please consider using the same method from the MeshBuilder class instead
  77572. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77573. * @param name defines the name of the mesh to create
  77574. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77575. * @param radius sets the tube radius size
  77576. * @param tessellation is the number of sides on the tubular surface
  77577. * @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
  77578. * @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
  77579. * @param scene defines the hosting scene
  77580. * @param updatable defines if the mesh must be flagged as updatable
  77581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77582. * @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)
  77583. * @returns a new Mesh
  77584. */
  77585. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77586. (i: number, distance: number): number;
  77587. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77588. /**
  77589. * Creates a polyhedron mesh.
  77590. * Please consider using the same method from the MeshBuilder class instead.
  77591. * * 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
  77592. * * The parameter `size` (positive float, default 1) sets the polygon size
  77593. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77594. * * 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`
  77595. * * 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
  77596. * * 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)`)
  77597. * * 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
  77598. * * 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
  77599. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77600. * * If you create a double-sided mesh, you can choose what parts of 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
  77601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77602. * @param name defines the name of the mesh to create
  77603. * @param options defines the options used to create the mesh
  77604. * @param scene defines the hosting scene
  77605. * @returns a new Mesh
  77606. */
  77607. static CreatePolyhedron(name: string, options: {
  77608. type?: number;
  77609. size?: number;
  77610. sizeX?: number;
  77611. sizeY?: number;
  77612. sizeZ?: number;
  77613. custom?: any;
  77614. faceUV?: Vector4[];
  77615. faceColors?: Color4[];
  77616. updatable?: boolean;
  77617. sideOrientation?: number;
  77618. }, scene: Scene): Mesh;
  77619. /**
  77620. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77621. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77622. * * 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`)
  77623. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77624. * * 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
  77625. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77626. * * If you create a double-sided mesh, you can choose what parts of 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
  77627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77628. * @param name defines the name of the mesh
  77629. * @param options defines the options used to create the mesh
  77630. * @param scene defines the hosting scene
  77631. * @returns a new Mesh
  77632. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77633. */
  77634. static CreateIcoSphere(name: string, options: {
  77635. radius?: number;
  77636. flat?: boolean;
  77637. subdivisions?: number;
  77638. sideOrientation?: number;
  77639. updatable?: boolean;
  77640. }, scene: Scene): Mesh;
  77641. /**
  77642. * Creates a decal mesh.
  77643. * Please consider using the same method from the MeshBuilder class instead.
  77644. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77645. * @param name defines the name of the mesh
  77646. * @param sourceMesh defines the mesh receiving the decal
  77647. * @param position sets the position of the decal in world coordinates
  77648. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77649. * @param size sets the decal scaling
  77650. * @param angle sets the angle to rotate the decal
  77651. * @returns a new Mesh
  77652. */
  77653. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77654. /**
  77655. * Prepare internal position array for software CPU skinning
  77656. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77657. */
  77658. setPositionsForCPUSkinning(): Float32Array;
  77659. /**
  77660. * Prepare internal normal array for software CPU skinning
  77661. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77662. */
  77663. setNormalsForCPUSkinning(): Float32Array;
  77664. /**
  77665. * Updates the vertex buffer by applying transformation from the bones
  77666. * @param skeleton defines the skeleton to apply to current mesh
  77667. * @returns the current mesh
  77668. */
  77669. applySkeleton(skeleton: Skeleton): Mesh;
  77670. /**
  77671. * 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
  77672. * @param meshes defines the list of meshes to scan
  77673. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77674. */
  77675. static MinMax(meshes: AbstractMesh[]): {
  77676. min: Vector3;
  77677. max: Vector3;
  77678. };
  77679. /**
  77680. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77681. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77682. * @returns a vector3
  77683. */
  77684. static Center(meshesOrMinMaxVector: {
  77685. min: Vector3;
  77686. max: Vector3;
  77687. } | AbstractMesh[]): Vector3;
  77688. /**
  77689. * Merge the array of meshes into a single mesh for performance reasons.
  77690. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77691. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77692. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77693. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77694. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77695. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77696. * @returns a new mesh
  77697. */
  77698. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77699. /** @hidden */
  77700. addInstance(instance: InstancedMesh): void;
  77701. /** @hidden */
  77702. removeInstance(instance: InstancedMesh): void;
  77703. }
  77704. }
  77705. declare module BABYLON {
  77706. /**
  77707. * Interface used to define Action
  77708. */
  77709. export interface IAction {
  77710. /**
  77711. * Trigger for the action
  77712. */
  77713. trigger: number;
  77714. /** Options of the trigger */
  77715. triggerOptions: any;
  77716. /**
  77717. * Gets the trigger parameters
  77718. * @returns the trigger parameters
  77719. */
  77720. getTriggerParameter(): any;
  77721. /**
  77722. * Internal only - executes current action event
  77723. * @hidden
  77724. */
  77725. _executeCurrent(evt?: ActionEvent): void;
  77726. /**
  77727. * Serialize placeholder for child classes
  77728. * @param parent of child
  77729. * @returns the serialized object
  77730. */
  77731. serialize(parent: any): any;
  77732. /**
  77733. * Internal only
  77734. * @hidden
  77735. */
  77736. _prepare(): void;
  77737. /**
  77738. * Internal only - manager for action
  77739. * @hidden
  77740. */
  77741. _actionManager: AbstractActionManager;
  77742. /**
  77743. * Adds action to chain of actions, may be a DoNothingAction
  77744. * @param action defines the next action to execute
  77745. * @returns The action passed in
  77746. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77747. */
  77748. then(action: IAction): IAction;
  77749. }
  77750. /**
  77751. * The action to be carried out following a trigger
  77752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77753. */
  77754. export class Action implements IAction {
  77755. /** the trigger, with or without parameters, for the action */
  77756. triggerOptions: any;
  77757. /**
  77758. * Trigger for the action
  77759. */
  77760. trigger: number;
  77761. /**
  77762. * Internal only - manager for action
  77763. * @hidden
  77764. */
  77765. _actionManager: ActionManager;
  77766. private _nextActiveAction;
  77767. private _child;
  77768. private _condition?;
  77769. private _triggerParameter;
  77770. /**
  77771. * An event triggered prior to action being executed.
  77772. */
  77773. onBeforeExecuteObservable: Observable<Action>;
  77774. /**
  77775. * Creates a new Action
  77776. * @param triggerOptions the trigger, with or without parameters, for the action
  77777. * @param condition an optional determinant of action
  77778. */
  77779. constructor(
  77780. /** the trigger, with or without parameters, for the action */
  77781. triggerOptions: any, condition?: Condition);
  77782. /**
  77783. * Internal only
  77784. * @hidden
  77785. */
  77786. _prepare(): void;
  77787. /**
  77788. * Gets the trigger parameters
  77789. * @returns the trigger parameters
  77790. */
  77791. getTriggerParameter(): any;
  77792. /**
  77793. * Internal only - executes current action event
  77794. * @hidden
  77795. */
  77796. _executeCurrent(evt?: ActionEvent): void;
  77797. /**
  77798. * Execute placeholder for child classes
  77799. * @param evt optional action event
  77800. */
  77801. execute(evt?: ActionEvent): void;
  77802. /**
  77803. * Skips to next active action
  77804. */
  77805. skipToNextActiveAction(): void;
  77806. /**
  77807. * Adds action to chain of actions, may be a DoNothingAction
  77808. * @param action defines the next action to execute
  77809. * @returns The action passed in
  77810. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77811. */
  77812. then(action: Action): Action;
  77813. /**
  77814. * Internal only
  77815. * @hidden
  77816. */
  77817. _getProperty(propertyPath: string): string;
  77818. /**
  77819. * Internal only
  77820. * @hidden
  77821. */
  77822. _getEffectiveTarget(target: any, propertyPath: string): any;
  77823. /**
  77824. * Serialize placeholder for child classes
  77825. * @param parent of child
  77826. * @returns the serialized object
  77827. */
  77828. serialize(parent: any): any;
  77829. /**
  77830. * Internal only called by serialize
  77831. * @hidden
  77832. */
  77833. protected _serialize(serializedAction: any, parent?: any): any;
  77834. /**
  77835. * Internal only
  77836. * @hidden
  77837. */
  77838. static _SerializeValueAsString: (value: any) => string;
  77839. /**
  77840. * Internal only
  77841. * @hidden
  77842. */
  77843. static _GetTargetProperty: (target: Scene | Node) => {
  77844. name: string;
  77845. targetType: string;
  77846. value: string;
  77847. };
  77848. }
  77849. }
  77850. declare module BABYLON {
  77851. /**
  77852. * A Condition applied to an Action
  77853. */
  77854. export class Condition {
  77855. /**
  77856. * Internal only - manager for action
  77857. * @hidden
  77858. */
  77859. _actionManager: ActionManager;
  77860. /**
  77861. * Internal only
  77862. * @hidden
  77863. */
  77864. _evaluationId: number;
  77865. /**
  77866. * Internal only
  77867. * @hidden
  77868. */
  77869. _currentResult: boolean;
  77870. /**
  77871. * Creates a new Condition
  77872. * @param actionManager the manager of the action the condition is applied to
  77873. */
  77874. constructor(actionManager: ActionManager);
  77875. /**
  77876. * Check if the current condition is valid
  77877. * @returns a boolean
  77878. */
  77879. isValid(): boolean;
  77880. /**
  77881. * Internal only
  77882. * @hidden
  77883. */
  77884. _getProperty(propertyPath: string): string;
  77885. /**
  77886. * Internal only
  77887. * @hidden
  77888. */
  77889. _getEffectiveTarget(target: any, propertyPath: string): any;
  77890. /**
  77891. * Serialize placeholder for child classes
  77892. * @returns the serialized object
  77893. */
  77894. serialize(): any;
  77895. /**
  77896. * Internal only
  77897. * @hidden
  77898. */
  77899. protected _serialize(serializedCondition: any): any;
  77900. }
  77901. /**
  77902. * Defines specific conditional operators as extensions of Condition
  77903. */
  77904. export class ValueCondition extends Condition {
  77905. /** path to specify the property of the target the conditional operator uses */
  77906. propertyPath: string;
  77907. /** the value compared by the conditional operator against the current value of the property */
  77908. value: any;
  77909. /** the conditional operator, default ValueCondition.IsEqual */
  77910. operator: number;
  77911. /**
  77912. * Internal only
  77913. * @hidden
  77914. */
  77915. private static _IsEqual;
  77916. /**
  77917. * Internal only
  77918. * @hidden
  77919. */
  77920. private static _IsDifferent;
  77921. /**
  77922. * Internal only
  77923. * @hidden
  77924. */
  77925. private static _IsGreater;
  77926. /**
  77927. * Internal only
  77928. * @hidden
  77929. */
  77930. private static _IsLesser;
  77931. /**
  77932. * returns the number for IsEqual
  77933. */
  77934. static readonly IsEqual: number;
  77935. /**
  77936. * Returns the number for IsDifferent
  77937. */
  77938. static readonly IsDifferent: number;
  77939. /**
  77940. * Returns the number for IsGreater
  77941. */
  77942. static readonly IsGreater: number;
  77943. /**
  77944. * Returns the number for IsLesser
  77945. */
  77946. static readonly IsLesser: number;
  77947. /**
  77948. * Internal only The action manager for the condition
  77949. * @hidden
  77950. */
  77951. _actionManager: ActionManager;
  77952. /**
  77953. * Internal only
  77954. * @hidden
  77955. */
  77956. private _target;
  77957. /**
  77958. * Internal only
  77959. * @hidden
  77960. */
  77961. private _effectiveTarget;
  77962. /**
  77963. * Internal only
  77964. * @hidden
  77965. */
  77966. private _property;
  77967. /**
  77968. * Creates a new ValueCondition
  77969. * @param actionManager manager for the action the condition applies to
  77970. * @param target for the action
  77971. * @param propertyPath path to specify the property of the target the conditional operator uses
  77972. * @param value the value compared by the conditional operator against the current value of the property
  77973. * @param operator the conditional operator, default ValueCondition.IsEqual
  77974. */
  77975. constructor(actionManager: ActionManager, target: any,
  77976. /** path to specify the property of the target the conditional operator uses */
  77977. propertyPath: string,
  77978. /** the value compared by the conditional operator against the current value of the property */
  77979. value: any,
  77980. /** the conditional operator, default ValueCondition.IsEqual */
  77981. operator?: number);
  77982. /**
  77983. * Compares the given value with the property value for the specified conditional operator
  77984. * @returns the result of the comparison
  77985. */
  77986. isValid(): boolean;
  77987. /**
  77988. * Serialize the ValueCondition into a JSON compatible object
  77989. * @returns serialization object
  77990. */
  77991. serialize(): any;
  77992. /**
  77993. * Gets the name of the conditional operator for the ValueCondition
  77994. * @param operator the conditional operator
  77995. * @returns the name
  77996. */
  77997. static GetOperatorName(operator: number): string;
  77998. }
  77999. /**
  78000. * Defines a predicate condition as an extension of Condition
  78001. */
  78002. export class PredicateCondition extends Condition {
  78003. /** defines the predicate function used to validate the condition */
  78004. predicate: () => boolean;
  78005. /**
  78006. * Internal only - manager for action
  78007. * @hidden
  78008. */
  78009. _actionManager: ActionManager;
  78010. /**
  78011. * Creates a new PredicateCondition
  78012. * @param actionManager manager for the action the condition applies to
  78013. * @param predicate defines the predicate function used to validate the condition
  78014. */
  78015. constructor(actionManager: ActionManager,
  78016. /** defines the predicate function used to validate the condition */
  78017. predicate: () => boolean);
  78018. /**
  78019. * @returns the validity of the predicate condition
  78020. */
  78021. isValid(): boolean;
  78022. }
  78023. /**
  78024. * Defines a state condition as an extension of Condition
  78025. */
  78026. export class StateCondition extends Condition {
  78027. /** Value to compare with target state */
  78028. value: string;
  78029. /**
  78030. * Internal only - manager for action
  78031. * @hidden
  78032. */
  78033. _actionManager: ActionManager;
  78034. /**
  78035. * Internal only
  78036. * @hidden
  78037. */
  78038. private _target;
  78039. /**
  78040. * Creates a new StateCondition
  78041. * @param actionManager manager for the action the condition applies to
  78042. * @param target of the condition
  78043. * @param value to compare with target state
  78044. */
  78045. constructor(actionManager: ActionManager, target: any,
  78046. /** Value to compare with target state */
  78047. value: string);
  78048. /**
  78049. * Gets a boolean indicating if the current condition is met
  78050. * @returns the validity of the state
  78051. */
  78052. isValid(): boolean;
  78053. /**
  78054. * Serialize the StateCondition into a JSON compatible object
  78055. * @returns serialization object
  78056. */
  78057. serialize(): any;
  78058. }
  78059. }
  78060. declare module BABYLON {
  78061. /**
  78062. * This defines an action responsible to toggle a boolean once triggered.
  78063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78064. */
  78065. export class SwitchBooleanAction extends Action {
  78066. /**
  78067. * The path to the boolean property in the target object
  78068. */
  78069. propertyPath: string;
  78070. private _target;
  78071. private _effectiveTarget;
  78072. private _property;
  78073. /**
  78074. * Instantiate the action
  78075. * @param triggerOptions defines the trigger options
  78076. * @param target defines the object containing the boolean
  78077. * @param propertyPath defines the path to the boolean property in the target object
  78078. * @param condition defines the trigger related conditions
  78079. */
  78080. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78081. /** @hidden */
  78082. _prepare(): void;
  78083. /**
  78084. * Execute the action toggle the boolean value.
  78085. */
  78086. execute(): void;
  78087. /**
  78088. * Serializes the actions and its related information.
  78089. * @param parent defines the object to serialize in
  78090. * @returns the serialized object
  78091. */
  78092. serialize(parent: any): any;
  78093. }
  78094. /**
  78095. * This defines an action responsible to set a the state field of the target
  78096. * to a desired value once triggered.
  78097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78098. */
  78099. export class SetStateAction extends Action {
  78100. /**
  78101. * The value to store in the state field.
  78102. */
  78103. value: string;
  78104. private _target;
  78105. /**
  78106. * Instantiate the action
  78107. * @param triggerOptions defines the trigger options
  78108. * @param target defines the object containing the state property
  78109. * @param value defines the value to store in the state field
  78110. * @param condition defines the trigger related conditions
  78111. */
  78112. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78113. /**
  78114. * Execute the action and store the value on the target state property.
  78115. */
  78116. execute(): void;
  78117. /**
  78118. * Serializes the actions and its related information.
  78119. * @param parent defines the object to serialize in
  78120. * @returns the serialized object
  78121. */
  78122. serialize(parent: any): any;
  78123. }
  78124. /**
  78125. * This defines an action responsible to set a property of the target
  78126. * to a desired value once triggered.
  78127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78128. */
  78129. export class SetValueAction extends Action {
  78130. /**
  78131. * The path of the property to set in the target.
  78132. */
  78133. propertyPath: string;
  78134. /**
  78135. * The value to set in the property
  78136. */
  78137. value: any;
  78138. private _target;
  78139. private _effectiveTarget;
  78140. private _property;
  78141. /**
  78142. * Instantiate the action
  78143. * @param triggerOptions defines the trigger options
  78144. * @param target defines the object containing the property
  78145. * @param propertyPath defines the path of the property to set in the target
  78146. * @param value defines the value to set in the property
  78147. * @param condition defines the trigger related conditions
  78148. */
  78149. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78150. /** @hidden */
  78151. _prepare(): void;
  78152. /**
  78153. * Execute the action and set the targetted property to the desired value.
  78154. */
  78155. execute(): void;
  78156. /**
  78157. * Serializes the actions and its related information.
  78158. * @param parent defines the object to serialize in
  78159. * @returns the serialized object
  78160. */
  78161. serialize(parent: any): any;
  78162. }
  78163. /**
  78164. * This defines an action responsible to increment the target value
  78165. * to a desired value once triggered.
  78166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78167. */
  78168. export class IncrementValueAction extends Action {
  78169. /**
  78170. * The path of the property to increment in the target.
  78171. */
  78172. propertyPath: string;
  78173. /**
  78174. * The value we should increment the property by.
  78175. */
  78176. value: any;
  78177. private _target;
  78178. private _effectiveTarget;
  78179. private _property;
  78180. /**
  78181. * Instantiate the action
  78182. * @param triggerOptions defines the trigger options
  78183. * @param target defines the object containing the property
  78184. * @param propertyPath defines the path of the property to increment in the target
  78185. * @param value defines the value value we should increment the property by
  78186. * @param condition defines the trigger related conditions
  78187. */
  78188. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78189. /** @hidden */
  78190. _prepare(): void;
  78191. /**
  78192. * Execute the action and increment the target of the value amount.
  78193. */
  78194. execute(): void;
  78195. /**
  78196. * Serializes the actions and its related information.
  78197. * @param parent defines the object to serialize in
  78198. * @returns the serialized object
  78199. */
  78200. serialize(parent: any): any;
  78201. }
  78202. /**
  78203. * This defines an action responsible to start an animation once triggered.
  78204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78205. */
  78206. export class PlayAnimationAction extends Action {
  78207. /**
  78208. * Where the animation should start (animation frame)
  78209. */
  78210. from: number;
  78211. /**
  78212. * Where the animation should stop (animation frame)
  78213. */
  78214. to: number;
  78215. /**
  78216. * Define if the animation should loop or stop after the first play.
  78217. */
  78218. loop?: boolean;
  78219. private _target;
  78220. /**
  78221. * Instantiate the action
  78222. * @param triggerOptions defines the trigger options
  78223. * @param target defines the target animation or animation name
  78224. * @param from defines from where the animation should start (animation frame)
  78225. * @param end defines where the animation should stop (animation frame)
  78226. * @param loop defines if the animation should loop or stop after the first play
  78227. * @param condition defines the trigger related conditions
  78228. */
  78229. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78230. /** @hidden */
  78231. _prepare(): void;
  78232. /**
  78233. * Execute the action and play the animation.
  78234. */
  78235. execute(): void;
  78236. /**
  78237. * Serializes the actions and its related information.
  78238. * @param parent defines the object to serialize in
  78239. * @returns the serialized object
  78240. */
  78241. serialize(parent: any): any;
  78242. }
  78243. /**
  78244. * This defines an action responsible to stop an animation once triggered.
  78245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78246. */
  78247. export class StopAnimationAction extends Action {
  78248. private _target;
  78249. /**
  78250. * Instantiate the action
  78251. * @param triggerOptions defines the trigger options
  78252. * @param target defines the target animation or animation name
  78253. * @param condition defines the trigger related conditions
  78254. */
  78255. constructor(triggerOptions: any, target: any, condition?: Condition);
  78256. /** @hidden */
  78257. _prepare(): void;
  78258. /**
  78259. * Execute the action and stop the animation.
  78260. */
  78261. execute(): void;
  78262. /**
  78263. * Serializes the actions and its related information.
  78264. * @param parent defines the object to serialize in
  78265. * @returns the serialized object
  78266. */
  78267. serialize(parent: any): any;
  78268. }
  78269. /**
  78270. * This defines an action responsible that does nothing once triggered.
  78271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78272. */
  78273. export class DoNothingAction extends Action {
  78274. /**
  78275. * Instantiate the action
  78276. * @param triggerOptions defines the trigger options
  78277. * @param condition defines the trigger related conditions
  78278. */
  78279. constructor(triggerOptions?: any, condition?: Condition);
  78280. /**
  78281. * Execute the action and do nothing.
  78282. */
  78283. execute(): void;
  78284. /**
  78285. * Serializes the actions and its related information.
  78286. * @param parent defines the object to serialize in
  78287. * @returns the serialized object
  78288. */
  78289. serialize(parent: any): any;
  78290. }
  78291. /**
  78292. * This defines an action responsible to trigger several actions once triggered.
  78293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78294. */
  78295. export class CombineAction extends Action {
  78296. /**
  78297. * The list of aggregated animations to run.
  78298. */
  78299. children: Action[];
  78300. /**
  78301. * Instantiate the action
  78302. * @param triggerOptions defines the trigger options
  78303. * @param children defines the list of aggregated animations to run
  78304. * @param condition defines the trigger related conditions
  78305. */
  78306. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78307. /** @hidden */
  78308. _prepare(): void;
  78309. /**
  78310. * Execute the action and executes all the aggregated actions.
  78311. */
  78312. execute(evt: ActionEvent): void;
  78313. /**
  78314. * Serializes the actions and its related information.
  78315. * @param parent defines the object to serialize in
  78316. * @returns the serialized object
  78317. */
  78318. serialize(parent: any): any;
  78319. }
  78320. /**
  78321. * This defines an action responsible to run code (external event) once triggered.
  78322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78323. */
  78324. export class ExecuteCodeAction extends Action {
  78325. /**
  78326. * The callback function to run.
  78327. */
  78328. func: (evt: ActionEvent) => void;
  78329. /**
  78330. * Instantiate the action
  78331. * @param triggerOptions defines the trigger options
  78332. * @param func defines the callback function to run
  78333. * @param condition defines the trigger related conditions
  78334. */
  78335. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78336. /**
  78337. * Execute the action and run the attached code.
  78338. */
  78339. execute(evt: ActionEvent): void;
  78340. }
  78341. /**
  78342. * This defines an action responsible to set the parent property of the target once triggered.
  78343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78344. */
  78345. export class SetParentAction extends Action {
  78346. private _parent;
  78347. private _target;
  78348. /**
  78349. * Instantiate the action
  78350. * @param triggerOptions defines the trigger options
  78351. * @param target defines the target containing the parent property
  78352. * @param parent defines from where the animation should start (animation frame)
  78353. * @param condition defines the trigger related conditions
  78354. */
  78355. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78356. /** @hidden */
  78357. _prepare(): void;
  78358. /**
  78359. * Execute the action and set the parent property.
  78360. */
  78361. execute(): void;
  78362. /**
  78363. * Serializes the actions and its related information.
  78364. * @param parent defines the object to serialize in
  78365. * @returns the serialized object
  78366. */
  78367. serialize(parent: any): any;
  78368. }
  78369. }
  78370. declare module BABYLON {
  78371. /**
  78372. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78373. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78375. */
  78376. export class ActionManager extends AbstractActionManager {
  78377. /**
  78378. * Nothing
  78379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78380. */
  78381. static readonly NothingTrigger: number;
  78382. /**
  78383. * On pick
  78384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78385. */
  78386. static readonly OnPickTrigger: number;
  78387. /**
  78388. * On left pick
  78389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78390. */
  78391. static readonly OnLeftPickTrigger: number;
  78392. /**
  78393. * On right pick
  78394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78395. */
  78396. static readonly OnRightPickTrigger: number;
  78397. /**
  78398. * On center pick
  78399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78400. */
  78401. static readonly OnCenterPickTrigger: number;
  78402. /**
  78403. * On pick down
  78404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78405. */
  78406. static readonly OnPickDownTrigger: number;
  78407. /**
  78408. * On double pick
  78409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78410. */
  78411. static readonly OnDoublePickTrigger: number;
  78412. /**
  78413. * On pick up
  78414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78415. */
  78416. static readonly OnPickUpTrigger: number;
  78417. /**
  78418. * On pick out.
  78419. * This trigger will only be raised if you also declared a OnPickDown
  78420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78421. */
  78422. static readonly OnPickOutTrigger: number;
  78423. /**
  78424. * On long press
  78425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78426. */
  78427. static readonly OnLongPressTrigger: number;
  78428. /**
  78429. * On pointer over
  78430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78431. */
  78432. static readonly OnPointerOverTrigger: number;
  78433. /**
  78434. * On pointer out
  78435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78436. */
  78437. static readonly OnPointerOutTrigger: number;
  78438. /**
  78439. * On every frame
  78440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78441. */
  78442. static readonly OnEveryFrameTrigger: number;
  78443. /**
  78444. * On intersection enter
  78445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78446. */
  78447. static readonly OnIntersectionEnterTrigger: number;
  78448. /**
  78449. * On intersection exit
  78450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78451. */
  78452. static readonly OnIntersectionExitTrigger: number;
  78453. /**
  78454. * On key down
  78455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78456. */
  78457. static readonly OnKeyDownTrigger: number;
  78458. /**
  78459. * On key up
  78460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78461. */
  78462. static readonly OnKeyUpTrigger: number;
  78463. private _scene;
  78464. /**
  78465. * Creates a new action manager
  78466. * @param scene defines the hosting scene
  78467. */
  78468. constructor(scene: Scene);
  78469. /**
  78470. * Releases all associated resources
  78471. */
  78472. dispose(): void;
  78473. /**
  78474. * Gets hosting scene
  78475. * @returns the hosting scene
  78476. */
  78477. getScene(): Scene;
  78478. /**
  78479. * Does this action manager handles actions of any of the given triggers
  78480. * @param triggers defines the triggers to be tested
  78481. * @return a boolean indicating whether one (or more) of the triggers is handled
  78482. */
  78483. hasSpecificTriggers(triggers: number[]): boolean;
  78484. /**
  78485. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78486. * speed.
  78487. * @param triggerA defines the trigger to be tested
  78488. * @param triggerB defines the trigger to be tested
  78489. * @return a boolean indicating whether one (or more) of the triggers is handled
  78490. */
  78491. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78492. /**
  78493. * Does this action manager handles actions of a given trigger
  78494. * @param trigger defines the trigger to be tested
  78495. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78496. * @return whether the trigger is handled
  78497. */
  78498. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78499. /**
  78500. * Does this action manager has pointer triggers
  78501. */
  78502. readonly hasPointerTriggers: boolean;
  78503. /**
  78504. * Does this action manager has pick triggers
  78505. */
  78506. readonly hasPickTriggers: boolean;
  78507. /**
  78508. * Registers an action to this action manager
  78509. * @param action defines the action to be registered
  78510. * @return the action amended (prepared) after registration
  78511. */
  78512. registerAction(action: IAction): Nullable<IAction>;
  78513. /**
  78514. * Unregisters an action to this action manager
  78515. * @param action defines the action to be unregistered
  78516. * @return a boolean indicating whether the action has been unregistered
  78517. */
  78518. unregisterAction(action: IAction): Boolean;
  78519. /**
  78520. * Process a specific trigger
  78521. * @param trigger defines the trigger to process
  78522. * @param evt defines the event details to be processed
  78523. */
  78524. processTrigger(trigger: number, evt?: IActionEvent): void;
  78525. /** @hidden */
  78526. _getEffectiveTarget(target: any, propertyPath: string): any;
  78527. /** @hidden */
  78528. _getProperty(propertyPath: string): string;
  78529. /**
  78530. * Serialize this manager to a JSON object
  78531. * @param name defines the property name to store this manager
  78532. * @returns a JSON representation of this manager
  78533. */
  78534. serialize(name: string): any;
  78535. /**
  78536. * Creates a new ActionManager from a JSON data
  78537. * @param parsedActions defines the JSON data to read from
  78538. * @param object defines the hosting mesh
  78539. * @param scene defines the hosting scene
  78540. */
  78541. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78542. /**
  78543. * Get a trigger name by index
  78544. * @param trigger defines the trigger index
  78545. * @returns a trigger name
  78546. */
  78547. static GetTriggerName(trigger: number): string;
  78548. }
  78549. }
  78550. declare module BABYLON {
  78551. /**
  78552. * Class representing a ray with position and direction
  78553. */
  78554. export class Ray {
  78555. /** origin point */
  78556. origin: Vector3;
  78557. /** direction */
  78558. direction: Vector3;
  78559. /** length of the ray */
  78560. length: number;
  78561. private static readonly TmpVector3;
  78562. private _tmpRay;
  78563. /**
  78564. * Creates a new ray
  78565. * @param origin origin point
  78566. * @param direction direction
  78567. * @param length length of the ray
  78568. */
  78569. constructor(
  78570. /** origin point */
  78571. origin: Vector3,
  78572. /** direction */
  78573. direction: Vector3,
  78574. /** length of the ray */
  78575. length?: number);
  78576. /**
  78577. * Checks if the ray intersects a box
  78578. * @param minimum bound of the box
  78579. * @param maximum bound of the box
  78580. * @param intersectionTreshold extra extend to be added to the box in all direction
  78581. * @returns if the box was hit
  78582. */
  78583. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78584. /**
  78585. * Checks if the ray intersects a box
  78586. * @param box the bounding box to check
  78587. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78588. * @returns if the box was hit
  78589. */
  78590. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78591. /**
  78592. * If the ray hits a sphere
  78593. * @param sphere the bounding sphere to check
  78594. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78595. * @returns true if it hits the sphere
  78596. */
  78597. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78598. /**
  78599. * If the ray hits a triange
  78600. * @param vertex0 triangle vertex
  78601. * @param vertex1 triangle vertex
  78602. * @param vertex2 triangle vertex
  78603. * @returns intersection information if hit
  78604. */
  78605. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78606. /**
  78607. * Checks if ray intersects a plane
  78608. * @param plane the plane to check
  78609. * @returns the distance away it was hit
  78610. */
  78611. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78612. /**
  78613. * Calculate the intercept of a ray on a given axis
  78614. * @param axis to check 'x' | 'y' | 'z'
  78615. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78616. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78617. */
  78618. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78619. /**
  78620. * Checks if ray intersects a mesh
  78621. * @param mesh the mesh to check
  78622. * @param fastCheck if only the bounding box should checked
  78623. * @returns picking info of the intersecton
  78624. */
  78625. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78626. /**
  78627. * Checks if ray intersects a mesh
  78628. * @param meshes the meshes to check
  78629. * @param fastCheck if only the bounding box should checked
  78630. * @param results array to store result in
  78631. * @returns Array of picking infos
  78632. */
  78633. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78634. private _comparePickingInfo;
  78635. private static smallnum;
  78636. private static rayl;
  78637. /**
  78638. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78639. * @param sega the first point of the segment to test the intersection against
  78640. * @param segb the second point of the segment to test the intersection against
  78641. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78642. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78643. */
  78644. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78645. /**
  78646. * Update the ray from viewport position
  78647. * @param x position
  78648. * @param y y position
  78649. * @param viewportWidth viewport width
  78650. * @param viewportHeight viewport height
  78651. * @param world world matrix
  78652. * @param view view matrix
  78653. * @param projection projection matrix
  78654. * @returns this ray updated
  78655. */
  78656. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78657. /**
  78658. * Creates a ray with origin and direction of 0,0,0
  78659. * @returns the new ray
  78660. */
  78661. static Zero(): Ray;
  78662. /**
  78663. * Creates a new ray from screen space and viewport
  78664. * @param x position
  78665. * @param y y position
  78666. * @param viewportWidth viewport width
  78667. * @param viewportHeight viewport height
  78668. * @param world world matrix
  78669. * @param view view matrix
  78670. * @param projection projection matrix
  78671. * @returns new ray
  78672. */
  78673. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78674. /**
  78675. * 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
  78676. * transformed to the given world matrix.
  78677. * @param origin The origin point
  78678. * @param end The end point
  78679. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78680. * @returns the new ray
  78681. */
  78682. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78683. /**
  78684. * Transforms a ray by a matrix
  78685. * @param ray ray to transform
  78686. * @param matrix matrix to apply
  78687. * @returns the resulting new ray
  78688. */
  78689. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78690. /**
  78691. * Transforms a ray by a matrix
  78692. * @param ray ray to transform
  78693. * @param matrix matrix to apply
  78694. * @param result ray to store result in
  78695. */
  78696. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78697. /**
  78698. * Unproject a ray from screen space to object space
  78699. * @param sourceX defines the screen space x coordinate to use
  78700. * @param sourceY defines the screen space y coordinate to use
  78701. * @param viewportWidth defines the current width of the viewport
  78702. * @param viewportHeight defines the current height of the viewport
  78703. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78704. * @param view defines the view matrix to use
  78705. * @param projection defines the projection matrix to use
  78706. */
  78707. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78708. }
  78709. /**
  78710. * Type used to define predicate used to select faces when a mesh intersection is detected
  78711. */
  78712. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78713. interface Scene {
  78714. /** @hidden */
  78715. _tempPickingRay: Nullable<Ray>;
  78716. /** @hidden */
  78717. _cachedRayForTransform: Ray;
  78718. /** @hidden */
  78719. _pickWithRayInverseMatrix: Matrix;
  78720. /** @hidden */
  78721. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78722. /** @hidden */
  78723. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78724. }
  78725. }
  78726. declare module BABYLON {
  78727. interface Scene {
  78728. /** @hidden */
  78729. _pointerOverSprite: Nullable<Sprite>;
  78730. /** @hidden */
  78731. _pickedDownSprite: Nullable<Sprite>;
  78732. /** @hidden */
  78733. _tempSpritePickingRay: Nullable<Ray>;
  78734. /**
  78735. * All of the sprite managers added to this scene
  78736. * @see http://doc.babylonjs.com/babylon101/sprites
  78737. */
  78738. spriteManagers: Array<ISpriteManager>;
  78739. /**
  78740. * An event triggered when sprites rendering is about to start
  78741. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78742. */
  78743. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78744. /**
  78745. * An event triggered when sprites rendering is done
  78746. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78747. */
  78748. onAfterSpritesRenderingObservable: Observable<Scene>;
  78749. /** @hidden */
  78750. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78751. /** Launch a ray to try to pick a sprite in the scene
  78752. * @param x position on screen
  78753. * @param y position on screen
  78754. * @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
  78755. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78756. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78757. * @returns a PickingInfo
  78758. */
  78759. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78760. /** Use the given ray to pick a sprite in the scene
  78761. * @param ray The ray (in world space) to use to pick meshes
  78762. * @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
  78763. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78764. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78765. * @returns a PickingInfo
  78766. */
  78767. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78768. /**
  78769. * Force the sprite under the pointer
  78770. * @param sprite defines the sprite to use
  78771. */
  78772. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78773. /**
  78774. * Gets the sprite under the pointer
  78775. * @returns a Sprite or null if no sprite is under the pointer
  78776. */
  78777. getPointerOverSprite(): Nullable<Sprite>;
  78778. }
  78779. /**
  78780. * Defines the sprite scene component responsible to manage sprites
  78781. * in a given scene.
  78782. */
  78783. export class SpriteSceneComponent implements ISceneComponent {
  78784. /**
  78785. * The component name helpfull to identify the component in the list of scene components.
  78786. */
  78787. readonly name: string;
  78788. /**
  78789. * The scene the component belongs to.
  78790. */
  78791. scene: Scene;
  78792. /** @hidden */
  78793. private _spritePredicate;
  78794. /**
  78795. * Creates a new instance of the component for the given scene
  78796. * @param scene Defines the scene to register the component in
  78797. */
  78798. constructor(scene: Scene);
  78799. /**
  78800. * Registers the component in a given scene
  78801. */
  78802. register(): void;
  78803. /**
  78804. * Rebuilds the elements related to this component in case of
  78805. * context lost for instance.
  78806. */
  78807. rebuild(): void;
  78808. /**
  78809. * Disposes the component and the associated ressources.
  78810. */
  78811. dispose(): void;
  78812. private _pickSpriteButKeepRay;
  78813. private _pointerMove;
  78814. private _pointerDown;
  78815. private _pointerUp;
  78816. }
  78817. }
  78818. declare module BABYLON {
  78819. /** @hidden */
  78820. export var fogFragmentDeclaration: {
  78821. name: string;
  78822. shader: string;
  78823. };
  78824. }
  78825. declare module BABYLON {
  78826. /** @hidden */
  78827. export var fogFragment: {
  78828. name: string;
  78829. shader: string;
  78830. };
  78831. }
  78832. declare module BABYLON {
  78833. /** @hidden */
  78834. export var spritesPixelShader: {
  78835. name: string;
  78836. shader: string;
  78837. };
  78838. }
  78839. declare module BABYLON {
  78840. /** @hidden */
  78841. export var fogVertexDeclaration: {
  78842. name: string;
  78843. shader: string;
  78844. };
  78845. }
  78846. declare module BABYLON {
  78847. /** @hidden */
  78848. export var spritesVertexShader: {
  78849. name: string;
  78850. shader: string;
  78851. };
  78852. }
  78853. declare module BABYLON {
  78854. /**
  78855. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78856. */
  78857. export interface ISpriteManager extends IDisposable {
  78858. /**
  78859. * Restricts the camera to viewing objects with the same layerMask.
  78860. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78861. */
  78862. layerMask: number;
  78863. /**
  78864. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78865. */
  78866. isPickable: boolean;
  78867. /**
  78868. * Specifies the rendering group id for this mesh (0 by default)
  78869. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78870. */
  78871. renderingGroupId: number;
  78872. /**
  78873. * Defines the list of sprites managed by the manager.
  78874. */
  78875. sprites: Array<Sprite>;
  78876. /**
  78877. * Tests the intersection of a sprite with a specific ray.
  78878. * @param ray The ray we are sending to test the collision
  78879. * @param camera The camera space we are sending rays in
  78880. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78881. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78882. * @returns picking info or null.
  78883. */
  78884. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78885. /**
  78886. * Renders the list of sprites on screen.
  78887. */
  78888. render(): void;
  78889. }
  78890. /**
  78891. * Class used to manage multiple sprites on the same spritesheet
  78892. * @see http://doc.babylonjs.com/babylon101/sprites
  78893. */
  78894. export class SpriteManager implements ISpriteManager {
  78895. /** defines the manager's name */
  78896. name: string;
  78897. /** Gets the list of sprites */
  78898. sprites: Sprite[];
  78899. /** Gets or sets the rendering group id (0 by default) */
  78900. renderingGroupId: number;
  78901. /** Gets or sets camera layer mask */
  78902. layerMask: number;
  78903. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78904. fogEnabled: boolean;
  78905. /** Gets or sets a boolean indicating if the sprites are pickable */
  78906. isPickable: boolean;
  78907. /** Defines the default width of a cell in the spritesheet */
  78908. cellWidth: number;
  78909. /** Defines the default height of a cell in the spritesheet */
  78910. cellHeight: number;
  78911. /**
  78912. * An event triggered when the manager is disposed.
  78913. */
  78914. onDisposeObservable: Observable<SpriteManager>;
  78915. private _onDisposeObserver;
  78916. /**
  78917. * Callback called when the manager is disposed
  78918. */
  78919. onDispose: () => void;
  78920. private _capacity;
  78921. private _spriteTexture;
  78922. private _epsilon;
  78923. private _scene;
  78924. private _vertexData;
  78925. private _buffer;
  78926. private _vertexBuffers;
  78927. private _indexBuffer;
  78928. private _effectBase;
  78929. private _effectFog;
  78930. /**
  78931. * Gets or sets the spritesheet texture
  78932. */
  78933. texture: Texture;
  78934. /**
  78935. * Creates a new sprite manager
  78936. * @param name defines the manager's name
  78937. * @param imgUrl defines the sprite sheet url
  78938. * @param capacity defines the maximum allowed number of sprites
  78939. * @param cellSize defines the size of a sprite cell
  78940. * @param scene defines the hosting scene
  78941. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78942. * @param samplingMode defines the smapling mode to use with spritesheet
  78943. */
  78944. constructor(
  78945. /** defines the manager's name */
  78946. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78947. private _appendSpriteVertex;
  78948. /**
  78949. * Intersects the sprites with a ray
  78950. * @param ray defines the ray to intersect with
  78951. * @param camera defines the current active camera
  78952. * @param predicate defines a predicate used to select candidate sprites
  78953. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78954. * @returns null if no hit or a PickingInfo
  78955. */
  78956. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78957. /**
  78958. * Render all child sprites
  78959. */
  78960. render(): void;
  78961. /**
  78962. * Release associated resources
  78963. */
  78964. dispose(): void;
  78965. }
  78966. }
  78967. declare module BABYLON {
  78968. /**
  78969. * Class used to represent a sprite
  78970. * @see http://doc.babylonjs.com/babylon101/sprites
  78971. */
  78972. export class Sprite {
  78973. /** defines the name */
  78974. name: string;
  78975. /** Gets or sets the current world position */
  78976. position: Vector3;
  78977. /** Gets or sets the main color */
  78978. color: Color4;
  78979. /** Gets or sets the width */
  78980. width: number;
  78981. /** Gets or sets the height */
  78982. height: number;
  78983. /** Gets or sets rotation angle */
  78984. angle: number;
  78985. /** Gets or sets the cell index in the sprite sheet */
  78986. cellIndex: number;
  78987. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78988. invertU: number;
  78989. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78990. invertV: number;
  78991. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78992. disposeWhenFinishedAnimating: boolean;
  78993. /** Gets the list of attached animations */
  78994. animations: Animation[];
  78995. /** Gets or sets a boolean indicating if the sprite can be picked */
  78996. isPickable: boolean;
  78997. /**
  78998. * Gets or sets the associated action manager
  78999. */
  79000. actionManager: Nullable<ActionManager>;
  79001. private _animationStarted;
  79002. private _loopAnimation;
  79003. private _fromIndex;
  79004. private _toIndex;
  79005. private _delay;
  79006. private _direction;
  79007. private _manager;
  79008. private _time;
  79009. private _onAnimationEnd;
  79010. /**
  79011. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79012. */
  79013. isVisible: boolean;
  79014. /**
  79015. * Gets or sets the sprite size
  79016. */
  79017. size: number;
  79018. /**
  79019. * Creates a new Sprite
  79020. * @param name defines the name
  79021. * @param manager defines the manager
  79022. */
  79023. constructor(
  79024. /** defines the name */
  79025. name: string, manager: ISpriteManager);
  79026. /**
  79027. * Starts an animation
  79028. * @param from defines the initial key
  79029. * @param to defines the end key
  79030. * @param loop defines if the animation must loop
  79031. * @param delay defines the start delay (in ms)
  79032. * @param onAnimationEnd defines a callback to call when animation ends
  79033. */
  79034. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79035. /** Stops current animation (if any) */
  79036. stopAnimation(): void;
  79037. /** @hidden */
  79038. _animate(deltaTime: number): void;
  79039. /** Release associated resources */
  79040. dispose(): void;
  79041. }
  79042. }
  79043. declare module BABYLON {
  79044. /**
  79045. * Information about the result of picking within a scene
  79046. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79047. */
  79048. export class PickingInfo {
  79049. /** @hidden */
  79050. _pickingUnavailable: boolean;
  79051. /**
  79052. * If the pick collided with an object
  79053. */
  79054. hit: boolean;
  79055. /**
  79056. * Distance away where the pick collided
  79057. */
  79058. distance: number;
  79059. /**
  79060. * The location of pick collision
  79061. */
  79062. pickedPoint: Nullable<Vector3>;
  79063. /**
  79064. * The mesh corresponding the the pick collision
  79065. */
  79066. pickedMesh: Nullable<AbstractMesh>;
  79067. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79068. bu: number;
  79069. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79070. bv: number;
  79071. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79072. faceId: number;
  79073. /** Id of the the submesh that was picked */
  79074. subMeshId: number;
  79075. /** If a sprite was picked, this will be the sprite the pick collided with */
  79076. pickedSprite: Nullable<Sprite>;
  79077. /**
  79078. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79079. */
  79080. originMesh: Nullable<AbstractMesh>;
  79081. /**
  79082. * The ray that was used to perform the picking.
  79083. */
  79084. ray: Nullable<Ray>;
  79085. /**
  79086. * Gets the normal correspodning to the face the pick collided with
  79087. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79088. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79089. * @returns The normal correspodning to the face the pick collided with
  79090. */
  79091. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79092. /**
  79093. * Gets the texture coordinates of where the pick occured
  79094. * @returns the vector containing the coordnates of the texture
  79095. */
  79096. getTextureCoordinates(): Nullable<Vector2>;
  79097. }
  79098. }
  79099. declare module BABYLON {
  79100. /**
  79101. * Gather the list of pointer event types as constants.
  79102. */
  79103. export class PointerEventTypes {
  79104. /**
  79105. * 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.
  79106. */
  79107. static readonly POINTERDOWN: number;
  79108. /**
  79109. * The pointerup event is fired when a pointer is no longer active.
  79110. */
  79111. static readonly POINTERUP: number;
  79112. /**
  79113. * The pointermove event is fired when a pointer changes coordinates.
  79114. */
  79115. static readonly POINTERMOVE: number;
  79116. /**
  79117. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79118. */
  79119. static readonly POINTERWHEEL: number;
  79120. /**
  79121. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79122. */
  79123. static readonly POINTERPICK: number;
  79124. /**
  79125. * The pointertap event is fired when a the object has been touched and released without drag.
  79126. */
  79127. static readonly POINTERTAP: number;
  79128. /**
  79129. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79130. */
  79131. static readonly POINTERDOUBLETAP: number;
  79132. }
  79133. /**
  79134. * Base class of pointer info types.
  79135. */
  79136. export class PointerInfoBase {
  79137. /**
  79138. * Defines the type of event (PointerEventTypes)
  79139. */
  79140. type: number;
  79141. /**
  79142. * Defines the related dom event
  79143. */
  79144. event: PointerEvent | MouseWheelEvent;
  79145. /**
  79146. * Instantiates the base class of pointers info.
  79147. * @param type Defines the type of event (PointerEventTypes)
  79148. * @param event Defines the related dom event
  79149. */
  79150. constructor(
  79151. /**
  79152. * Defines the type of event (PointerEventTypes)
  79153. */
  79154. type: number,
  79155. /**
  79156. * Defines the related dom event
  79157. */
  79158. event: PointerEvent | MouseWheelEvent);
  79159. }
  79160. /**
  79161. * This class is used to store pointer related info for the onPrePointerObservable event.
  79162. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79163. */
  79164. export class PointerInfoPre extends PointerInfoBase {
  79165. /**
  79166. * Ray from a pointer if availible (eg. 6dof controller)
  79167. */
  79168. ray: Nullable<Ray>;
  79169. /**
  79170. * Defines the local position of the pointer on the canvas.
  79171. */
  79172. localPosition: Vector2;
  79173. /**
  79174. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79175. */
  79176. skipOnPointerObservable: boolean;
  79177. /**
  79178. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79179. * @param type Defines the type of event (PointerEventTypes)
  79180. * @param event Defines the related dom event
  79181. * @param localX Defines the local x coordinates of the pointer when the event occured
  79182. * @param localY Defines the local y coordinates of the pointer when the event occured
  79183. */
  79184. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79185. }
  79186. /**
  79187. * This type contains all the data related to a pointer event in Babylon.js.
  79188. * 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.
  79189. */
  79190. export class PointerInfo extends PointerInfoBase {
  79191. /**
  79192. * Defines the picking info associated to the info (if any)\
  79193. */
  79194. pickInfo: Nullable<PickingInfo>;
  79195. /**
  79196. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79197. * @param type Defines the type of event (PointerEventTypes)
  79198. * @param event Defines the related dom event
  79199. * @param pickInfo Defines the picking info associated to the info (if any)\
  79200. */
  79201. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79202. /**
  79203. * Defines the picking info associated to the info (if any)\
  79204. */
  79205. pickInfo: Nullable<PickingInfo>);
  79206. }
  79207. /**
  79208. * Data relating to a touch event on the screen.
  79209. */
  79210. export interface PointerTouch {
  79211. /**
  79212. * X coordinate of touch.
  79213. */
  79214. x: number;
  79215. /**
  79216. * Y coordinate of touch.
  79217. */
  79218. y: number;
  79219. /**
  79220. * Id of touch. Unique for each finger.
  79221. */
  79222. pointerId: number;
  79223. /**
  79224. * Event type passed from DOM.
  79225. */
  79226. type: any;
  79227. }
  79228. }
  79229. declare module BABYLON {
  79230. /**
  79231. * Manage the mouse inputs to control the movement of a free camera.
  79232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79233. */
  79234. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79235. /**
  79236. * Define if touch is enabled in the mouse input
  79237. */
  79238. touchEnabled: boolean;
  79239. /**
  79240. * Defines the camera the input is attached to.
  79241. */
  79242. camera: FreeCamera;
  79243. /**
  79244. * Defines the buttons associated with the input to handle camera move.
  79245. */
  79246. buttons: number[];
  79247. /**
  79248. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79249. */
  79250. angularSensibility: number;
  79251. private _pointerInput;
  79252. private _onMouseMove;
  79253. private _observer;
  79254. private previousPosition;
  79255. /**
  79256. * Observable for when a pointer move event occurs containing the move offset
  79257. */
  79258. onPointerMovedObservable: Observable<{
  79259. offsetX: number;
  79260. offsetY: number;
  79261. }>;
  79262. /**
  79263. * @hidden
  79264. * If the camera should be rotated automatically based on pointer movement
  79265. */
  79266. _allowCameraRotation: boolean;
  79267. /**
  79268. * Manage the mouse inputs to control the movement of a free camera.
  79269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79270. * @param touchEnabled Defines if touch is enabled or not
  79271. */
  79272. constructor(
  79273. /**
  79274. * Define if touch is enabled in the mouse input
  79275. */
  79276. touchEnabled?: boolean);
  79277. /**
  79278. * Attach the input controls to a specific dom element to get the input from.
  79279. * @param element Defines the element the controls should be listened from
  79280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79281. */
  79282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79283. /**
  79284. * Called on JS contextmenu event.
  79285. * Override this method to provide functionality.
  79286. */
  79287. protected onContextMenu(evt: PointerEvent): void;
  79288. /**
  79289. * Detach the current controls from the specified dom element.
  79290. * @param element Defines the element to stop listening the inputs from
  79291. */
  79292. detachControl(element: Nullable<HTMLElement>): void;
  79293. /**
  79294. * Gets the class name of the current intput.
  79295. * @returns the class name
  79296. */
  79297. getClassName(): string;
  79298. /**
  79299. * Get the friendly name associated with the input class.
  79300. * @returns the input friendly name
  79301. */
  79302. getSimpleName(): string;
  79303. }
  79304. }
  79305. declare module BABYLON {
  79306. /**
  79307. * Manage the touch inputs to control the movement of a free camera.
  79308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79309. */
  79310. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79311. /**
  79312. * Defines the camera the input is attached to.
  79313. */
  79314. camera: FreeCamera;
  79315. /**
  79316. * Defines the touch sensibility for rotation.
  79317. * The higher the faster.
  79318. */
  79319. touchAngularSensibility: number;
  79320. /**
  79321. * Defines the touch sensibility for move.
  79322. * The higher the faster.
  79323. */
  79324. touchMoveSensibility: number;
  79325. private _offsetX;
  79326. private _offsetY;
  79327. private _pointerPressed;
  79328. private _pointerInput;
  79329. private _observer;
  79330. private _onLostFocus;
  79331. /**
  79332. * Attach the input controls to a specific dom element to get the input from.
  79333. * @param element Defines the element the controls should be listened from
  79334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79335. */
  79336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79337. /**
  79338. * Detach the current controls from the specified dom element.
  79339. * @param element Defines the element to stop listening the inputs from
  79340. */
  79341. detachControl(element: Nullable<HTMLElement>): void;
  79342. /**
  79343. * Update the current camera state depending on the inputs that have been used this frame.
  79344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79345. */
  79346. checkInputs(): void;
  79347. /**
  79348. * Gets the class name of the current intput.
  79349. * @returns the class name
  79350. */
  79351. getClassName(): string;
  79352. /**
  79353. * Get the friendly name associated with the input class.
  79354. * @returns the input friendly name
  79355. */
  79356. getSimpleName(): string;
  79357. }
  79358. }
  79359. declare module BABYLON {
  79360. /**
  79361. * Default Inputs manager for the FreeCamera.
  79362. * It groups all the default supported inputs for ease of use.
  79363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79364. */
  79365. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79366. /**
  79367. * @hidden
  79368. */
  79369. _mouseInput: Nullable<FreeCameraMouseInput>;
  79370. /**
  79371. * Instantiates a new FreeCameraInputsManager.
  79372. * @param camera Defines the camera the inputs belong to
  79373. */
  79374. constructor(camera: FreeCamera);
  79375. /**
  79376. * Add keyboard input support to the input manager.
  79377. * @returns the current input manager
  79378. */
  79379. addKeyboard(): FreeCameraInputsManager;
  79380. /**
  79381. * Add mouse input support to the input manager.
  79382. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79383. * @returns the current input manager
  79384. */
  79385. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79386. /**
  79387. * Removes the mouse input support from the manager
  79388. * @returns the current input manager
  79389. */
  79390. removeMouse(): FreeCameraInputsManager;
  79391. /**
  79392. * Add touch input support to the input manager.
  79393. * @returns the current input manager
  79394. */
  79395. addTouch(): FreeCameraInputsManager;
  79396. /**
  79397. * Remove all attached input methods from a camera
  79398. */
  79399. clear(): void;
  79400. }
  79401. }
  79402. declare module BABYLON {
  79403. /**
  79404. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79405. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79407. */
  79408. export class FreeCamera extends TargetCamera {
  79409. /**
  79410. * Define the collision ellipsoid of the camera.
  79411. * This is helpful to simulate a camera body like the player body around the camera
  79412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79413. */
  79414. ellipsoid: Vector3;
  79415. /**
  79416. * Define an offset for the position of the ellipsoid around the camera.
  79417. * This can be helpful to determine the center of the body near the gravity center of the body
  79418. * instead of its head.
  79419. */
  79420. ellipsoidOffset: Vector3;
  79421. /**
  79422. * Enable or disable collisions of the camera with the rest of the scene objects.
  79423. */
  79424. checkCollisions: boolean;
  79425. /**
  79426. * Enable or disable gravity on the camera.
  79427. */
  79428. applyGravity: boolean;
  79429. /**
  79430. * Define the input manager associated to the camera.
  79431. */
  79432. inputs: FreeCameraInputsManager;
  79433. /**
  79434. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79435. * Higher values reduce sensitivity.
  79436. */
  79437. /**
  79438. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79439. * Higher values reduce sensitivity.
  79440. */
  79441. angularSensibility: number;
  79442. /**
  79443. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79444. */
  79445. keysUp: number[];
  79446. /**
  79447. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79448. */
  79449. keysDown: number[];
  79450. /**
  79451. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79452. */
  79453. keysLeft: number[];
  79454. /**
  79455. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79456. */
  79457. keysRight: number[];
  79458. /**
  79459. * Event raised when the camera collide with a mesh in the scene.
  79460. */
  79461. onCollide: (collidedMesh: AbstractMesh) => void;
  79462. private _collider;
  79463. private _needMoveForGravity;
  79464. private _oldPosition;
  79465. private _diffPosition;
  79466. private _newPosition;
  79467. /** @hidden */
  79468. _localDirection: Vector3;
  79469. /** @hidden */
  79470. _transformedDirection: Vector3;
  79471. /**
  79472. * Instantiates a Free Camera.
  79473. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79474. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79475. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79476. * @param name Define the name of the camera in the scene
  79477. * @param position Define the start position of the camera in the scene
  79478. * @param scene Define the scene the camera belongs to
  79479. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79480. */
  79481. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79482. /**
  79483. * Attached controls to the current camera.
  79484. * @param element Defines the element the controls should be listened from
  79485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79486. */
  79487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79488. /**
  79489. * Detach the current controls from the camera.
  79490. * The camera will stop reacting to inputs.
  79491. * @param element Defines the element to stop listening the inputs from
  79492. */
  79493. detachControl(element: HTMLElement): void;
  79494. private _collisionMask;
  79495. /**
  79496. * Define a collision mask to limit the list of object the camera can collide with
  79497. */
  79498. collisionMask: number;
  79499. /** @hidden */
  79500. _collideWithWorld(displacement: Vector3): void;
  79501. private _onCollisionPositionChange;
  79502. /** @hidden */
  79503. _checkInputs(): void;
  79504. /** @hidden */
  79505. _decideIfNeedsToMove(): boolean;
  79506. /** @hidden */
  79507. _updatePosition(): void;
  79508. /**
  79509. * Destroy the camera and release the current resources hold by it.
  79510. */
  79511. dispose(): void;
  79512. /**
  79513. * Gets the current object class name.
  79514. * @return the class name
  79515. */
  79516. getClassName(): string;
  79517. }
  79518. }
  79519. declare module BABYLON {
  79520. /**
  79521. * Represents a gamepad control stick position
  79522. */
  79523. export class StickValues {
  79524. /**
  79525. * The x component of the control stick
  79526. */
  79527. x: number;
  79528. /**
  79529. * The y component of the control stick
  79530. */
  79531. y: number;
  79532. /**
  79533. * Initializes the gamepad x and y control stick values
  79534. * @param x The x component of the gamepad control stick value
  79535. * @param y The y component of the gamepad control stick value
  79536. */
  79537. constructor(
  79538. /**
  79539. * The x component of the control stick
  79540. */
  79541. x: number,
  79542. /**
  79543. * The y component of the control stick
  79544. */
  79545. y: number);
  79546. }
  79547. /**
  79548. * An interface which manages callbacks for gamepad button changes
  79549. */
  79550. export interface GamepadButtonChanges {
  79551. /**
  79552. * Called when a gamepad has been changed
  79553. */
  79554. changed: boolean;
  79555. /**
  79556. * Called when a gamepad press event has been triggered
  79557. */
  79558. pressChanged: boolean;
  79559. /**
  79560. * Called when a touch event has been triggered
  79561. */
  79562. touchChanged: boolean;
  79563. /**
  79564. * Called when a value has changed
  79565. */
  79566. valueChanged: boolean;
  79567. }
  79568. /**
  79569. * Represents a gamepad
  79570. */
  79571. export class Gamepad {
  79572. /**
  79573. * The id of the gamepad
  79574. */
  79575. id: string;
  79576. /**
  79577. * The index of the gamepad
  79578. */
  79579. index: number;
  79580. /**
  79581. * The browser gamepad
  79582. */
  79583. browserGamepad: any;
  79584. /**
  79585. * Specifies what type of gamepad this represents
  79586. */
  79587. type: number;
  79588. private _leftStick;
  79589. private _rightStick;
  79590. /** @hidden */
  79591. _isConnected: boolean;
  79592. private _leftStickAxisX;
  79593. private _leftStickAxisY;
  79594. private _rightStickAxisX;
  79595. private _rightStickAxisY;
  79596. /**
  79597. * Triggered when the left control stick has been changed
  79598. */
  79599. private _onleftstickchanged;
  79600. /**
  79601. * Triggered when the right control stick has been changed
  79602. */
  79603. private _onrightstickchanged;
  79604. /**
  79605. * Represents a gamepad controller
  79606. */
  79607. static GAMEPAD: number;
  79608. /**
  79609. * Represents a generic controller
  79610. */
  79611. static GENERIC: number;
  79612. /**
  79613. * Represents an XBox controller
  79614. */
  79615. static XBOX: number;
  79616. /**
  79617. * Represents a pose-enabled controller
  79618. */
  79619. static POSE_ENABLED: number;
  79620. /**
  79621. * Specifies whether the left control stick should be Y-inverted
  79622. */
  79623. protected _invertLeftStickY: boolean;
  79624. /**
  79625. * Specifies if the gamepad has been connected
  79626. */
  79627. readonly isConnected: boolean;
  79628. /**
  79629. * Initializes the gamepad
  79630. * @param id The id of the gamepad
  79631. * @param index The index of the gamepad
  79632. * @param browserGamepad The browser gamepad
  79633. * @param leftStickX The x component of the left joystick
  79634. * @param leftStickY The y component of the left joystick
  79635. * @param rightStickX The x component of the right joystick
  79636. * @param rightStickY The y component of the right joystick
  79637. */
  79638. constructor(
  79639. /**
  79640. * The id of the gamepad
  79641. */
  79642. id: string,
  79643. /**
  79644. * The index of the gamepad
  79645. */
  79646. index: number,
  79647. /**
  79648. * The browser gamepad
  79649. */
  79650. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79651. /**
  79652. * Callback triggered when the left joystick has changed
  79653. * @param callback
  79654. */
  79655. onleftstickchanged(callback: (values: StickValues) => void): void;
  79656. /**
  79657. * Callback triggered when the right joystick has changed
  79658. * @param callback
  79659. */
  79660. onrightstickchanged(callback: (values: StickValues) => void): void;
  79661. /**
  79662. * Gets the left joystick
  79663. */
  79664. /**
  79665. * Sets the left joystick values
  79666. */
  79667. leftStick: StickValues;
  79668. /**
  79669. * Gets the right joystick
  79670. */
  79671. /**
  79672. * Sets the right joystick value
  79673. */
  79674. rightStick: StickValues;
  79675. /**
  79676. * Updates the gamepad joystick positions
  79677. */
  79678. update(): void;
  79679. /**
  79680. * Disposes the gamepad
  79681. */
  79682. dispose(): void;
  79683. }
  79684. /**
  79685. * Represents a generic gamepad
  79686. */
  79687. export class GenericPad extends Gamepad {
  79688. private _buttons;
  79689. private _onbuttondown;
  79690. private _onbuttonup;
  79691. /**
  79692. * Observable triggered when a button has been pressed
  79693. */
  79694. onButtonDownObservable: Observable<number>;
  79695. /**
  79696. * Observable triggered when a button has been released
  79697. */
  79698. onButtonUpObservable: Observable<number>;
  79699. /**
  79700. * Callback triggered when a button has been pressed
  79701. * @param callback Called when a button has been pressed
  79702. */
  79703. onbuttondown(callback: (buttonPressed: number) => void): void;
  79704. /**
  79705. * Callback triggered when a button has been released
  79706. * @param callback Called when a button has been released
  79707. */
  79708. onbuttonup(callback: (buttonReleased: number) => void): void;
  79709. /**
  79710. * Initializes the generic gamepad
  79711. * @param id The id of the generic gamepad
  79712. * @param index The index of the generic gamepad
  79713. * @param browserGamepad The browser gamepad
  79714. */
  79715. constructor(id: string, index: number, browserGamepad: any);
  79716. private _setButtonValue;
  79717. /**
  79718. * Updates the generic gamepad
  79719. */
  79720. update(): void;
  79721. /**
  79722. * Disposes the generic gamepad
  79723. */
  79724. dispose(): void;
  79725. }
  79726. }
  79727. declare module BABYLON {
  79728. /**
  79729. * Defines the types of pose enabled controllers that are supported
  79730. */
  79731. export enum PoseEnabledControllerType {
  79732. /**
  79733. * HTC Vive
  79734. */
  79735. VIVE = 0,
  79736. /**
  79737. * Oculus Rift
  79738. */
  79739. OCULUS = 1,
  79740. /**
  79741. * Windows mixed reality
  79742. */
  79743. WINDOWS = 2,
  79744. /**
  79745. * Samsung gear VR
  79746. */
  79747. GEAR_VR = 3,
  79748. /**
  79749. * Google Daydream
  79750. */
  79751. DAYDREAM = 4,
  79752. /**
  79753. * Generic
  79754. */
  79755. GENERIC = 5
  79756. }
  79757. /**
  79758. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79759. */
  79760. export interface MutableGamepadButton {
  79761. /**
  79762. * Value of the button/trigger
  79763. */
  79764. value: number;
  79765. /**
  79766. * If the button/trigger is currently touched
  79767. */
  79768. touched: boolean;
  79769. /**
  79770. * If the button/trigger is currently pressed
  79771. */
  79772. pressed: boolean;
  79773. }
  79774. /**
  79775. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79776. * @hidden
  79777. */
  79778. export interface ExtendedGamepadButton extends GamepadButton {
  79779. /**
  79780. * If the button/trigger is currently pressed
  79781. */
  79782. readonly pressed: boolean;
  79783. /**
  79784. * If the button/trigger is currently touched
  79785. */
  79786. readonly touched: boolean;
  79787. /**
  79788. * Value of the button/trigger
  79789. */
  79790. readonly value: number;
  79791. }
  79792. /** @hidden */
  79793. export interface _GamePadFactory {
  79794. /**
  79795. * Returns wether or not the current gamepad can be created for this type of controller.
  79796. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79797. * @returns true if it can be created, otherwise false
  79798. */
  79799. canCreate(gamepadInfo: any): boolean;
  79800. /**
  79801. * Creates a new instance of the Gamepad.
  79802. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79803. * @returns the new gamepad instance
  79804. */
  79805. create(gamepadInfo: any): Gamepad;
  79806. }
  79807. /**
  79808. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79809. */
  79810. export class PoseEnabledControllerHelper {
  79811. /** @hidden */
  79812. static _ControllerFactories: _GamePadFactory[];
  79813. /** @hidden */
  79814. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79815. /**
  79816. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79817. * @param vrGamepad the gamepad to initialized
  79818. * @returns a vr controller of the type the gamepad identified as
  79819. */
  79820. static InitiateController(vrGamepad: any): Gamepad;
  79821. }
  79822. /**
  79823. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79824. */
  79825. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79826. private _deviceRoomPosition;
  79827. private _deviceRoomRotationQuaternion;
  79828. /**
  79829. * The device position in babylon space
  79830. */
  79831. devicePosition: Vector3;
  79832. /**
  79833. * The device rotation in babylon space
  79834. */
  79835. deviceRotationQuaternion: Quaternion;
  79836. /**
  79837. * The scale factor of the device in babylon space
  79838. */
  79839. deviceScaleFactor: number;
  79840. /**
  79841. * (Likely devicePosition should be used instead) The device position in its room space
  79842. */
  79843. position: Vector3;
  79844. /**
  79845. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79846. */
  79847. rotationQuaternion: Quaternion;
  79848. /**
  79849. * The type of controller (Eg. Windows mixed reality)
  79850. */
  79851. controllerType: PoseEnabledControllerType;
  79852. protected _calculatedPosition: Vector3;
  79853. private _calculatedRotation;
  79854. /**
  79855. * The raw pose from the device
  79856. */
  79857. rawPose: DevicePose;
  79858. private _trackPosition;
  79859. private _maxRotationDistFromHeadset;
  79860. private _draggedRoomRotation;
  79861. /**
  79862. * @hidden
  79863. */
  79864. _disableTrackPosition(fixedPosition: Vector3): void;
  79865. /**
  79866. * Internal, the mesh attached to the controller
  79867. * @hidden
  79868. */
  79869. _mesh: Nullable<AbstractMesh>;
  79870. private _poseControlledCamera;
  79871. private _leftHandSystemQuaternion;
  79872. /**
  79873. * Internal, matrix used to convert room space to babylon space
  79874. * @hidden
  79875. */
  79876. _deviceToWorld: Matrix;
  79877. /**
  79878. * Node to be used when casting a ray from the controller
  79879. * @hidden
  79880. */
  79881. _pointingPoseNode: Nullable<TransformNode>;
  79882. /**
  79883. * Name of the child mesh that can be used to cast a ray from the controller
  79884. */
  79885. static readonly POINTING_POSE: string;
  79886. /**
  79887. * Creates a new PoseEnabledController from a gamepad
  79888. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79889. */
  79890. constructor(browserGamepad: any);
  79891. private _workingMatrix;
  79892. /**
  79893. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79894. */
  79895. update(): void;
  79896. /**
  79897. * Updates only the pose device and mesh without doing any button event checking
  79898. */
  79899. protected _updatePoseAndMesh(): void;
  79900. /**
  79901. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79902. * @param poseData raw pose fromthe device
  79903. */
  79904. updateFromDevice(poseData: DevicePose): void;
  79905. /**
  79906. * @hidden
  79907. */
  79908. _meshAttachedObservable: Observable<AbstractMesh>;
  79909. /**
  79910. * Attaches a mesh to the controller
  79911. * @param mesh the mesh to be attached
  79912. */
  79913. attachToMesh(mesh: AbstractMesh): void;
  79914. /**
  79915. * Attaches the controllers mesh to a camera
  79916. * @param camera the camera the mesh should be attached to
  79917. */
  79918. attachToPoseControlledCamera(camera: TargetCamera): void;
  79919. /**
  79920. * Disposes of the controller
  79921. */
  79922. dispose(): void;
  79923. /**
  79924. * The mesh that is attached to the controller
  79925. */
  79926. readonly mesh: Nullable<AbstractMesh>;
  79927. /**
  79928. * Gets the ray of the controller in the direction the controller is pointing
  79929. * @param length the length the resulting ray should be
  79930. * @returns a ray in the direction the controller is pointing
  79931. */
  79932. getForwardRay(length?: number): Ray;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /**
  79937. * Defines the WebVRController object that represents controllers tracked in 3D space
  79938. */
  79939. export abstract class WebVRController extends PoseEnabledController {
  79940. /**
  79941. * Internal, the default controller model for the controller
  79942. */
  79943. protected _defaultModel: AbstractMesh;
  79944. /**
  79945. * Fired when the trigger state has changed
  79946. */
  79947. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79948. /**
  79949. * Fired when the main button state has changed
  79950. */
  79951. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79952. /**
  79953. * Fired when the secondary button state has changed
  79954. */
  79955. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79956. /**
  79957. * Fired when the pad state has changed
  79958. */
  79959. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79960. /**
  79961. * Fired when controllers stick values have changed
  79962. */
  79963. onPadValuesChangedObservable: Observable<StickValues>;
  79964. /**
  79965. * Array of button availible on the controller
  79966. */
  79967. protected _buttons: Array<MutableGamepadButton>;
  79968. private _onButtonStateChange;
  79969. /**
  79970. * Fired when a controller button's state has changed
  79971. * @param callback the callback containing the button that was modified
  79972. */
  79973. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79974. /**
  79975. * X and Y axis corresponding to the controllers joystick
  79976. */
  79977. pad: StickValues;
  79978. /**
  79979. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79980. */
  79981. hand: string;
  79982. /**
  79983. * The default controller model for the controller
  79984. */
  79985. readonly defaultModel: AbstractMesh;
  79986. /**
  79987. * Creates a new WebVRController from a gamepad
  79988. * @param vrGamepad the gamepad that the WebVRController should be created from
  79989. */
  79990. constructor(vrGamepad: any);
  79991. /**
  79992. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79993. */
  79994. update(): void;
  79995. /**
  79996. * Function to be called when a button is modified
  79997. */
  79998. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79999. /**
  80000. * Loads a mesh and attaches it to the controller
  80001. * @param scene the scene the mesh should be added to
  80002. * @param meshLoaded callback for when the mesh has been loaded
  80003. */
  80004. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80005. private _setButtonValue;
  80006. private _changes;
  80007. private _checkChanges;
  80008. /**
  80009. * Disposes of th webVRCOntroller
  80010. */
  80011. dispose(): void;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /**
  80016. * The HemisphericLight simulates the ambient environment light,
  80017. * so the passed direction is the light reflection direction, not the incoming direction.
  80018. */
  80019. export class HemisphericLight extends Light {
  80020. /**
  80021. * The groundColor is the light in the opposite direction to the one specified during creation.
  80022. * 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.
  80023. */
  80024. groundColor: Color3;
  80025. /**
  80026. * The light reflection direction, not the incoming direction.
  80027. */
  80028. direction: Vector3;
  80029. /**
  80030. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80031. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80032. * The HemisphericLight can't cast shadows.
  80033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80034. * @param name The friendly name of the light
  80035. * @param direction The direction of the light reflection
  80036. * @param scene The scene the light belongs to
  80037. */
  80038. constructor(name: string, direction: Vector3, scene: Scene);
  80039. protected _buildUniformLayout(): void;
  80040. /**
  80041. * Returns the string "HemisphericLight".
  80042. * @return The class name
  80043. */
  80044. getClassName(): string;
  80045. /**
  80046. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80047. * Returns the updated direction.
  80048. * @param target The target the direction should point to
  80049. * @return The computed direction
  80050. */
  80051. setDirectionToTarget(target: Vector3): Vector3;
  80052. /**
  80053. * Returns the shadow generator associated to the light.
  80054. * @returns Always null for hemispheric lights because it does not support shadows.
  80055. */
  80056. getShadowGenerator(): Nullable<IShadowGenerator>;
  80057. /**
  80058. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80059. * @param effect The effect to update
  80060. * @param lightIndex The index of the light in the effect to update
  80061. * @returns The hemispheric light
  80062. */
  80063. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80064. /**
  80065. * Computes the world matrix of the node
  80066. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80067. * @param useWasUpdatedFlag defines a reserved property
  80068. * @returns the world matrix
  80069. */
  80070. computeWorldMatrix(): Matrix;
  80071. /**
  80072. * Returns the integer 3.
  80073. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80074. */
  80075. getTypeID(): number;
  80076. /**
  80077. * Prepares the list of defines specific to the light type.
  80078. * @param defines the list of defines
  80079. * @param lightIndex defines the index of the light for the effect
  80080. */
  80081. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80082. }
  80083. }
  80084. declare module BABYLON {
  80085. /** @hidden */
  80086. export var vrMultiviewToSingleviewPixelShader: {
  80087. name: string;
  80088. shader: string;
  80089. };
  80090. }
  80091. declare module BABYLON {
  80092. /**
  80093. * Renders to multiple views with a single draw call
  80094. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80095. */
  80096. export class MultiviewRenderTarget extends RenderTargetTexture {
  80097. /**
  80098. * Creates a multiview render target
  80099. * @param scene scene used with the render target
  80100. * @param size the size of the render target (used for each view)
  80101. */
  80102. constructor(scene: Scene, size?: number | {
  80103. width: number;
  80104. height: number;
  80105. } | {
  80106. ratio: number;
  80107. });
  80108. /**
  80109. * @hidden
  80110. * @param faceIndex the face index, if its a cube texture
  80111. */
  80112. _bindFrameBuffer(faceIndex?: number): void;
  80113. /**
  80114. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80115. * @returns the view count
  80116. */
  80117. getViewCount(): number;
  80118. }
  80119. }
  80120. declare module BABYLON {
  80121. interface Engine {
  80122. /**
  80123. * Creates a new multiview render target
  80124. * @param width defines the width of the texture
  80125. * @param height defines the height of the texture
  80126. * @returns the created multiview texture
  80127. */
  80128. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80129. /**
  80130. * Binds a multiview framebuffer to be drawn to
  80131. * @param multiviewTexture texture to bind
  80132. */
  80133. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80134. }
  80135. interface Camera {
  80136. /**
  80137. * @hidden
  80138. * 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)
  80139. */
  80140. _useMultiviewToSingleView: boolean;
  80141. /**
  80142. * @hidden
  80143. * 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)
  80144. */
  80145. _multiviewTexture: Nullable<RenderTargetTexture>;
  80146. /**
  80147. * @hidden
  80148. * ensures the multiview texture of the camera exists and has the specified width/height
  80149. * @param width height to set on the multiview texture
  80150. * @param height width to set on the multiview texture
  80151. */
  80152. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80153. }
  80154. interface Scene {
  80155. /** @hidden */
  80156. _transformMatrixR: Matrix;
  80157. /** @hidden */
  80158. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80159. /** @hidden */
  80160. _createMultiviewUbo(): void;
  80161. /** @hidden */
  80162. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80163. /** @hidden */
  80164. _renderMultiviewToSingleView(camera: Camera): void;
  80165. }
  80166. }
  80167. declare module BABYLON {
  80168. /**
  80169. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80170. * This will not be used for webXR as it supports displaying texture arrays directly
  80171. */
  80172. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80173. /**
  80174. * Initializes a VRMultiviewToSingleview
  80175. * @param name name of the post process
  80176. * @param camera camera to be applied to
  80177. * @param scaleFactor scaling factor to the size of the output texture
  80178. */
  80179. constructor(name: string, camera: Camera, scaleFactor: number);
  80180. }
  80181. }
  80182. declare module BABYLON {
  80183. interface Engine {
  80184. /** @hidden */
  80185. _vrDisplay: any;
  80186. /** @hidden */
  80187. _vrSupported: boolean;
  80188. /** @hidden */
  80189. _oldSize: Size;
  80190. /** @hidden */
  80191. _oldHardwareScaleFactor: number;
  80192. /** @hidden */
  80193. _vrExclusivePointerMode: boolean;
  80194. /** @hidden */
  80195. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80196. /** @hidden */
  80197. _onVRDisplayPointerRestricted: () => void;
  80198. /** @hidden */
  80199. _onVRDisplayPointerUnrestricted: () => void;
  80200. /** @hidden */
  80201. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80202. /** @hidden */
  80203. _onVrDisplayDisconnect: Nullable<() => void>;
  80204. /** @hidden */
  80205. _onVrDisplayPresentChange: Nullable<() => void>;
  80206. /**
  80207. * Observable signaled when VR display mode changes
  80208. */
  80209. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80210. /**
  80211. * Observable signaled when VR request present is complete
  80212. */
  80213. onVRRequestPresentComplete: Observable<boolean>;
  80214. /**
  80215. * Observable signaled when VR request present starts
  80216. */
  80217. onVRRequestPresentStart: Observable<Engine>;
  80218. /**
  80219. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80220. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80221. */
  80222. isInVRExclusivePointerMode: boolean;
  80223. /**
  80224. * Gets a boolean indicating if a webVR device was detected
  80225. * @returns true if a webVR device was detected
  80226. */
  80227. isVRDevicePresent(): boolean;
  80228. /**
  80229. * Gets the current webVR device
  80230. * @returns the current webVR device (or null)
  80231. */
  80232. getVRDevice(): any;
  80233. /**
  80234. * Initializes a webVR display and starts listening to display change events
  80235. * The onVRDisplayChangedObservable will be notified upon these changes
  80236. * @returns A promise containing a VRDisplay and if vr is supported
  80237. */
  80238. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80239. /** @hidden */
  80240. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80241. /**
  80242. * Call this function to switch to webVR mode
  80243. * Will do nothing if webVR is not supported or if there is no webVR device
  80244. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80245. */
  80246. enableVR(): void;
  80247. /** @hidden */
  80248. _onVRFullScreenTriggered(): void;
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /**
  80253. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80254. * IMPORTANT!! The data is right-hand data.
  80255. * @export
  80256. * @interface DevicePose
  80257. */
  80258. export interface DevicePose {
  80259. /**
  80260. * The position of the device, values in array are [x,y,z].
  80261. */
  80262. readonly position: Nullable<Float32Array>;
  80263. /**
  80264. * The linearVelocity of the device, values in array are [x,y,z].
  80265. */
  80266. readonly linearVelocity: Nullable<Float32Array>;
  80267. /**
  80268. * The linearAcceleration of the device, values in array are [x,y,z].
  80269. */
  80270. readonly linearAcceleration: Nullable<Float32Array>;
  80271. /**
  80272. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80273. */
  80274. readonly orientation: Nullable<Float32Array>;
  80275. /**
  80276. * The angularVelocity of the device, values in array are [x,y,z].
  80277. */
  80278. readonly angularVelocity: Nullable<Float32Array>;
  80279. /**
  80280. * The angularAcceleration of the device, values in array are [x,y,z].
  80281. */
  80282. readonly angularAcceleration: Nullable<Float32Array>;
  80283. }
  80284. /**
  80285. * Interface representing a pose controlled object in Babylon.
  80286. * A pose controlled object has both regular pose values as well as pose values
  80287. * from an external device such as a VR head mounted display
  80288. */
  80289. export interface PoseControlled {
  80290. /**
  80291. * The position of the object in babylon space.
  80292. */
  80293. position: Vector3;
  80294. /**
  80295. * The rotation quaternion of the object in babylon space.
  80296. */
  80297. rotationQuaternion: Quaternion;
  80298. /**
  80299. * The position of the device in babylon space.
  80300. */
  80301. devicePosition?: Vector3;
  80302. /**
  80303. * The rotation quaternion of the device in babylon space.
  80304. */
  80305. deviceRotationQuaternion: Quaternion;
  80306. /**
  80307. * The raw pose coming from the device.
  80308. */
  80309. rawPose: Nullable<DevicePose>;
  80310. /**
  80311. * The scale of the device to be used when translating from device space to babylon space.
  80312. */
  80313. deviceScaleFactor: number;
  80314. /**
  80315. * Updates the poseControlled values based on the input device pose.
  80316. * @param poseData the pose data to update the object with
  80317. */
  80318. updateFromDevice(poseData: DevicePose): void;
  80319. }
  80320. /**
  80321. * Set of options to customize the webVRCamera
  80322. */
  80323. export interface WebVROptions {
  80324. /**
  80325. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80326. */
  80327. trackPosition?: boolean;
  80328. /**
  80329. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80330. */
  80331. positionScale?: number;
  80332. /**
  80333. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80334. */
  80335. displayName?: string;
  80336. /**
  80337. * Should the native controller meshes be initialized. (default: true)
  80338. */
  80339. controllerMeshes?: boolean;
  80340. /**
  80341. * Creating a default HemiLight only on controllers. (default: true)
  80342. */
  80343. defaultLightingOnControllers?: boolean;
  80344. /**
  80345. * If you don't want to use the default VR button of the helper. (default: false)
  80346. */
  80347. useCustomVRButton?: boolean;
  80348. /**
  80349. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80350. */
  80351. customVRButton?: HTMLButtonElement;
  80352. /**
  80353. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80354. */
  80355. rayLength?: number;
  80356. /**
  80357. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80358. */
  80359. defaultHeight?: number;
  80360. /**
  80361. * If multiview should be used if availible (default: false)
  80362. */
  80363. useMultiview?: boolean;
  80364. }
  80365. /**
  80366. * This represents a WebVR camera.
  80367. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80368. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80369. */
  80370. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80371. private webVROptions;
  80372. /**
  80373. * @hidden
  80374. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80375. */
  80376. _vrDevice: any;
  80377. /**
  80378. * The rawPose of the vrDevice.
  80379. */
  80380. rawPose: Nullable<DevicePose>;
  80381. private _onVREnabled;
  80382. private _specsVersion;
  80383. private _attached;
  80384. private _frameData;
  80385. protected _descendants: Array<Node>;
  80386. private _deviceRoomPosition;
  80387. /** @hidden */
  80388. _deviceRoomRotationQuaternion: Quaternion;
  80389. private _standingMatrix;
  80390. /**
  80391. * Represents device position in babylon space.
  80392. */
  80393. devicePosition: Vector3;
  80394. /**
  80395. * Represents device rotation in babylon space.
  80396. */
  80397. deviceRotationQuaternion: Quaternion;
  80398. /**
  80399. * The scale of the device to be used when translating from device space to babylon space.
  80400. */
  80401. deviceScaleFactor: number;
  80402. private _deviceToWorld;
  80403. private _worldToDevice;
  80404. /**
  80405. * References to the webVR controllers for the vrDevice.
  80406. */
  80407. controllers: Array<WebVRController>;
  80408. /**
  80409. * Emits an event when a controller is attached.
  80410. */
  80411. onControllersAttachedObservable: Observable<WebVRController[]>;
  80412. /**
  80413. * Emits an event when a controller's mesh has been loaded;
  80414. */
  80415. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80416. /**
  80417. * Emits an event when the HMD's pose has been updated.
  80418. */
  80419. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80420. private _poseSet;
  80421. /**
  80422. * If the rig cameras be used as parent instead of this camera.
  80423. */
  80424. rigParenting: boolean;
  80425. private _lightOnControllers;
  80426. private _defaultHeight?;
  80427. /**
  80428. * Instantiates a WebVRFreeCamera.
  80429. * @param name The name of the WebVRFreeCamera
  80430. * @param position The starting anchor position for the camera
  80431. * @param scene The scene the camera belongs to
  80432. * @param webVROptions a set of customizable options for the webVRCamera
  80433. */
  80434. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80435. /**
  80436. * Gets the device distance from the ground in meters.
  80437. * @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.
  80438. */
  80439. deviceDistanceToRoomGround(): number;
  80440. /**
  80441. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80442. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80443. */
  80444. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80445. /**
  80446. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80447. * @returns A promise with a boolean set to if the standing matrix is supported.
  80448. */
  80449. useStandingMatrixAsync(): Promise<boolean>;
  80450. /**
  80451. * Disposes the camera
  80452. */
  80453. dispose(): void;
  80454. /**
  80455. * Gets a vrController by name.
  80456. * @param name The name of the controller to retreive
  80457. * @returns the controller matching the name specified or null if not found
  80458. */
  80459. getControllerByName(name: string): Nullable<WebVRController>;
  80460. private _leftController;
  80461. /**
  80462. * The controller corresponding to the users left hand.
  80463. */
  80464. readonly leftController: Nullable<WebVRController>;
  80465. private _rightController;
  80466. /**
  80467. * The controller corresponding to the users right hand.
  80468. */
  80469. readonly rightController: Nullable<WebVRController>;
  80470. /**
  80471. * Casts a ray forward from the vrCamera's gaze.
  80472. * @param length Length of the ray (default: 100)
  80473. * @returns the ray corresponding to the gaze
  80474. */
  80475. getForwardRay(length?: number): Ray;
  80476. /**
  80477. * @hidden
  80478. * Updates the camera based on device's frame data
  80479. */
  80480. _checkInputs(): void;
  80481. /**
  80482. * Updates the poseControlled values based on the input device pose.
  80483. * @param poseData Pose coming from the device
  80484. */
  80485. updateFromDevice(poseData: DevicePose): void;
  80486. private _htmlElementAttached;
  80487. private _detachIfAttached;
  80488. /**
  80489. * WebVR's attach control will start broadcasting frames to the device.
  80490. * Note that in certain browsers (chrome for example) this function must be called
  80491. * within a user-interaction callback. Example:
  80492. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80493. *
  80494. * @param element html element to attach the vrDevice to
  80495. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80496. */
  80497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80498. /**
  80499. * Detaches the camera from the html element and disables VR
  80500. *
  80501. * @param element html element to detach from
  80502. */
  80503. detachControl(element: HTMLElement): void;
  80504. /**
  80505. * @returns the name of this class
  80506. */
  80507. getClassName(): string;
  80508. /**
  80509. * Calls resetPose on the vrDisplay
  80510. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80511. */
  80512. resetToCurrentRotation(): void;
  80513. /**
  80514. * @hidden
  80515. * Updates the rig cameras (left and right eye)
  80516. */
  80517. _updateRigCameras(): void;
  80518. private _workingVector;
  80519. private _oneVector;
  80520. private _workingMatrix;
  80521. private updateCacheCalled;
  80522. private _correctPositionIfNotTrackPosition;
  80523. /**
  80524. * @hidden
  80525. * Updates the cached values of the camera
  80526. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80527. */
  80528. _updateCache(ignoreParentClass?: boolean): void;
  80529. /**
  80530. * @hidden
  80531. * Get current device position in babylon world
  80532. */
  80533. _computeDevicePosition(): void;
  80534. /**
  80535. * Updates the current device position and rotation in the babylon world
  80536. */
  80537. update(): void;
  80538. /**
  80539. * @hidden
  80540. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80541. * @returns an identity matrix
  80542. */
  80543. _getViewMatrix(): Matrix;
  80544. private _tmpMatrix;
  80545. /**
  80546. * This function is called by the two RIG cameras.
  80547. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80548. * @hidden
  80549. */
  80550. _getWebVRViewMatrix(): Matrix;
  80551. /** @hidden */
  80552. _getWebVRProjectionMatrix(): Matrix;
  80553. private _onGamepadConnectedObserver;
  80554. private _onGamepadDisconnectedObserver;
  80555. private _updateCacheWhenTrackingDisabledObserver;
  80556. /**
  80557. * Initializes the controllers and their meshes
  80558. */
  80559. initControllers(): void;
  80560. }
  80561. }
  80562. declare module BABYLON {
  80563. /**
  80564. * Size options for a post process
  80565. */
  80566. export type PostProcessOptions = {
  80567. width: number;
  80568. height: number;
  80569. };
  80570. /**
  80571. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80572. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80573. */
  80574. export class PostProcess {
  80575. /** Name of the PostProcess. */
  80576. name: string;
  80577. /**
  80578. * Gets or sets the unique id of the post process
  80579. */
  80580. uniqueId: number;
  80581. /**
  80582. * Width of the texture to apply the post process on
  80583. */
  80584. width: number;
  80585. /**
  80586. * Height of the texture to apply the post process on
  80587. */
  80588. height: number;
  80589. /**
  80590. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80591. * @hidden
  80592. */
  80593. _outputTexture: Nullable<InternalTexture>;
  80594. /**
  80595. * Sampling mode used by the shader
  80596. * See https://doc.babylonjs.com/classes/3.1/texture
  80597. */
  80598. renderTargetSamplingMode: number;
  80599. /**
  80600. * Clear color to use when screen clearing
  80601. */
  80602. clearColor: Color4;
  80603. /**
  80604. * If the buffer needs to be cleared before applying the post process. (default: true)
  80605. * Should be set to false if shader will overwrite all previous pixels.
  80606. */
  80607. autoClear: boolean;
  80608. /**
  80609. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80610. */
  80611. alphaMode: number;
  80612. /**
  80613. * Sets the setAlphaBlendConstants of the babylon engine
  80614. */
  80615. alphaConstants: Color4;
  80616. /**
  80617. * Animations to be used for the post processing
  80618. */
  80619. animations: Animation[];
  80620. /**
  80621. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80622. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80623. */
  80624. enablePixelPerfectMode: boolean;
  80625. /**
  80626. * Force the postprocess to be applied without taking in account viewport
  80627. */
  80628. forceFullscreenViewport: boolean;
  80629. /**
  80630. * List of inspectable custom properties (used by the Inspector)
  80631. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80632. */
  80633. inspectableCustomProperties: IInspectable[];
  80634. /**
  80635. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80636. *
  80637. * | Value | Type | Description |
  80638. * | ----- | ----------------------------------- | ----------- |
  80639. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80640. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80641. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80642. *
  80643. */
  80644. scaleMode: number;
  80645. /**
  80646. * Force textures to be a power of two (default: false)
  80647. */
  80648. alwaysForcePOT: boolean;
  80649. private _samples;
  80650. /**
  80651. * Number of sample textures (default: 1)
  80652. */
  80653. samples: number;
  80654. /**
  80655. * Modify the scale of the post process to be the same as the viewport (default: false)
  80656. */
  80657. adaptScaleToCurrentViewport: boolean;
  80658. private _camera;
  80659. private _scene;
  80660. private _engine;
  80661. private _options;
  80662. private _reusable;
  80663. private _textureType;
  80664. /**
  80665. * Smart array of input and output textures for the post process.
  80666. * @hidden
  80667. */
  80668. _textures: SmartArray<InternalTexture>;
  80669. /**
  80670. * The index in _textures that corresponds to the output texture.
  80671. * @hidden
  80672. */
  80673. _currentRenderTextureInd: number;
  80674. private _effect;
  80675. private _samplers;
  80676. private _fragmentUrl;
  80677. private _vertexUrl;
  80678. private _parameters;
  80679. private _scaleRatio;
  80680. protected _indexParameters: any;
  80681. private _shareOutputWithPostProcess;
  80682. private _texelSize;
  80683. private _forcedOutputTexture;
  80684. /**
  80685. * Returns the fragment url or shader name used in the post process.
  80686. * @returns the fragment url or name in the shader store.
  80687. */
  80688. getEffectName(): string;
  80689. /**
  80690. * An event triggered when the postprocess is activated.
  80691. */
  80692. onActivateObservable: Observable<Camera>;
  80693. private _onActivateObserver;
  80694. /**
  80695. * A function that is added to the onActivateObservable
  80696. */
  80697. onActivate: Nullable<(camera: Camera) => void>;
  80698. /**
  80699. * An event triggered when the postprocess changes its size.
  80700. */
  80701. onSizeChangedObservable: Observable<PostProcess>;
  80702. private _onSizeChangedObserver;
  80703. /**
  80704. * A function that is added to the onSizeChangedObservable
  80705. */
  80706. onSizeChanged: (postProcess: PostProcess) => void;
  80707. /**
  80708. * An event triggered when the postprocess applies its effect.
  80709. */
  80710. onApplyObservable: Observable<Effect>;
  80711. private _onApplyObserver;
  80712. /**
  80713. * A function that is added to the onApplyObservable
  80714. */
  80715. onApply: (effect: Effect) => void;
  80716. /**
  80717. * An event triggered before rendering the postprocess
  80718. */
  80719. onBeforeRenderObservable: Observable<Effect>;
  80720. private _onBeforeRenderObserver;
  80721. /**
  80722. * A function that is added to the onBeforeRenderObservable
  80723. */
  80724. onBeforeRender: (effect: Effect) => void;
  80725. /**
  80726. * An event triggered after rendering the postprocess
  80727. */
  80728. onAfterRenderObservable: Observable<Effect>;
  80729. private _onAfterRenderObserver;
  80730. /**
  80731. * A function that is added to the onAfterRenderObservable
  80732. */
  80733. onAfterRender: (efect: Effect) => void;
  80734. /**
  80735. * 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
  80736. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80737. */
  80738. inputTexture: InternalTexture;
  80739. /**
  80740. * Gets the camera which post process is applied to.
  80741. * @returns The camera the post process is applied to.
  80742. */
  80743. getCamera(): Camera;
  80744. /**
  80745. * Gets the texel size of the postprocess.
  80746. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80747. */
  80748. readonly texelSize: Vector2;
  80749. /**
  80750. * Creates a new instance PostProcess
  80751. * @param name The name of the PostProcess.
  80752. * @param fragmentUrl The url of the fragment shader to be used.
  80753. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80754. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80755. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80756. * @param camera The camera to apply the render pass to.
  80757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80758. * @param engine The engine which the post process will be applied. (default: current engine)
  80759. * @param reusable If the post process can be reused on the same frame. (default: false)
  80760. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80761. * @param textureType Type of textures used when performing the post process. (default: 0)
  80762. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80763. * @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
  80764. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80765. */
  80766. constructor(
  80767. /** Name of the PostProcess. */
  80768. 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);
  80769. /**
  80770. * Gets a string idenfifying the name of the class
  80771. * @returns "PostProcess" string
  80772. */
  80773. getClassName(): string;
  80774. /**
  80775. * Gets the engine which this post process belongs to.
  80776. * @returns The engine the post process was enabled with.
  80777. */
  80778. getEngine(): Engine;
  80779. /**
  80780. * The effect that is created when initializing the post process.
  80781. * @returns The created effect corresponding the the postprocess.
  80782. */
  80783. getEffect(): Effect;
  80784. /**
  80785. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80786. * @param postProcess The post process to share the output with.
  80787. * @returns This post process.
  80788. */
  80789. shareOutputWith(postProcess: PostProcess): PostProcess;
  80790. /**
  80791. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80792. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80793. */
  80794. useOwnOutput(): void;
  80795. /**
  80796. * Updates the effect with the current post process compile time values and recompiles the shader.
  80797. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80798. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80799. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80800. * @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
  80801. * @param onCompiled Called when the shader has been compiled.
  80802. * @param onError Called if there is an error when compiling a shader.
  80803. */
  80804. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80805. /**
  80806. * The post process is reusable if it can be used multiple times within one frame.
  80807. * @returns If the post process is reusable
  80808. */
  80809. isReusable(): boolean;
  80810. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80811. markTextureDirty(): void;
  80812. /**
  80813. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80814. * 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.
  80815. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80816. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80817. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80818. * @returns The target texture that was bound to be written to.
  80819. */
  80820. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80821. /**
  80822. * If the post process is supported.
  80823. */
  80824. readonly isSupported: boolean;
  80825. /**
  80826. * The aspect ratio of the output texture.
  80827. */
  80828. readonly aspectRatio: number;
  80829. /**
  80830. * Get a value indicating if the post-process is ready to be used
  80831. * @returns true if the post-process is ready (shader is compiled)
  80832. */
  80833. isReady(): boolean;
  80834. /**
  80835. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80836. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80837. */
  80838. apply(): Nullable<Effect>;
  80839. private _disposeTextures;
  80840. /**
  80841. * Disposes the post process.
  80842. * @param camera The camera to dispose the post process on.
  80843. */
  80844. dispose(camera?: Camera): void;
  80845. }
  80846. }
  80847. declare module BABYLON {
  80848. /** @hidden */
  80849. export var kernelBlurVaryingDeclaration: {
  80850. name: string;
  80851. shader: string;
  80852. };
  80853. }
  80854. declare module BABYLON {
  80855. /** @hidden */
  80856. export var kernelBlurFragment: {
  80857. name: string;
  80858. shader: string;
  80859. };
  80860. }
  80861. declare module BABYLON {
  80862. /** @hidden */
  80863. export var kernelBlurFragment2: {
  80864. name: string;
  80865. shader: string;
  80866. };
  80867. }
  80868. declare module BABYLON {
  80869. /** @hidden */
  80870. export var kernelBlurPixelShader: {
  80871. name: string;
  80872. shader: string;
  80873. };
  80874. }
  80875. declare module BABYLON {
  80876. /** @hidden */
  80877. export var kernelBlurVertex: {
  80878. name: string;
  80879. shader: string;
  80880. };
  80881. }
  80882. declare module BABYLON {
  80883. /** @hidden */
  80884. export var kernelBlurVertexShader: {
  80885. name: string;
  80886. shader: string;
  80887. };
  80888. }
  80889. declare module BABYLON {
  80890. /**
  80891. * The Blur Post Process which blurs an image based on a kernel and direction.
  80892. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80893. */
  80894. export class BlurPostProcess extends PostProcess {
  80895. /** The direction in which to blur the image. */
  80896. direction: Vector2;
  80897. private blockCompilation;
  80898. protected _kernel: number;
  80899. protected _idealKernel: number;
  80900. protected _packedFloat: boolean;
  80901. private _staticDefines;
  80902. /**
  80903. * Sets the length in pixels of the blur sample region
  80904. */
  80905. /**
  80906. * Gets the length in pixels of the blur sample region
  80907. */
  80908. kernel: number;
  80909. /**
  80910. * Sets wether or not the blur needs to unpack/repack floats
  80911. */
  80912. /**
  80913. * Gets wether or not the blur is unpacking/repacking floats
  80914. */
  80915. packedFloat: boolean;
  80916. /**
  80917. * Creates a new instance BlurPostProcess
  80918. * @param name The name of the effect.
  80919. * @param direction The direction in which to blur the image.
  80920. * @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.
  80921. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80922. * @param camera The camera to apply the render pass to.
  80923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80924. * @param engine The engine which the post process will be applied. (default: current engine)
  80925. * @param reusable If the post process can be reused on the same frame. (default: false)
  80926. * @param textureType Type of textures used when performing the post process. (default: 0)
  80927. * @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)
  80928. */
  80929. constructor(name: string,
  80930. /** The direction in which to blur the image. */
  80931. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80932. /**
  80933. * Updates the effect with the current post process compile time values and recompiles the shader.
  80934. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80935. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80936. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80937. * @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
  80938. * @param onCompiled Called when the shader has been compiled.
  80939. * @param onError Called if there is an error when compiling a shader.
  80940. */
  80941. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80942. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80943. /**
  80944. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80945. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80946. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80947. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80948. * The gaps between physical kernels are compensated for in the weighting of the samples
  80949. * @param idealKernel Ideal blur kernel.
  80950. * @return Nearest best kernel.
  80951. */
  80952. protected _nearestBestKernel(idealKernel: number): number;
  80953. /**
  80954. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80955. * @param x The point on the Gaussian distribution to sample.
  80956. * @return the value of the Gaussian function at x.
  80957. */
  80958. protected _gaussianWeight(x: number): number;
  80959. /**
  80960. * Generates a string that can be used as a floating point number in GLSL.
  80961. * @param x Value to print.
  80962. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80963. * @return GLSL float string.
  80964. */
  80965. protected _glslFloat(x: number, decimalFigures?: number): string;
  80966. }
  80967. }
  80968. declare module BABYLON {
  80969. /**
  80970. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80971. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80972. * You can then easily use it as a reflectionTexture on a flat surface.
  80973. * In case the surface is not a plane, please consider relying on reflection probes.
  80974. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80975. */
  80976. export class MirrorTexture extends RenderTargetTexture {
  80977. private scene;
  80978. /**
  80979. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80980. * 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.
  80981. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80982. */
  80983. mirrorPlane: Plane;
  80984. /**
  80985. * Define the blur ratio used to blur the reflection if needed.
  80986. */
  80987. blurRatio: number;
  80988. /**
  80989. * Define the adaptive blur kernel used to blur the reflection if needed.
  80990. * This will autocompute the closest best match for the `blurKernel`
  80991. */
  80992. adaptiveBlurKernel: number;
  80993. /**
  80994. * Define the blur kernel used to blur the reflection if needed.
  80995. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80996. */
  80997. blurKernel: number;
  80998. /**
  80999. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81000. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81001. */
  81002. blurKernelX: number;
  81003. /**
  81004. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81005. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81006. */
  81007. blurKernelY: number;
  81008. private _autoComputeBlurKernel;
  81009. protected _onRatioRescale(): void;
  81010. private _updateGammaSpace;
  81011. private _imageProcessingConfigChangeObserver;
  81012. private _transformMatrix;
  81013. private _mirrorMatrix;
  81014. private _savedViewMatrix;
  81015. private _blurX;
  81016. private _blurY;
  81017. private _adaptiveBlurKernel;
  81018. private _blurKernelX;
  81019. private _blurKernelY;
  81020. private _blurRatio;
  81021. /**
  81022. * Instantiates a Mirror Texture.
  81023. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81024. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81025. * You can then easily use it as a reflectionTexture on a flat surface.
  81026. * In case the surface is not a plane, please consider relying on reflection probes.
  81027. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81028. * @param name
  81029. * @param size
  81030. * @param scene
  81031. * @param generateMipMaps
  81032. * @param type
  81033. * @param samplingMode
  81034. * @param generateDepthBuffer
  81035. */
  81036. constructor(name: string, size: number | {
  81037. width: number;
  81038. height: number;
  81039. } | {
  81040. ratio: number;
  81041. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81042. private _preparePostProcesses;
  81043. /**
  81044. * Clone the mirror texture.
  81045. * @returns the cloned texture
  81046. */
  81047. clone(): MirrorTexture;
  81048. /**
  81049. * Serialize the texture to a JSON representation you could use in Parse later on
  81050. * @returns the serialized JSON representation
  81051. */
  81052. serialize(): any;
  81053. /**
  81054. * Dispose the texture and release its associated resources.
  81055. */
  81056. dispose(): void;
  81057. }
  81058. }
  81059. declare module BABYLON {
  81060. /**
  81061. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81062. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81063. */
  81064. export class Texture extends BaseTexture {
  81065. /** @hidden */
  81066. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81067. /** @hidden */
  81068. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81069. /** @hidden */
  81070. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81071. /** nearest is mag = nearest and min = nearest and mip = linear */
  81072. static readonly NEAREST_SAMPLINGMODE: number;
  81073. /** nearest is mag = nearest and min = nearest and mip = linear */
  81074. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81076. static readonly BILINEAR_SAMPLINGMODE: number;
  81077. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81078. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81079. /** Trilinear is mag = linear and min = linear and mip = linear */
  81080. static readonly TRILINEAR_SAMPLINGMODE: number;
  81081. /** Trilinear is mag = linear and min = linear and mip = linear */
  81082. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81083. /** mag = nearest and min = nearest and mip = nearest */
  81084. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81085. /** mag = nearest and min = linear and mip = nearest */
  81086. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81087. /** mag = nearest and min = linear and mip = linear */
  81088. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81089. /** mag = nearest and min = linear and mip = none */
  81090. static readonly NEAREST_LINEAR: number;
  81091. /** mag = nearest and min = nearest and mip = none */
  81092. static readonly NEAREST_NEAREST: number;
  81093. /** mag = linear and min = nearest and mip = nearest */
  81094. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81095. /** mag = linear and min = nearest and mip = linear */
  81096. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81097. /** mag = linear and min = linear and mip = none */
  81098. static readonly LINEAR_LINEAR: number;
  81099. /** mag = linear and min = nearest and mip = none */
  81100. static readonly LINEAR_NEAREST: number;
  81101. /** Explicit coordinates mode */
  81102. static readonly EXPLICIT_MODE: number;
  81103. /** Spherical coordinates mode */
  81104. static readonly SPHERICAL_MODE: number;
  81105. /** Planar coordinates mode */
  81106. static readonly PLANAR_MODE: number;
  81107. /** Cubic coordinates mode */
  81108. static readonly CUBIC_MODE: number;
  81109. /** Projection coordinates mode */
  81110. static readonly PROJECTION_MODE: number;
  81111. /** Inverse Cubic coordinates mode */
  81112. static readonly SKYBOX_MODE: number;
  81113. /** Inverse Cubic coordinates mode */
  81114. static readonly INVCUBIC_MODE: number;
  81115. /** Equirectangular coordinates mode */
  81116. static readonly EQUIRECTANGULAR_MODE: number;
  81117. /** Equirectangular Fixed coordinates mode */
  81118. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81119. /** Equirectangular Fixed Mirrored coordinates mode */
  81120. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81121. /** Texture is not repeating outside of 0..1 UVs */
  81122. static readonly CLAMP_ADDRESSMODE: number;
  81123. /** Texture is repeating outside of 0..1 UVs */
  81124. static readonly WRAP_ADDRESSMODE: number;
  81125. /** Texture is repeating and mirrored */
  81126. static readonly MIRROR_ADDRESSMODE: number;
  81127. /**
  81128. * 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
  81129. */
  81130. static UseSerializedUrlIfAny: boolean;
  81131. /**
  81132. * Define the url of the texture.
  81133. */
  81134. url: Nullable<string>;
  81135. /**
  81136. * Define an offset on the texture to offset the u coordinates of the UVs
  81137. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81138. */
  81139. uOffset: number;
  81140. /**
  81141. * Define an offset on the texture to offset the v coordinates of the UVs
  81142. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81143. */
  81144. vOffset: number;
  81145. /**
  81146. * Define an offset on the texture to scale the u coordinates of the UVs
  81147. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81148. */
  81149. uScale: number;
  81150. /**
  81151. * Define an offset on the texture to scale the v coordinates of the UVs
  81152. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81153. */
  81154. vScale: number;
  81155. /**
  81156. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81157. * @see http://doc.babylonjs.com/how_to/more_materials
  81158. */
  81159. uAng: number;
  81160. /**
  81161. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81162. * @see http://doc.babylonjs.com/how_to/more_materials
  81163. */
  81164. vAng: number;
  81165. /**
  81166. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81167. * @see http://doc.babylonjs.com/how_to/more_materials
  81168. */
  81169. wAng: number;
  81170. /**
  81171. * Defines the center of rotation (U)
  81172. */
  81173. uRotationCenter: number;
  81174. /**
  81175. * Defines the center of rotation (V)
  81176. */
  81177. vRotationCenter: number;
  81178. /**
  81179. * Defines the center of rotation (W)
  81180. */
  81181. wRotationCenter: number;
  81182. /**
  81183. * Are mip maps generated for this texture or not.
  81184. */
  81185. readonly noMipmap: boolean;
  81186. /**
  81187. * List of inspectable custom properties (used by the Inspector)
  81188. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81189. */
  81190. inspectableCustomProperties: Nullable<IInspectable[]>;
  81191. private _noMipmap;
  81192. /** @hidden */
  81193. _invertY: boolean;
  81194. private _rowGenerationMatrix;
  81195. private _cachedTextureMatrix;
  81196. private _projectionModeMatrix;
  81197. private _t0;
  81198. private _t1;
  81199. private _t2;
  81200. private _cachedUOffset;
  81201. private _cachedVOffset;
  81202. private _cachedUScale;
  81203. private _cachedVScale;
  81204. private _cachedUAng;
  81205. private _cachedVAng;
  81206. private _cachedWAng;
  81207. private _cachedProjectionMatrixId;
  81208. private _cachedCoordinatesMode;
  81209. /** @hidden */
  81210. protected _initialSamplingMode: number;
  81211. /** @hidden */
  81212. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81213. private _deleteBuffer;
  81214. protected _format: Nullable<number>;
  81215. private _delayedOnLoad;
  81216. private _delayedOnError;
  81217. /**
  81218. * Observable triggered once the texture has been loaded.
  81219. */
  81220. onLoadObservable: Observable<Texture>;
  81221. protected _isBlocking: boolean;
  81222. /**
  81223. * Is the texture preventing material to render while loading.
  81224. * If false, a default texture will be used instead of the loading one during the preparation step.
  81225. */
  81226. isBlocking: boolean;
  81227. /**
  81228. * Get the current sampling mode associated with the texture.
  81229. */
  81230. readonly samplingMode: number;
  81231. /**
  81232. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81233. */
  81234. readonly invertY: boolean;
  81235. /**
  81236. * Instantiates a new texture.
  81237. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81238. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81239. * @param url define the url of the picture to load as a texture
  81240. * @param scene define the scene or engine the texture will belong to
  81241. * @param noMipmap define if the texture will require mip maps or not
  81242. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81243. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81244. * @param onLoad define a callback triggered when the texture has been loaded
  81245. * @param onError define a callback triggered when an error occurred during the loading session
  81246. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81247. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81248. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81249. */
  81250. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  81251. /**
  81252. * Update the url (and optional buffer) of this texture if url was null during construction.
  81253. * @param url the url of the texture
  81254. * @param buffer the buffer of the texture (defaults to null)
  81255. * @param onLoad callback called when the texture is loaded (defaults to null)
  81256. */
  81257. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81258. /**
  81259. * Finish the loading sequence of a texture flagged as delayed load.
  81260. * @hidden
  81261. */
  81262. delayLoad(): void;
  81263. private _prepareRowForTextureGeneration;
  81264. /**
  81265. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81266. * @returns the transform matrix of the texture.
  81267. */
  81268. getTextureMatrix(): Matrix;
  81269. /**
  81270. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81271. * @returns The reflection texture transform
  81272. */
  81273. getReflectionTextureMatrix(): Matrix;
  81274. /**
  81275. * Clones the texture.
  81276. * @returns the cloned texture
  81277. */
  81278. clone(): Texture;
  81279. /**
  81280. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81281. * @returns The JSON representation of the texture
  81282. */
  81283. serialize(): any;
  81284. /**
  81285. * Get the current class name of the texture useful for serialization or dynamic coding.
  81286. * @returns "Texture"
  81287. */
  81288. getClassName(): string;
  81289. /**
  81290. * Dispose the texture and release its associated resources.
  81291. */
  81292. dispose(): void;
  81293. /**
  81294. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81295. * @param parsedTexture Define the JSON representation of the texture
  81296. * @param scene Define the scene the parsed texture should be instantiated in
  81297. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81298. * @returns The parsed texture if successful
  81299. */
  81300. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81301. /**
  81302. * Creates a texture from its base 64 representation.
  81303. * @param data Define the base64 payload without the data: prefix
  81304. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81305. * @param scene Define the scene the texture should belong to
  81306. * @param noMipmap Forces the texture to not create mip map information if true
  81307. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81308. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81309. * @param onLoad define a callback triggered when the texture has been loaded
  81310. * @param onError define a callback triggered when an error occurred during the loading session
  81311. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81312. * @returns the created texture
  81313. */
  81314. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81315. /**
  81316. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81317. * @param data Define the base64 payload without the data: prefix
  81318. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81319. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81320. * @param scene Define the scene the texture should belong to
  81321. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81322. * @param noMipmap Forces the texture to not create mip map information if true
  81323. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81324. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81325. * @param onLoad define a callback triggered when the texture has been loaded
  81326. * @param onError define a callback triggered when an error occurred during the loading session
  81327. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81328. * @returns the created texture
  81329. */
  81330. 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;
  81331. }
  81332. }
  81333. declare module BABYLON {
  81334. /**
  81335. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81336. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81337. */
  81338. export class PostProcessManager {
  81339. private _scene;
  81340. private _indexBuffer;
  81341. private _vertexBuffers;
  81342. /**
  81343. * Creates a new instance PostProcess
  81344. * @param scene The scene that the post process is associated with.
  81345. */
  81346. constructor(scene: Scene);
  81347. private _prepareBuffers;
  81348. private _buildIndexBuffer;
  81349. /**
  81350. * Rebuilds the vertex buffers of the manager.
  81351. * @hidden
  81352. */
  81353. _rebuild(): void;
  81354. /**
  81355. * Prepares a frame to be run through a post process.
  81356. * @param sourceTexture The input texture to the post procesess. (default: null)
  81357. * @param postProcesses An array of post processes to be run. (default: null)
  81358. * @returns True if the post processes were able to be run.
  81359. * @hidden
  81360. */
  81361. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81362. /**
  81363. * Manually render a set of post processes to a texture.
  81364. * @param postProcesses An array of post processes to be run.
  81365. * @param targetTexture The target texture to render to.
  81366. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81367. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81368. * @param lodLevel defines which lod of the texture to render to
  81369. */
  81370. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81371. /**
  81372. * Finalize the result of the output of the postprocesses.
  81373. * @param doNotPresent If true the result will not be displayed to the screen.
  81374. * @param targetTexture The target texture to render to.
  81375. * @param faceIndex The index of the face to bind the target texture to.
  81376. * @param postProcesses The array of post processes to render.
  81377. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81378. * @hidden
  81379. */
  81380. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81381. /**
  81382. * Disposes of the post process manager.
  81383. */
  81384. dispose(): void;
  81385. }
  81386. }
  81387. declare module BABYLON {
  81388. interface AbstractScene {
  81389. /**
  81390. * The list of procedural textures added to the scene
  81391. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81392. */
  81393. proceduralTextures: Array<ProceduralTexture>;
  81394. }
  81395. /**
  81396. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81397. * in a given scene.
  81398. */
  81399. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81400. /**
  81401. * The component name helpfull to identify the component in the list of scene components.
  81402. */
  81403. readonly name: string;
  81404. /**
  81405. * The scene the component belongs to.
  81406. */
  81407. scene: Scene;
  81408. /**
  81409. * Creates a new instance of the component for the given scene
  81410. * @param scene Defines the scene to register the component in
  81411. */
  81412. constructor(scene: Scene);
  81413. /**
  81414. * Registers the component in a given scene
  81415. */
  81416. register(): void;
  81417. /**
  81418. * Rebuilds the elements related to this component in case of
  81419. * context lost for instance.
  81420. */
  81421. rebuild(): void;
  81422. /**
  81423. * Disposes the component and the associated ressources.
  81424. */
  81425. dispose(): void;
  81426. private _beforeClear;
  81427. }
  81428. }
  81429. declare module BABYLON {
  81430. interface Engine {
  81431. /**
  81432. * Creates a new render target cube texture
  81433. * @param size defines the size of the texture
  81434. * @param options defines the options used to create the texture
  81435. * @returns a new render target cube texture stored in an InternalTexture
  81436. */
  81437. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81438. }
  81439. }
  81440. declare module BABYLON {
  81441. /** @hidden */
  81442. export var proceduralVertexShader: {
  81443. name: string;
  81444. shader: string;
  81445. };
  81446. }
  81447. declare module BABYLON {
  81448. /**
  81449. * 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.
  81450. * This is the base class of any Procedural texture and contains most of the shareable code.
  81451. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81452. */
  81453. export class ProceduralTexture extends Texture {
  81454. isCube: boolean;
  81455. /**
  81456. * Define if the texture is enabled or not (disabled texture will not render)
  81457. */
  81458. isEnabled: boolean;
  81459. /**
  81460. * Define if the texture must be cleared before rendering (default is true)
  81461. */
  81462. autoClear: boolean;
  81463. /**
  81464. * Callback called when the texture is generated
  81465. */
  81466. onGenerated: () => void;
  81467. /**
  81468. * Event raised when the texture is generated
  81469. */
  81470. onGeneratedObservable: Observable<ProceduralTexture>;
  81471. /** @hidden */
  81472. _generateMipMaps: boolean;
  81473. /** @hidden **/
  81474. _effect: Effect;
  81475. /** @hidden */
  81476. _textures: {
  81477. [key: string]: Texture;
  81478. };
  81479. private _size;
  81480. private _currentRefreshId;
  81481. private _refreshRate;
  81482. private _vertexBuffers;
  81483. private _indexBuffer;
  81484. private _uniforms;
  81485. private _samplers;
  81486. private _fragment;
  81487. private _floats;
  81488. private _ints;
  81489. private _floatsArrays;
  81490. private _colors3;
  81491. private _colors4;
  81492. private _vectors2;
  81493. private _vectors3;
  81494. private _matrices;
  81495. private _fallbackTexture;
  81496. private _fallbackTextureUsed;
  81497. private _engine;
  81498. private _cachedDefines;
  81499. private _contentUpdateId;
  81500. private _contentData;
  81501. /**
  81502. * Instantiates a new procedural texture.
  81503. * 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.
  81504. * This is the base class of any Procedural texture and contains most of the shareable code.
  81505. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81506. * @param name Define the name of the texture
  81507. * @param size Define the size of the texture to create
  81508. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81509. * @param scene Define the scene the texture belongs to
  81510. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81511. * @param generateMipMaps Define if the texture should creates mip maps or not
  81512. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81513. */
  81514. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81515. /**
  81516. * The effect that is created when initializing the post process.
  81517. * @returns The created effect corresponding the the postprocess.
  81518. */
  81519. getEffect(): Effect;
  81520. /**
  81521. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81522. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81523. */
  81524. getContent(): Nullable<ArrayBufferView>;
  81525. private _createIndexBuffer;
  81526. /** @hidden */
  81527. _rebuild(): void;
  81528. /**
  81529. * Resets the texture in order to recreate its associated resources.
  81530. * This can be called in case of context loss
  81531. */
  81532. reset(): void;
  81533. protected _getDefines(): string;
  81534. /**
  81535. * Is the texture ready to be used ? (rendered at least once)
  81536. * @returns true if ready, otherwise, false.
  81537. */
  81538. isReady(): boolean;
  81539. /**
  81540. * Resets the refresh counter of the texture and start bak from scratch.
  81541. * Could be useful to regenerate the texture if it is setup to render only once.
  81542. */
  81543. resetRefreshCounter(): void;
  81544. /**
  81545. * Set the fragment shader to use in order to render the texture.
  81546. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81547. */
  81548. setFragment(fragment: any): void;
  81549. /**
  81550. * Define the refresh rate of the texture or the rendering frequency.
  81551. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81552. */
  81553. refreshRate: number;
  81554. /** @hidden */
  81555. _shouldRender(): boolean;
  81556. /**
  81557. * Get the size the texture is rendering at.
  81558. * @returns the size (texture is always squared)
  81559. */
  81560. getRenderSize(): number;
  81561. /**
  81562. * Resize the texture to new value.
  81563. * @param size Define the new size the texture should have
  81564. * @param generateMipMaps Define whether the new texture should create mip maps
  81565. */
  81566. resize(size: number, generateMipMaps: boolean): void;
  81567. private _checkUniform;
  81568. /**
  81569. * Set a texture in the shader program used to render.
  81570. * @param name Define the name of the uniform samplers as defined in the shader
  81571. * @param texture Define the texture to bind to this sampler
  81572. * @return the texture itself allowing "fluent" like uniform updates
  81573. */
  81574. setTexture(name: string, texture: Texture): ProceduralTexture;
  81575. /**
  81576. * Set a float in the shader.
  81577. * @param name Define the name of the uniform as defined in the shader
  81578. * @param value Define the value to give to the uniform
  81579. * @return the texture itself allowing "fluent" like uniform updates
  81580. */
  81581. setFloat(name: string, value: number): ProceduralTexture;
  81582. /**
  81583. * Set a int in the shader.
  81584. * @param name Define the name of the uniform as defined in the shader
  81585. * @param value Define the value to give to the uniform
  81586. * @return the texture itself allowing "fluent" like uniform updates
  81587. */
  81588. setInt(name: string, value: number): ProceduralTexture;
  81589. /**
  81590. * Set an array of floats in the shader.
  81591. * @param name Define the name of the uniform as defined in the shader
  81592. * @param value Define the value to give to the uniform
  81593. * @return the texture itself allowing "fluent" like uniform updates
  81594. */
  81595. setFloats(name: string, value: number[]): ProceduralTexture;
  81596. /**
  81597. * Set a vec3 in the shader from a Color3.
  81598. * @param name Define the name of the uniform as defined in the shader
  81599. * @param value Define the value to give to the uniform
  81600. * @return the texture itself allowing "fluent" like uniform updates
  81601. */
  81602. setColor3(name: string, value: Color3): ProceduralTexture;
  81603. /**
  81604. * Set a vec4 in the shader from a Color4.
  81605. * @param name Define the name of the uniform as defined in the shader
  81606. * @param value Define the value to give to the uniform
  81607. * @return the texture itself allowing "fluent" like uniform updates
  81608. */
  81609. setColor4(name: string, value: Color4): ProceduralTexture;
  81610. /**
  81611. * Set a vec2 in the shader from a Vector2.
  81612. * @param name Define the name of the uniform as defined in the shader
  81613. * @param value Define the value to give to the uniform
  81614. * @return the texture itself allowing "fluent" like uniform updates
  81615. */
  81616. setVector2(name: string, value: Vector2): ProceduralTexture;
  81617. /**
  81618. * Set a vec3 in the shader from a Vector3.
  81619. * @param name Define the name of the uniform as defined in the shader
  81620. * @param value Define the value to give to the uniform
  81621. * @return the texture itself allowing "fluent" like uniform updates
  81622. */
  81623. setVector3(name: string, value: Vector3): ProceduralTexture;
  81624. /**
  81625. * Set a mat4 in the shader from a MAtrix.
  81626. * @param name Define the name of the uniform as defined in the shader
  81627. * @param value Define the value to give to the uniform
  81628. * @return the texture itself allowing "fluent" like uniform updates
  81629. */
  81630. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81631. /**
  81632. * Render the texture to its associated render target.
  81633. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81634. */
  81635. render(useCameraPostProcess?: boolean): void;
  81636. /**
  81637. * Clone the texture.
  81638. * @returns the cloned texture
  81639. */
  81640. clone(): ProceduralTexture;
  81641. /**
  81642. * Dispose the texture and release its asoociated resources.
  81643. */
  81644. dispose(): void;
  81645. }
  81646. }
  81647. declare module BABYLON {
  81648. /**
  81649. * This represents the base class for particle system in Babylon.
  81650. * 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.
  81651. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81652. * @example https://doc.babylonjs.com/babylon101/particles
  81653. */
  81654. export class BaseParticleSystem {
  81655. /**
  81656. * Source color is added to the destination color without alpha affecting the result
  81657. */
  81658. static BLENDMODE_ONEONE: number;
  81659. /**
  81660. * Blend current color and particle color using particle’s alpha
  81661. */
  81662. static BLENDMODE_STANDARD: number;
  81663. /**
  81664. * Add current color and particle color multiplied by particle’s alpha
  81665. */
  81666. static BLENDMODE_ADD: number;
  81667. /**
  81668. * Multiply current color with particle color
  81669. */
  81670. static BLENDMODE_MULTIPLY: number;
  81671. /**
  81672. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81673. */
  81674. static BLENDMODE_MULTIPLYADD: number;
  81675. /**
  81676. * List of animations used by the particle system.
  81677. */
  81678. animations: Animation[];
  81679. /**
  81680. * The id of the Particle system.
  81681. */
  81682. id: string;
  81683. /**
  81684. * The friendly name of the Particle system.
  81685. */
  81686. name: string;
  81687. /**
  81688. * The rendering group used by the Particle system to chose when to render.
  81689. */
  81690. renderingGroupId: number;
  81691. /**
  81692. * The emitter represents the Mesh or position we are attaching the particle system to.
  81693. */
  81694. emitter: Nullable<AbstractMesh | Vector3>;
  81695. /**
  81696. * The maximum number of particles to emit per frame
  81697. */
  81698. emitRate: number;
  81699. /**
  81700. * If you want to launch only a few particles at once, that can be done, as well.
  81701. */
  81702. manualEmitCount: number;
  81703. /**
  81704. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81705. */
  81706. updateSpeed: number;
  81707. /**
  81708. * The amount of time the particle system is running (depends of the overall update speed).
  81709. */
  81710. targetStopDuration: number;
  81711. /**
  81712. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81713. */
  81714. disposeOnStop: boolean;
  81715. /**
  81716. * Minimum power of emitting particles.
  81717. */
  81718. minEmitPower: number;
  81719. /**
  81720. * Maximum power of emitting particles.
  81721. */
  81722. maxEmitPower: number;
  81723. /**
  81724. * Minimum life time of emitting particles.
  81725. */
  81726. minLifeTime: number;
  81727. /**
  81728. * Maximum life time of emitting particles.
  81729. */
  81730. maxLifeTime: number;
  81731. /**
  81732. * Minimum Size of emitting particles.
  81733. */
  81734. minSize: number;
  81735. /**
  81736. * Maximum Size of emitting particles.
  81737. */
  81738. maxSize: number;
  81739. /**
  81740. * Minimum scale of emitting particles on X axis.
  81741. */
  81742. minScaleX: number;
  81743. /**
  81744. * Maximum scale of emitting particles on X axis.
  81745. */
  81746. maxScaleX: number;
  81747. /**
  81748. * Minimum scale of emitting particles on Y axis.
  81749. */
  81750. minScaleY: number;
  81751. /**
  81752. * Maximum scale of emitting particles on Y axis.
  81753. */
  81754. maxScaleY: number;
  81755. /**
  81756. * Gets or sets the minimal initial rotation in radians.
  81757. */
  81758. minInitialRotation: number;
  81759. /**
  81760. * Gets or sets the maximal initial rotation in radians.
  81761. */
  81762. maxInitialRotation: number;
  81763. /**
  81764. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81765. */
  81766. minAngularSpeed: number;
  81767. /**
  81768. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81769. */
  81770. maxAngularSpeed: number;
  81771. /**
  81772. * The texture used to render each particle. (this can be a spritesheet)
  81773. */
  81774. particleTexture: Nullable<Texture>;
  81775. /**
  81776. * The layer mask we are rendering the particles through.
  81777. */
  81778. layerMask: number;
  81779. /**
  81780. * This can help using your own shader to render the particle system.
  81781. * The according effect will be created
  81782. */
  81783. customShader: any;
  81784. /**
  81785. * By default particle system starts as soon as they are created. This prevents the
  81786. * automatic start to happen and let you decide when to start emitting particles.
  81787. */
  81788. preventAutoStart: boolean;
  81789. private _noiseTexture;
  81790. /**
  81791. * Gets or sets a texture used to add random noise to particle positions
  81792. */
  81793. noiseTexture: Nullable<ProceduralTexture>;
  81794. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81795. noiseStrength: Vector3;
  81796. /**
  81797. * Callback triggered when the particle animation is ending.
  81798. */
  81799. onAnimationEnd: Nullable<() => void>;
  81800. /**
  81801. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81802. */
  81803. blendMode: number;
  81804. /**
  81805. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81806. * to override the particles.
  81807. */
  81808. forceDepthWrite: boolean;
  81809. /** 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 */
  81810. preWarmCycles: number;
  81811. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81812. preWarmStepOffset: number;
  81813. /**
  81814. * 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)
  81815. */
  81816. spriteCellChangeSpeed: number;
  81817. /**
  81818. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81819. */
  81820. startSpriteCellID: number;
  81821. /**
  81822. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81823. */
  81824. endSpriteCellID: number;
  81825. /**
  81826. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81827. */
  81828. spriteCellWidth: number;
  81829. /**
  81830. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81831. */
  81832. spriteCellHeight: number;
  81833. /**
  81834. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81835. */
  81836. spriteRandomStartCell: boolean;
  81837. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81838. translationPivot: Vector2;
  81839. /** @hidden */
  81840. protected _isAnimationSheetEnabled: boolean;
  81841. /**
  81842. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81843. */
  81844. beginAnimationOnStart: boolean;
  81845. /**
  81846. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81847. */
  81848. beginAnimationFrom: number;
  81849. /**
  81850. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81851. */
  81852. beginAnimationTo: number;
  81853. /**
  81854. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81855. */
  81856. beginAnimationLoop: boolean;
  81857. /**
  81858. * Gets or sets a world offset applied to all particles
  81859. */
  81860. worldOffset: Vector3;
  81861. /**
  81862. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81863. */
  81864. isAnimationSheetEnabled: boolean;
  81865. /**
  81866. * Get hosting scene
  81867. * @returns the scene
  81868. */
  81869. getScene(): Scene;
  81870. /**
  81871. * You can use gravity if you want to give an orientation to your particles.
  81872. */
  81873. gravity: Vector3;
  81874. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81875. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81876. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81877. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81878. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81879. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81880. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81881. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81882. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81883. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81884. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81885. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81886. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81887. /**
  81888. * Defines the delay in milliseconds before starting the system (0 by default)
  81889. */
  81890. startDelay: number;
  81891. /**
  81892. * Gets the current list of drag gradients.
  81893. * You must use addDragGradient and removeDragGradient to udpate this list
  81894. * @returns the list of drag gradients
  81895. */
  81896. getDragGradients(): Nullable<Array<FactorGradient>>;
  81897. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81898. limitVelocityDamping: number;
  81899. /**
  81900. * Gets the current list of limit velocity gradients.
  81901. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81902. * @returns the list of limit velocity gradients
  81903. */
  81904. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81905. /**
  81906. * Gets the current list of color gradients.
  81907. * You must use addColorGradient and removeColorGradient to udpate this list
  81908. * @returns the list of color gradients
  81909. */
  81910. getColorGradients(): Nullable<Array<ColorGradient>>;
  81911. /**
  81912. * Gets the current list of size gradients.
  81913. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81914. * @returns the list of size gradients
  81915. */
  81916. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81917. /**
  81918. * Gets the current list of color remap gradients.
  81919. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81920. * @returns the list of color remap gradients
  81921. */
  81922. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81923. /**
  81924. * Gets the current list of alpha remap gradients.
  81925. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81926. * @returns the list of alpha remap gradients
  81927. */
  81928. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81929. /**
  81930. * Gets the current list of life time gradients.
  81931. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81932. * @returns the list of life time gradients
  81933. */
  81934. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81935. /**
  81936. * Gets the current list of angular speed gradients.
  81937. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81938. * @returns the list of angular speed gradients
  81939. */
  81940. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81941. /**
  81942. * Gets the current list of velocity gradients.
  81943. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81944. * @returns the list of velocity gradients
  81945. */
  81946. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81947. /**
  81948. * Gets the current list of start size gradients.
  81949. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81950. * @returns the list of start size gradients
  81951. */
  81952. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81953. /**
  81954. * Gets the current list of emit rate gradients.
  81955. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81956. * @returns the list of emit rate gradients
  81957. */
  81958. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81959. /**
  81960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81961. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81962. */
  81963. direction1: Vector3;
  81964. /**
  81965. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81966. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81967. */
  81968. direction2: Vector3;
  81969. /**
  81970. * 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.
  81971. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81972. */
  81973. minEmitBox: Vector3;
  81974. /**
  81975. * 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.
  81976. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81977. */
  81978. maxEmitBox: Vector3;
  81979. /**
  81980. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81981. */
  81982. color1: Color4;
  81983. /**
  81984. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81985. */
  81986. color2: Color4;
  81987. /**
  81988. * Color the particle will have at the end of its lifetime
  81989. */
  81990. colorDead: Color4;
  81991. /**
  81992. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81993. */
  81994. textureMask: Color4;
  81995. /**
  81996. * The particle emitter type defines the emitter used by the particle system.
  81997. * It can be for example box, sphere, or cone...
  81998. */
  81999. particleEmitterType: IParticleEmitterType;
  82000. /** @hidden */
  82001. _isSubEmitter: boolean;
  82002. /**
  82003. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82004. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82005. */
  82006. billboardMode: number;
  82007. protected _isBillboardBased: boolean;
  82008. /**
  82009. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82010. */
  82011. isBillboardBased: boolean;
  82012. /**
  82013. * The scene the particle system belongs to.
  82014. */
  82015. protected _scene: Scene;
  82016. /**
  82017. * Local cache of defines for image processing.
  82018. */
  82019. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82020. /**
  82021. * Default configuration related to image processing available in the standard Material.
  82022. */
  82023. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82024. /**
  82025. * Gets the image processing configuration used either in this material.
  82026. */
  82027. /**
  82028. * Sets the Default image processing configuration used either in the this material.
  82029. *
  82030. * If sets to null, the scene one is in use.
  82031. */
  82032. imageProcessingConfiguration: ImageProcessingConfiguration;
  82033. /**
  82034. * Attaches a new image processing configuration to the Standard Material.
  82035. * @param configuration
  82036. */
  82037. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82038. /** @hidden */
  82039. protected _reset(): void;
  82040. /** @hidden */
  82041. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82042. /**
  82043. * Instantiates a particle system.
  82044. * 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.
  82045. * @param name The name of the particle system
  82046. */
  82047. constructor(name: string);
  82048. /**
  82049. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82050. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82051. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82052. * @returns the emitter
  82053. */
  82054. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82055. /**
  82056. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82057. * @param radius The radius of the hemisphere to emit from
  82058. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82059. * @returns the emitter
  82060. */
  82061. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82062. /**
  82063. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82064. * @param radius The radius of the sphere to emit from
  82065. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82066. * @returns the emitter
  82067. */
  82068. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82069. /**
  82070. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82071. * @param radius The radius of the sphere to emit from
  82072. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82073. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82074. * @returns the emitter
  82075. */
  82076. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82077. /**
  82078. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82079. * @param radius The radius of the emission cylinder
  82080. * @param height The height of the emission cylinder
  82081. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82082. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82083. * @returns the emitter
  82084. */
  82085. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82086. /**
  82087. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82088. * @param radius The radius of the cylinder to emit from
  82089. * @param height The height of the emission cylinder
  82090. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82091. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82092. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82093. * @returns the emitter
  82094. */
  82095. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82096. /**
  82097. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82098. * @param radius The radius of the cone to emit from
  82099. * @param angle The base angle of the cone
  82100. * @returns the emitter
  82101. */
  82102. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82103. /**
  82104. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82105. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82106. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82107. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82108. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82109. * @returns the emitter
  82110. */
  82111. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82112. }
  82113. }
  82114. declare module BABYLON {
  82115. /**
  82116. * Type of sub emitter
  82117. */
  82118. export enum SubEmitterType {
  82119. /**
  82120. * Attached to the particle over it's lifetime
  82121. */
  82122. ATTACHED = 0,
  82123. /**
  82124. * Created when the particle dies
  82125. */
  82126. END = 1
  82127. }
  82128. /**
  82129. * Sub emitter class used to emit particles from an existing particle
  82130. */
  82131. export class SubEmitter {
  82132. /**
  82133. * the particle system to be used by the sub emitter
  82134. */
  82135. particleSystem: ParticleSystem;
  82136. /**
  82137. * Type of the submitter (Default: END)
  82138. */
  82139. type: SubEmitterType;
  82140. /**
  82141. * 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)
  82142. * Note: This only is supported when using an emitter of type Mesh
  82143. */
  82144. inheritDirection: boolean;
  82145. /**
  82146. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82147. */
  82148. inheritedVelocityAmount: number;
  82149. /**
  82150. * Creates a sub emitter
  82151. * @param particleSystem the particle system to be used by the sub emitter
  82152. */
  82153. constructor(
  82154. /**
  82155. * the particle system to be used by the sub emitter
  82156. */
  82157. particleSystem: ParticleSystem);
  82158. /**
  82159. * Clones the sub emitter
  82160. * @returns the cloned sub emitter
  82161. */
  82162. clone(): SubEmitter;
  82163. /**
  82164. * Serialize current object to a JSON object
  82165. * @returns the serialized object
  82166. */
  82167. serialize(): any;
  82168. /** @hidden */
  82169. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82170. /**
  82171. * Creates a new SubEmitter from a serialized JSON version
  82172. * @param serializationObject defines the JSON object to read from
  82173. * @param scene defines the hosting scene
  82174. * @param rootUrl defines the rootUrl for data loading
  82175. * @returns a new SubEmitter
  82176. */
  82177. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82178. /** Release associated resources */
  82179. dispose(): void;
  82180. }
  82181. }
  82182. declare module BABYLON {
  82183. /** @hidden */
  82184. export var imageProcessingDeclaration: {
  82185. name: string;
  82186. shader: string;
  82187. };
  82188. }
  82189. declare module BABYLON {
  82190. /** @hidden */
  82191. export var imageProcessingFunctions: {
  82192. name: string;
  82193. shader: string;
  82194. };
  82195. }
  82196. declare module BABYLON {
  82197. /** @hidden */
  82198. export var particlesPixelShader: {
  82199. name: string;
  82200. shader: string;
  82201. };
  82202. }
  82203. declare module BABYLON {
  82204. /** @hidden */
  82205. export var particlesVertexShader: {
  82206. name: string;
  82207. shader: string;
  82208. };
  82209. }
  82210. declare module BABYLON {
  82211. /**
  82212. * This represents a particle system in Babylon.
  82213. * 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.
  82214. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82215. * @example https://doc.babylonjs.com/babylon101/particles
  82216. */
  82217. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82218. /**
  82219. * Billboard mode will only apply to Y axis
  82220. */
  82221. static readonly BILLBOARDMODE_Y: number;
  82222. /**
  82223. * Billboard mode will apply to all axes
  82224. */
  82225. static readonly BILLBOARDMODE_ALL: number;
  82226. /**
  82227. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82228. */
  82229. static readonly BILLBOARDMODE_STRETCHED: number;
  82230. /**
  82231. * This function can be defined to provide custom update for active particles.
  82232. * This function will be called instead of regular update (age, position, color, etc.).
  82233. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82234. */
  82235. updateFunction: (particles: Particle[]) => void;
  82236. private _emitterWorldMatrix;
  82237. /**
  82238. * This function can be defined to specify initial direction for every new particle.
  82239. * It by default use the emitterType defined function
  82240. */
  82241. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82242. /**
  82243. * This function can be defined to specify initial position for every new particle.
  82244. * It by default use the emitterType defined function
  82245. */
  82246. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82247. /**
  82248. * @hidden
  82249. */
  82250. _inheritedVelocityOffset: Vector3;
  82251. /**
  82252. * An event triggered when the system is disposed
  82253. */
  82254. onDisposeObservable: Observable<ParticleSystem>;
  82255. private _onDisposeObserver;
  82256. /**
  82257. * Sets a callback that will be triggered when the system is disposed
  82258. */
  82259. onDispose: () => void;
  82260. private _particles;
  82261. private _epsilon;
  82262. private _capacity;
  82263. private _stockParticles;
  82264. private _newPartsExcess;
  82265. private _vertexData;
  82266. private _vertexBuffer;
  82267. private _vertexBuffers;
  82268. private _spriteBuffer;
  82269. private _indexBuffer;
  82270. private _effect;
  82271. private _customEffect;
  82272. private _cachedDefines;
  82273. private _scaledColorStep;
  82274. private _colorDiff;
  82275. private _scaledDirection;
  82276. private _scaledGravity;
  82277. private _currentRenderId;
  82278. private _alive;
  82279. private _useInstancing;
  82280. private _started;
  82281. private _stopped;
  82282. private _actualFrame;
  82283. private _scaledUpdateSpeed;
  82284. private _vertexBufferSize;
  82285. /** @hidden */
  82286. _currentEmitRateGradient: Nullable<FactorGradient>;
  82287. /** @hidden */
  82288. _currentEmitRate1: number;
  82289. /** @hidden */
  82290. _currentEmitRate2: number;
  82291. /** @hidden */
  82292. _currentStartSizeGradient: Nullable<FactorGradient>;
  82293. /** @hidden */
  82294. _currentStartSize1: number;
  82295. /** @hidden */
  82296. _currentStartSize2: number;
  82297. private readonly _rawTextureWidth;
  82298. private _rampGradientsTexture;
  82299. private _useRampGradients;
  82300. /** Gets or sets a boolean indicating that ramp gradients must be used
  82301. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82302. */
  82303. useRampGradients: boolean;
  82304. /**
  82305. * 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.
  82306. * 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: [])
  82307. */
  82308. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82309. private _subEmitters;
  82310. /**
  82311. * @hidden
  82312. * If the particle systems emitter should be disposed when the particle system is disposed
  82313. */
  82314. _disposeEmitterOnDispose: boolean;
  82315. /**
  82316. * The current active Sub-systems, this property is used by the root particle system only.
  82317. */
  82318. activeSubSystems: Array<ParticleSystem>;
  82319. private _rootParticleSystem;
  82320. /**
  82321. * Gets the current list of active particles
  82322. */
  82323. readonly particles: Particle[];
  82324. /**
  82325. * Returns the string "ParticleSystem"
  82326. * @returns a string containing the class name
  82327. */
  82328. getClassName(): string;
  82329. /**
  82330. * Instantiates a particle system.
  82331. * 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.
  82332. * @param name The name of the particle system
  82333. * @param capacity The max number of particles alive at the same time
  82334. * @param scene The scene the particle system belongs to
  82335. * @param customEffect a custom effect used to change the way particles are rendered by default
  82336. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82337. * @param epsilon Offset used to render the particles
  82338. */
  82339. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82340. private _addFactorGradient;
  82341. private _removeFactorGradient;
  82342. /**
  82343. * Adds a new life time gradient
  82344. * @param gradient defines the gradient to use (between 0 and 1)
  82345. * @param factor defines the life time factor to affect to the specified gradient
  82346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82347. * @returns the current particle system
  82348. */
  82349. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82350. /**
  82351. * Remove a specific life time gradient
  82352. * @param gradient defines the gradient to remove
  82353. * @returns the current particle system
  82354. */
  82355. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82356. /**
  82357. * Adds a new size gradient
  82358. * @param gradient defines the gradient to use (between 0 and 1)
  82359. * @param factor defines the size factor to affect to the specified gradient
  82360. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82361. * @returns the current particle system
  82362. */
  82363. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82364. /**
  82365. * Remove a specific size gradient
  82366. * @param gradient defines the gradient to remove
  82367. * @returns the current particle system
  82368. */
  82369. removeSizeGradient(gradient: number): IParticleSystem;
  82370. /**
  82371. * Adds a new color remap gradient
  82372. * @param gradient defines the gradient to use (between 0 and 1)
  82373. * @param min defines the color remap minimal range
  82374. * @param max defines the color remap maximal range
  82375. * @returns the current particle system
  82376. */
  82377. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82378. /**
  82379. * Remove a specific color remap gradient
  82380. * @param gradient defines the gradient to remove
  82381. * @returns the current particle system
  82382. */
  82383. removeColorRemapGradient(gradient: number): IParticleSystem;
  82384. /**
  82385. * Adds a new alpha remap gradient
  82386. * @param gradient defines the gradient to use (between 0 and 1)
  82387. * @param min defines the alpha remap minimal range
  82388. * @param max defines the alpha remap maximal range
  82389. * @returns the current particle system
  82390. */
  82391. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82392. /**
  82393. * Remove a specific alpha remap gradient
  82394. * @param gradient defines the gradient to remove
  82395. * @returns the current particle system
  82396. */
  82397. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82398. /**
  82399. * Adds a new angular speed gradient
  82400. * @param gradient defines the gradient to use (between 0 and 1)
  82401. * @param factor defines the angular speed to affect to the specified gradient
  82402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82403. * @returns the current particle system
  82404. */
  82405. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82406. /**
  82407. * Remove a specific angular speed gradient
  82408. * @param gradient defines the gradient to remove
  82409. * @returns the current particle system
  82410. */
  82411. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82412. /**
  82413. * Adds a new velocity gradient
  82414. * @param gradient defines the gradient to use (between 0 and 1)
  82415. * @param factor defines the velocity to affect to the specified gradient
  82416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82417. * @returns the current particle system
  82418. */
  82419. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82420. /**
  82421. * Remove a specific velocity gradient
  82422. * @param gradient defines the gradient to remove
  82423. * @returns the current particle system
  82424. */
  82425. removeVelocityGradient(gradient: number): IParticleSystem;
  82426. /**
  82427. * Adds a new limit velocity gradient
  82428. * @param gradient defines the gradient to use (between 0 and 1)
  82429. * @param factor defines the limit velocity value to affect to the specified gradient
  82430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82431. * @returns the current particle system
  82432. */
  82433. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82434. /**
  82435. * Remove a specific limit velocity gradient
  82436. * @param gradient defines the gradient to remove
  82437. * @returns the current particle system
  82438. */
  82439. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82440. /**
  82441. * Adds a new drag gradient
  82442. * @param gradient defines the gradient to use (between 0 and 1)
  82443. * @param factor defines the drag value to affect to the specified gradient
  82444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82445. * @returns the current particle system
  82446. */
  82447. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82448. /**
  82449. * Remove a specific drag gradient
  82450. * @param gradient defines the gradient to remove
  82451. * @returns the current particle system
  82452. */
  82453. removeDragGradient(gradient: number): IParticleSystem;
  82454. /**
  82455. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82456. * @param gradient defines the gradient to use (between 0 and 1)
  82457. * @param factor defines the emit rate value to affect to the specified gradient
  82458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82459. * @returns the current particle system
  82460. */
  82461. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82462. /**
  82463. * Remove a specific emit rate gradient
  82464. * @param gradient defines the gradient to remove
  82465. * @returns the current particle system
  82466. */
  82467. removeEmitRateGradient(gradient: number): IParticleSystem;
  82468. /**
  82469. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82470. * @param gradient defines the gradient to use (between 0 and 1)
  82471. * @param factor defines the start size value to affect to the specified gradient
  82472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82473. * @returns the current particle system
  82474. */
  82475. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82476. /**
  82477. * Remove a specific start size gradient
  82478. * @param gradient defines the gradient to remove
  82479. * @returns the current particle system
  82480. */
  82481. removeStartSizeGradient(gradient: number): IParticleSystem;
  82482. private _createRampGradientTexture;
  82483. /**
  82484. * Gets the current list of ramp gradients.
  82485. * You must use addRampGradient and removeRampGradient to udpate this list
  82486. * @returns the list of ramp gradients
  82487. */
  82488. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82489. /**
  82490. * Adds a new ramp gradient used to remap particle colors
  82491. * @param gradient defines the gradient to use (between 0 and 1)
  82492. * @param color defines the color to affect to the specified gradient
  82493. * @returns the current particle system
  82494. */
  82495. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82496. /**
  82497. * Remove a specific ramp gradient
  82498. * @param gradient defines the gradient to remove
  82499. * @returns the current particle system
  82500. */
  82501. removeRampGradient(gradient: number): ParticleSystem;
  82502. /**
  82503. * Adds a new color gradient
  82504. * @param gradient defines the gradient to use (between 0 and 1)
  82505. * @param color1 defines the color to affect to the specified gradient
  82506. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82507. * @returns this particle system
  82508. */
  82509. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82510. /**
  82511. * Remove a specific color gradient
  82512. * @param gradient defines the gradient to remove
  82513. * @returns this particle system
  82514. */
  82515. removeColorGradient(gradient: number): IParticleSystem;
  82516. private _fetchR;
  82517. protected _reset(): void;
  82518. private _resetEffect;
  82519. private _createVertexBuffers;
  82520. private _createIndexBuffer;
  82521. /**
  82522. * Gets the maximum number of particles active at the same time.
  82523. * @returns The max number of active particles.
  82524. */
  82525. getCapacity(): number;
  82526. /**
  82527. * Gets whether there are still active particles in the system.
  82528. * @returns True if it is alive, otherwise false.
  82529. */
  82530. isAlive(): boolean;
  82531. /**
  82532. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82533. * @returns True if it has been started, otherwise false.
  82534. */
  82535. isStarted(): boolean;
  82536. private _prepareSubEmitterInternalArray;
  82537. /**
  82538. * Starts the particle system and begins to emit
  82539. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82540. */
  82541. start(delay?: number): void;
  82542. /**
  82543. * Stops the particle system.
  82544. * @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.
  82545. */
  82546. stop(stopSubEmitters?: boolean): void;
  82547. /**
  82548. * Remove all active particles
  82549. */
  82550. reset(): void;
  82551. /**
  82552. * @hidden (for internal use only)
  82553. */
  82554. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82555. /**
  82556. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82557. * Its lifetime will start back at 0.
  82558. */
  82559. recycleParticle: (particle: Particle) => void;
  82560. private _stopSubEmitters;
  82561. private _createParticle;
  82562. private _removeFromRoot;
  82563. private _emitFromParticle;
  82564. private _update;
  82565. /** @hidden */
  82566. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82567. /** @hidden */
  82568. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82569. /** @hidden */
  82570. private _getEffect;
  82571. /**
  82572. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82573. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82574. */
  82575. animate(preWarmOnly?: boolean): void;
  82576. private _appendParticleVertices;
  82577. /**
  82578. * Rebuilds the particle system.
  82579. */
  82580. rebuild(): void;
  82581. /**
  82582. * Is this system ready to be used/rendered
  82583. * @return true if the system is ready
  82584. */
  82585. isReady(): boolean;
  82586. private _render;
  82587. /**
  82588. * Renders the particle system in its current state.
  82589. * @returns the current number of particles
  82590. */
  82591. render(): number;
  82592. /**
  82593. * Disposes the particle system and free the associated resources
  82594. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82595. */
  82596. dispose(disposeTexture?: boolean): void;
  82597. /**
  82598. * Clones the particle system.
  82599. * @param name The name of the cloned object
  82600. * @param newEmitter The new emitter to use
  82601. * @returns the cloned particle system
  82602. */
  82603. clone(name: string, newEmitter: any): ParticleSystem;
  82604. /**
  82605. * Serializes the particle system to a JSON object.
  82606. * @returns the JSON object
  82607. */
  82608. serialize(): any;
  82609. /** @hidden */
  82610. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82611. /** @hidden */
  82612. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82613. /**
  82614. * Parses a JSON object to create a particle system.
  82615. * @param parsedParticleSystem The JSON object to parse
  82616. * @param scene The scene to create the particle system in
  82617. * @param rootUrl The root url to use to load external dependencies like texture
  82618. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82619. * @returns the Parsed particle system
  82620. */
  82621. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82622. }
  82623. }
  82624. declare module BABYLON {
  82625. /**
  82626. * A particle represents one of the element emitted by a particle system.
  82627. * This is mainly define by its coordinates, direction, velocity and age.
  82628. */
  82629. export class Particle {
  82630. /**
  82631. * The particle system the particle belongs to.
  82632. */
  82633. particleSystem: ParticleSystem;
  82634. private static _Count;
  82635. /**
  82636. * Unique ID of the particle
  82637. */
  82638. id: number;
  82639. /**
  82640. * The world position of the particle in the scene.
  82641. */
  82642. position: Vector3;
  82643. /**
  82644. * The world direction of the particle in the scene.
  82645. */
  82646. direction: Vector3;
  82647. /**
  82648. * The color of the particle.
  82649. */
  82650. color: Color4;
  82651. /**
  82652. * The color change of the particle per step.
  82653. */
  82654. colorStep: Color4;
  82655. /**
  82656. * Defines how long will the life of the particle be.
  82657. */
  82658. lifeTime: number;
  82659. /**
  82660. * The current age of the particle.
  82661. */
  82662. age: number;
  82663. /**
  82664. * The current size of the particle.
  82665. */
  82666. size: number;
  82667. /**
  82668. * The current scale of the particle.
  82669. */
  82670. scale: Vector2;
  82671. /**
  82672. * The current angle of the particle.
  82673. */
  82674. angle: number;
  82675. /**
  82676. * Defines how fast is the angle changing.
  82677. */
  82678. angularSpeed: number;
  82679. /**
  82680. * Defines the cell index used by the particle to be rendered from a sprite.
  82681. */
  82682. cellIndex: number;
  82683. /**
  82684. * The information required to support color remapping
  82685. */
  82686. remapData: Vector4;
  82687. /** @hidden */
  82688. _randomCellOffset?: number;
  82689. /** @hidden */
  82690. _initialDirection: Nullable<Vector3>;
  82691. /** @hidden */
  82692. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82693. /** @hidden */
  82694. _initialStartSpriteCellID: number;
  82695. /** @hidden */
  82696. _initialEndSpriteCellID: number;
  82697. /** @hidden */
  82698. _currentColorGradient: Nullable<ColorGradient>;
  82699. /** @hidden */
  82700. _currentColor1: Color4;
  82701. /** @hidden */
  82702. _currentColor2: Color4;
  82703. /** @hidden */
  82704. _currentSizeGradient: Nullable<FactorGradient>;
  82705. /** @hidden */
  82706. _currentSize1: number;
  82707. /** @hidden */
  82708. _currentSize2: number;
  82709. /** @hidden */
  82710. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82711. /** @hidden */
  82712. _currentAngularSpeed1: number;
  82713. /** @hidden */
  82714. _currentAngularSpeed2: number;
  82715. /** @hidden */
  82716. _currentVelocityGradient: Nullable<FactorGradient>;
  82717. /** @hidden */
  82718. _currentVelocity1: number;
  82719. /** @hidden */
  82720. _currentVelocity2: number;
  82721. /** @hidden */
  82722. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82723. /** @hidden */
  82724. _currentLimitVelocity1: number;
  82725. /** @hidden */
  82726. _currentLimitVelocity2: number;
  82727. /** @hidden */
  82728. _currentDragGradient: Nullable<FactorGradient>;
  82729. /** @hidden */
  82730. _currentDrag1: number;
  82731. /** @hidden */
  82732. _currentDrag2: number;
  82733. /** @hidden */
  82734. _randomNoiseCoordinates1: Vector3;
  82735. /** @hidden */
  82736. _randomNoiseCoordinates2: Vector3;
  82737. /**
  82738. * Creates a new instance Particle
  82739. * @param particleSystem the particle system the particle belongs to
  82740. */
  82741. constructor(
  82742. /**
  82743. * The particle system the particle belongs to.
  82744. */
  82745. particleSystem: ParticleSystem);
  82746. private updateCellInfoFromSystem;
  82747. /**
  82748. * Defines how the sprite cell index is updated for the particle
  82749. */
  82750. updateCellIndex(): void;
  82751. /** @hidden */
  82752. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82753. /** @hidden */
  82754. _inheritParticleInfoToSubEmitters(): void;
  82755. /** @hidden */
  82756. _reset(): void;
  82757. /**
  82758. * Copy the properties of particle to another one.
  82759. * @param other the particle to copy the information to.
  82760. */
  82761. copyTo(other: Particle): void;
  82762. }
  82763. }
  82764. declare module BABYLON {
  82765. /**
  82766. * Particle emitter represents a volume emitting particles.
  82767. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82768. */
  82769. export interface IParticleEmitterType {
  82770. /**
  82771. * Called by the particle System when the direction is computed for the created particle.
  82772. * @param worldMatrix is the world matrix of the particle system
  82773. * @param directionToUpdate is the direction vector to update with the result
  82774. * @param particle is the particle we are computed the direction for
  82775. */
  82776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82777. /**
  82778. * Called by the particle System when the position is computed for the created particle.
  82779. * @param worldMatrix is the world matrix of the particle system
  82780. * @param positionToUpdate is the position vector to update with the result
  82781. * @param particle is the particle we are computed the position for
  82782. */
  82783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82784. /**
  82785. * Clones the current emitter and returns a copy of it
  82786. * @returns the new emitter
  82787. */
  82788. clone(): IParticleEmitterType;
  82789. /**
  82790. * Called by the GPUParticleSystem to setup the update shader
  82791. * @param effect defines the update shader
  82792. */
  82793. applyToShader(effect: Effect): void;
  82794. /**
  82795. * Returns a string to use to update the GPU particles update shader
  82796. * @returns the effect defines string
  82797. */
  82798. getEffectDefines(): string;
  82799. /**
  82800. * Returns a string representing the class name
  82801. * @returns a string containing the class name
  82802. */
  82803. getClassName(): string;
  82804. /**
  82805. * Serializes the particle system to a JSON object.
  82806. * @returns the JSON object
  82807. */
  82808. serialize(): any;
  82809. /**
  82810. * Parse properties from a JSON object
  82811. * @param serializationObject defines the JSON object
  82812. */
  82813. parse(serializationObject: any): void;
  82814. }
  82815. }
  82816. declare module BABYLON {
  82817. /**
  82818. * Particle emitter emitting particles from the inside of a box.
  82819. * It emits the particles randomly between 2 given directions.
  82820. */
  82821. export class BoxParticleEmitter implements IParticleEmitterType {
  82822. /**
  82823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82824. */
  82825. direction1: Vector3;
  82826. /**
  82827. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82828. */
  82829. direction2: Vector3;
  82830. /**
  82831. * 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.
  82832. */
  82833. minEmitBox: Vector3;
  82834. /**
  82835. * 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.
  82836. */
  82837. maxEmitBox: Vector3;
  82838. /**
  82839. * Creates a new instance BoxParticleEmitter
  82840. */
  82841. constructor();
  82842. /**
  82843. * Called by the particle System when the direction is computed for the created particle.
  82844. * @param worldMatrix is the world matrix of the particle system
  82845. * @param directionToUpdate is the direction vector to update with the result
  82846. * @param particle is the particle we are computed the direction for
  82847. */
  82848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82849. /**
  82850. * Called by the particle System when the position is computed for the created particle.
  82851. * @param worldMatrix is the world matrix of the particle system
  82852. * @param positionToUpdate is the position vector to update with the result
  82853. * @param particle is the particle we are computed the position for
  82854. */
  82855. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82856. /**
  82857. * Clones the current emitter and returns a copy of it
  82858. * @returns the new emitter
  82859. */
  82860. clone(): BoxParticleEmitter;
  82861. /**
  82862. * Called by the GPUParticleSystem to setup the update shader
  82863. * @param effect defines the update shader
  82864. */
  82865. applyToShader(effect: Effect): void;
  82866. /**
  82867. * Returns a string to use to update the GPU particles update shader
  82868. * @returns a string containng the defines string
  82869. */
  82870. getEffectDefines(): string;
  82871. /**
  82872. * Returns the string "BoxParticleEmitter"
  82873. * @returns a string containing the class name
  82874. */
  82875. getClassName(): string;
  82876. /**
  82877. * Serializes the particle system to a JSON object.
  82878. * @returns the JSON object
  82879. */
  82880. serialize(): any;
  82881. /**
  82882. * Parse properties from a JSON object
  82883. * @param serializationObject defines the JSON object
  82884. */
  82885. parse(serializationObject: any): void;
  82886. }
  82887. }
  82888. declare module BABYLON {
  82889. /**
  82890. * Particle emitter emitting particles from the inside of a cone.
  82891. * It emits the particles alongside the cone volume from the base to the particle.
  82892. * The emission direction might be randomized.
  82893. */
  82894. export class ConeParticleEmitter implements IParticleEmitterType {
  82895. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82896. directionRandomizer: number;
  82897. private _radius;
  82898. private _angle;
  82899. private _height;
  82900. /**
  82901. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82902. */
  82903. radiusRange: number;
  82904. /**
  82905. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82906. */
  82907. heightRange: number;
  82908. /**
  82909. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82910. */
  82911. emitFromSpawnPointOnly: boolean;
  82912. /**
  82913. * Gets or sets the radius of the emission cone
  82914. */
  82915. radius: number;
  82916. /**
  82917. * Gets or sets the angle of the emission cone
  82918. */
  82919. angle: number;
  82920. private _buildHeight;
  82921. /**
  82922. * Creates a new instance ConeParticleEmitter
  82923. * @param radius the radius of the emission cone (1 by default)
  82924. * @param angle the cone base angle (PI by default)
  82925. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82926. */
  82927. constructor(radius?: number, angle?: number,
  82928. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82929. directionRandomizer?: number);
  82930. /**
  82931. * Called by the particle System when the direction is computed for the created particle.
  82932. * @param worldMatrix is the world matrix of the particle system
  82933. * @param directionToUpdate is the direction vector to update with the result
  82934. * @param particle is the particle we are computed the direction for
  82935. */
  82936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82937. /**
  82938. * Called by the particle System when the position is computed for the created particle.
  82939. * @param worldMatrix is the world matrix of the particle system
  82940. * @param positionToUpdate is the position vector to update with the result
  82941. * @param particle is the particle we are computed the position for
  82942. */
  82943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82944. /**
  82945. * Clones the current emitter and returns a copy of it
  82946. * @returns the new emitter
  82947. */
  82948. clone(): ConeParticleEmitter;
  82949. /**
  82950. * Called by the GPUParticleSystem to setup the update shader
  82951. * @param effect defines the update shader
  82952. */
  82953. applyToShader(effect: Effect): void;
  82954. /**
  82955. * Returns a string to use to update the GPU particles update shader
  82956. * @returns a string containng the defines string
  82957. */
  82958. getEffectDefines(): string;
  82959. /**
  82960. * Returns the string "ConeParticleEmitter"
  82961. * @returns a string containing the class name
  82962. */
  82963. getClassName(): string;
  82964. /**
  82965. * Serializes the particle system to a JSON object.
  82966. * @returns the JSON object
  82967. */
  82968. serialize(): any;
  82969. /**
  82970. * Parse properties from a JSON object
  82971. * @param serializationObject defines the JSON object
  82972. */
  82973. parse(serializationObject: any): void;
  82974. }
  82975. }
  82976. declare module BABYLON {
  82977. /**
  82978. * Particle emitter emitting particles from the inside of a cylinder.
  82979. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82980. */
  82981. export class CylinderParticleEmitter implements IParticleEmitterType {
  82982. /**
  82983. * The radius of the emission cylinder.
  82984. */
  82985. radius: number;
  82986. /**
  82987. * The height of the emission cylinder.
  82988. */
  82989. height: number;
  82990. /**
  82991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82992. */
  82993. radiusRange: number;
  82994. /**
  82995. * How much to randomize the particle direction [0-1].
  82996. */
  82997. directionRandomizer: number;
  82998. /**
  82999. * Creates a new instance CylinderParticleEmitter
  83000. * @param radius the radius of the emission cylinder (1 by default)
  83001. * @param height the height of the emission cylinder (1 by default)
  83002. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83003. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83004. */
  83005. constructor(
  83006. /**
  83007. * The radius of the emission cylinder.
  83008. */
  83009. radius?: number,
  83010. /**
  83011. * The height of the emission cylinder.
  83012. */
  83013. height?: number,
  83014. /**
  83015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83016. */
  83017. radiusRange?: number,
  83018. /**
  83019. * How much to randomize the particle direction [0-1].
  83020. */
  83021. directionRandomizer?: number);
  83022. /**
  83023. * Called by the particle System when the direction is computed for the created particle.
  83024. * @param worldMatrix is the world matrix of the particle system
  83025. * @param directionToUpdate is the direction vector to update with the result
  83026. * @param particle is the particle we are computed the direction for
  83027. */
  83028. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83029. /**
  83030. * Called by the particle System when the position is computed for the created particle.
  83031. * @param worldMatrix is the world matrix of the particle system
  83032. * @param positionToUpdate is the position vector to update with the result
  83033. * @param particle is the particle we are computed the position for
  83034. */
  83035. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83036. /**
  83037. * Clones the current emitter and returns a copy of it
  83038. * @returns the new emitter
  83039. */
  83040. clone(): CylinderParticleEmitter;
  83041. /**
  83042. * Called by the GPUParticleSystem to setup the update shader
  83043. * @param effect defines the update shader
  83044. */
  83045. applyToShader(effect: Effect): void;
  83046. /**
  83047. * Returns a string to use to update the GPU particles update shader
  83048. * @returns a string containng the defines string
  83049. */
  83050. getEffectDefines(): string;
  83051. /**
  83052. * Returns the string "CylinderParticleEmitter"
  83053. * @returns a string containing the class name
  83054. */
  83055. getClassName(): string;
  83056. /**
  83057. * Serializes the particle system to a JSON object.
  83058. * @returns the JSON object
  83059. */
  83060. serialize(): any;
  83061. /**
  83062. * Parse properties from a JSON object
  83063. * @param serializationObject defines the JSON object
  83064. */
  83065. parse(serializationObject: any): void;
  83066. }
  83067. /**
  83068. * Particle emitter emitting particles from the inside of a cylinder.
  83069. * It emits the particles randomly between two vectors.
  83070. */
  83071. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83072. /**
  83073. * The min limit of the emission direction.
  83074. */
  83075. direction1: Vector3;
  83076. /**
  83077. * The max limit of the emission direction.
  83078. */
  83079. direction2: Vector3;
  83080. /**
  83081. * Creates a new instance CylinderDirectedParticleEmitter
  83082. * @param radius the radius of the emission cylinder (1 by default)
  83083. * @param height the height of the emission cylinder (1 by default)
  83084. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83085. * @param direction1 the min limit of the emission direction (up vector by default)
  83086. * @param direction2 the max limit of the emission direction (up vector by default)
  83087. */
  83088. constructor(radius?: number, height?: number, radiusRange?: number,
  83089. /**
  83090. * The min limit of the emission direction.
  83091. */
  83092. direction1?: Vector3,
  83093. /**
  83094. * The max limit of the emission direction.
  83095. */
  83096. direction2?: Vector3);
  83097. /**
  83098. * Called by the particle System when the direction is computed for the created particle.
  83099. * @param worldMatrix is the world matrix of the particle system
  83100. * @param directionToUpdate is the direction vector to update with the result
  83101. * @param particle is the particle we are computed the direction for
  83102. */
  83103. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83104. /**
  83105. * Clones the current emitter and returns a copy of it
  83106. * @returns the new emitter
  83107. */
  83108. clone(): CylinderDirectedParticleEmitter;
  83109. /**
  83110. * Called by the GPUParticleSystem to setup the update shader
  83111. * @param effect defines the update shader
  83112. */
  83113. applyToShader(effect: Effect): void;
  83114. /**
  83115. * Returns a string to use to update the GPU particles update shader
  83116. * @returns a string containng the defines string
  83117. */
  83118. getEffectDefines(): string;
  83119. /**
  83120. * Returns the string "CylinderDirectedParticleEmitter"
  83121. * @returns a string containing the class name
  83122. */
  83123. getClassName(): string;
  83124. /**
  83125. * Serializes the particle system to a JSON object.
  83126. * @returns the JSON object
  83127. */
  83128. serialize(): any;
  83129. /**
  83130. * Parse properties from a JSON object
  83131. * @param serializationObject defines the JSON object
  83132. */
  83133. parse(serializationObject: any): void;
  83134. }
  83135. }
  83136. declare module BABYLON {
  83137. /**
  83138. * Particle emitter emitting particles from the inside of a hemisphere.
  83139. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83140. */
  83141. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83142. /**
  83143. * The radius of the emission hemisphere.
  83144. */
  83145. radius: number;
  83146. /**
  83147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83148. */
  83149. radiusRange: number;
  83150. /**
  83151. * How much to randomize the particle direction [0-1].
  83152. */
  83153. directionRandomizer: number;
  83154. /**
  83155. * Creates a new instance HemisphericParticleEmitter
  83156. * @param radius the radius of the emission hemisphere (1 by default)
  83157. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83158. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83159. */
  83160. constructor(
  83161. /**
  83162. * The radius of the emission hemisphere.
  83163. */
  83164. radius?: number,
  83165. /**
  83166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83167. */
  83168. radiusRange?: number,
  83169. /**
  83170. * How much to randomize the particle direction [0-1].
  83171. */
  83172. directionRandomizer?: number);
  83173. /**
  83174. * Called by the particle System when the direction is computed for the created particle.
  83175. * @param worldMatrix is the world matrix of the particle system
  83176. * @param directionToUpdate is the direction vector to update with the result
  83177. * @param particle is the particle we are computed the direction for
  83178. */
  83179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83180. /**
  83181. * Called by the particle System when the position is computed for the created particle.
  83182. * @param worldMatrix is the world matrix of the particle system
  83183. * @param positionToUpdate is the position vector to update with the result
  83184. * @param particle is the particle we are computed the position for
  83185. */
  83186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83187. /**
  83188. * Clones the current emitter and returns a copy of it
  83189. * @returns the new emitter
  83190. */
  83191. clone(): HemisphericParticleEmitter;
  83192. /**
  83193. * Called by the GPUParticleSystem to setup the update shader
  83194. * @param effect defines the update shader
  83195. */
  83196. applyToShader(effect: Effect): void;
  83197. /**
  83198. * Returns a string to use to update the GPU particles update shader
  83199. * @returns a string containng the defines string
  83200. */
  83201. getEffectDefines(): string;
  83202. /**
  83203. * Returns the string "HemisphericParticleEmitter"
  83204. * @returns a string containing the class name
  83205. */
  83206. getClassName(): string;
  83207. /**
  83208. * Serializes the particle system to a JSON object.
  83209. * @returns the JSON object
  83210. */
  83211. serialize(): any;
  83212. /**
  83213. * Parse properties from a JSON object
  83214. * @param serializationObject defines the JSON object
  83215. */
  83216. parse(serializationObject: any): void;
  83217. }
  83218. }
  83219. declare module BABYLON {
  83220. /**
  83221. * Particle emitter emitting particles from a point.
  83222. * It emits the particles randomly between 2 given directions.
  83223. */
  83224. export class PointParticleEmitter implements IParticleEmitterType {
  83225. /**
  83226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83227. */
  83228. direction1: Vector3;
  83229. /**
  83230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83231. */
  83232. direction2: Vector3;
  83233. /**
  83234. * Creates a new instance PointParticleEmitter
  83235. */
  83236. constructor();
  83237. /**
  83238. * Called by the particle System when the direction is computed for the created particle.
  83239. * @param worldMatrix is the world matrix of the particle system
  83240. * @param directionToUpdate is the direction vector to update with the result
  83241. * @param particle is the particle we are computed the direction for
  83242. */
  83243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83244. /**
  83245. * Called by the particle System when the position is computed for the created particle.
  83246. * @param worldMatrix is the world matrix of the particle system
  83247. * @param positionToUpdate is the position vector to update with the result
  83248. * @param particle is the particle we are computed the position for
  83249. */
  83250. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83251. /**
  83252. * Clones the current emitter and returns a copy of it
  83253. * @returns the new emitter
  83254. */
  83255. clone(): PointParticleEmitter;
  83256. /**
  83257. * Called by the GPUParticleSystem to setup the update shader
  83258. * @param effect defines the update shader
  83259. */
  83260. applyToShader(effect: Effect): void;
  83261. /**
  83262. * Returns a string to use to update the GPU particles update shader
  83263. * @returns a string containng the defines string
  83264. */
  83265. getEffectDefines(): string;
  83266. /**
  83267. * Returns the string "PointParticleEmitter"
  83268. * @returns a string containing the class name
  83269. */
  83270. getClassName(): string;
  83271. /**
  83272. * Serializes the particle system to a JSON object.
  83273. * @returns the JSON object
  83274. */
  83275. serialize(): any;
  83276. /**
  83277. * Parse properties from a JSON object
  83278. * @param serializationObject defines the JSON object
  83279. */
  83280. parse(serializationObject: any): void;
  83281. }
  83282. }
  83283. declare module BABYLON {
  83284. /**
  83285. * Particle emitter emitting particles from the inside of a sphere.
  83286. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83287. */
  83288. export class SphereParticleEmitter implements IParticleEmitterType {
  83289. /**
  83290. * The radius of the emission sphere.
  83291. */
  83292. radius: number;
  83293. /**
  83294. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83295. */
  83296. radiusRange: number;
  83297. /**
  83298. * How much to randomize the particle direction [0-1].
  83299. */
  83300. directionRandomizer: number;
  83301. /**
  83302. * Creates a new instance SphereParticleEmitter
  83303. * @param radius the radius of the emission sphere (1 by default)
  83304. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83305. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83306. */
  83307. constructor(
  83308. /**
  83309. * The radius of the emission sphere.
  83310. */
  83311. radius?: number,
  83312. /**
  83313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83314. */
  83315. radiusRange?: number,
  83316. /**
  83317. * How much to randomize the particle direction [0-1].
  83318. */
  83319. directionRandomizer?: number);
  83320. /**
  83321. * Called by the particle System when the direction is computed for the created particle.
  83322. * @param worldMatrix is the world matrix of the particle system
  83323. * @param directionToUpdate is the direction vector to update with the result
  83324. * @param particle is the particle we are computed the direction for
  83325. */
  83326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83327. /**
  83328. * Called by the particle System when the position is computed for the created particle.
  83329. * @param worldMatrix is the world matrix of the particle system
  83330. * @param positionToUpdate is the position vector to update with the result
  83331. * @param particle is the particle we are computed the position for
  83332. */
  83333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83334. /**
  83335. * Clones the current emitter and returns a copy of it
  83336. * @returns the new emitter
  83337. */
  83338. clone(): SphereParticleEmitter;
  83339. /**
  83340. * Called by the GPUParticleSystem to setup the update shader
  83341. * @param effect defines the update shader
  83342. */
  83343. applyToShader(effect: Effect): void;
  83344. /**
  83345. * Returns a string to use to update the GPU particles update shader
  83346. * @returns a string containng the defines string
  83347. */
  83348. getEffectDefines(): string;
  83349. /**
  83350. * Returns the string "SphereParticleEmitter"
  83351. * @returns a string containing the class name
  83352. */
  83353. getClassName(): string;
  83354. /**
  83355. * Serializes the particle system to a JSON object.
  83356. * @returns the JSON object
  83357. */
  83358. serialize(): any;
  83359. /**
  83360. * Parse properties from a JSON object
  83361. * @param serializationObject defines the JSON object
  83362. */
  83363. parse(serializationObject: any): void;
  83364. }
  83365. /**
  83366. * Particle emitter emitting particles from the inside of a sphere.
  83367. * It emits the particles randomly between two vectors.
  83368. */
  83369. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83370. /**
  83371. * The min limit of the emission direction.
  83372. */
  83373. direction1: Vector3;
  83374. /**
  83375. * The max limit of the emission direction.
  83376. */
  83377. direction2: Vector3;
  83378. /**
  83379. * Creates a new instance SphereDirectedParticleEmitter
  83380. * @param radius the radius of the emission sphere (1 by default)
  83381. * @param direction1 the min limit of the emission direction (up vector by default)
  83382. * @param direction2 the max limit of the emission direction (up vector by default)
  83383. */
  83384. constructor(radius?: number,
  83385. /**
  83386. * The min limit of the emission direction.
  83387. */
  83388. direction1?: Vector3,
  83389. /**
  83390. * The max limit of the emission direction.
  83391. */
  83392. direction2?: Vector3);
  83393. /**
  83394. * Called by the particle System when the direction is computed for the created particle.
  83395. * @param worldMatrix is the world matrix of the particle system
  83396. * @param directionToUpdate is the direction vector to update with the result
  83397. * @param particle is the particle we are computed the direction for
  83398. */
  83399. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83400. /**
  83401. * Clones the current emitter and returns a copy of it
  83402. * @returns the new emitter
  83403. */
  83404. clone(): SphereDirectedParticleEmitter;
  83405. /**
  83406. * Called by the GPUParticleSystem to setup the update shader
  83407. * @param effect defines the update shader
  83408. */
  83409. applyToShader(effect: Effect): void;
  83410. /**
  83411. * Returns a string to use to update the GPU particles update shader
  83412. * @returns a string containng the defines string
  83413. */
  83414. getEffectDefines(): string;
  83415. /**
  83416. * Returns the string "SphereDirectedParticleEmitter"
  83417. * @returns a string containing the class name
  83418. */
  83419. getClassName(): string;
  83420. /**
  83421. * Serializes the particle system to a JSON object.
  83422. * @returns the JSON object
  83423. */
  83424. serialize(): any;
  83425. /**
  83426. * Parse properties from a JSON object
  83427. * @param serializationObject defines the JSON object
  83428. */
  83429. parse(serializationObject: any): void;
  83430. }
  83431. }
  83432. declare module BABYLON {
  83433. /**
  83434. * Interface representing a particle system in Babylon.js.
  83435. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83436. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83437. */
  83438. export interface IParticleSystem {
  83439. /**
  83440. * List of animations used by the particle system.
  83441. */
  83442. animations: Animation[];
  83443. /**
  83444. * The id of the Particle system.
  83445. */
  83446. id: string;
  83447. /**
  83448. * The name of the Particle system.
  83449. */
  83450. name: string;
  83451. /**
  83452. * The emitter represents the Mesh or position we are attaching the particle system to.
  83453. */
  83454. emitter: Nullable<AbstractMesh | Vector3>;
  83455. /**
  83456. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83457. */
  83458. isBillboardBased: boolean;
  83459. /**
  83460. * The rendering group used by the Particle system to chose when to render.
  83461. */
  83462. renderingGroupId: number;
  83463. /**
  83464. * The layer mask we are rendering the particles through.
  83465. */
  83466. layerMask: number;
  83467. /**
  83468. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83469. */
  83470. updateSpeed: number;
  83471. /**
  83472. * The amount of time the particle system is running (depends of the overall update speed).
  83473. */
  83474. targetStopDuration: number;
  83475. /**
  83476. * The texture used to render each particle. (this can be a spritesheet)
  83477. */
  83478. particleTexture: Nullable<Texture>;
  83479. /**
  83480. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83481. */
  83482. blendMode: number;
  83483. /**
  83484. * Minimum life time of emitting particles.
  83485. */
  83486. minLifeTime: number;
  83487. /**
  83488. * Maximum life time of emitting particles.
  83489. */
  83490. maxLifeTime: number;
  83491. /**
  83492. * Minimum Size of emitting particles.
  83493. */
  83494. minSize: number;
  83495. /**
  83496. * Maximum Size of emitting particles.
  83497. */
  83498. maxSize: number;
  83499. /**
  83500. * Minimum scale of emitting particles on X axis.
  83501. */
  83502. minScaleX: number;
  83503. /**
  83504. * Maximum scale of emitting particles on X axis.
  83505. */
  83506. maxScaleX: number;
  83507. /**
  83508. * Minimum scale of emitting particles on Y axis.
  83509. */
  83510. minScaleY: number;
  83511. /**
  83512. * Maximum scale of emitting particles on Y axis.
  83513. */
  83514. maxScaleY: number;
  83515. /**
  83516. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83517. */
  83518. color1: Color4;
  83519. /**
  83520. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83521. */
  83522. color2: Color4;
  83523. /**
  83524. * Color the particle will have at the end of its lifetime.
  83525. */
  83526. colorDead: Color4;
  83527. /**
  83528. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83529. */
  83530. emitRate: number;
  83531. /**
  83532. * You can use gravity if you want to give an orientation to your particles.
  83533. */
  83534. gravity: Vector3;
  83535. /**
  83536. * Minimum power of emitting particles.
  83537. */
  83538. minEmitPower: number;
  83539. /**
  83540. * Maximum power of emitting particles.
  83541. */
  83542. maxEmitPower: number;
  83543. /**
  83544. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83545. */
  83546. minAngularSpeed: number;
  83547. /**
  83548. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83549. */
  83550. maxAngularSpeed: number;
  83551. /**
  83552. * Gets or sets the minimal initial rotation in radians.
  83553. */
  83554. minInitialRotation: number;
  83555. /**
  83556. * Gets or sets the maximal initial rotation in radians.
  83557. */
  83558. maxInitialRotation: number;
  83559. /**
  83560. * The particle emitter type defines the emitter used by the particle system.
  83561. * It can be for example box, sphere, or cone...
  83562. */
  83563. particleEmitterType: Nullable<IParticleEmitterType>;
  83564. /**
  83565. * Defines the delay in milliseconds before starting the system (0 by default)
  83566. */
  83567. startDelay: number;
  83568. /**
  83569. * 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
  83570. */
  83571. preWarmCycles: number;
  83572. /**
  83573. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83574. */
  83575. preWarmStepOffset: number;
  83576. /**
  83577. * 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)
  83578. */
  83579. spriteCellChangeSpeed: number;
  83580. /**
  83581. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83582. */
  83583. startSpriteCellID: number;
  83584. /**
  83585. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83586. */
  83587. endSpriteCellID: number;
  83588. /**
  83589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83590. */
  83591. spriteCellWidth: number;
  83592. /**
  83593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83594. */
  83595. spriteCellHeight: number;
  83596. /**
  83597. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83598. */
  83599. spriteRandomStartCell: boolean;
  83600. /**
  83601. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83602. */
  83603. isAnimationSheetEnabled: boolean;
  83604. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83605. translationPivot: Vector2;
  83606. /**
  83607. * Gets or sets a texture used to add random noise to particle positions
  83608. */
  83609. noiseTexture: Nullable<BaseTexture>;
  83610. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83611. noiseStrength: Vector3;
  83612. /**
  83613. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83614. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83615. */
  83616. billboardMode: number;
  83617. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83618. limitVelocityDamping: number;
  83619. /**
  83620. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83621. */
  83622. beginAnimationOnStart: boolean;
  83623. /**
  83624. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83625. */
  83626. beginAnimationFrom: number;
  83627. /**
  83628. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83629. */
  83630. beginAnimationTo: number;
  83631. /**
  83632. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83633. */
  83634. beginAnimationLoop: boolean;
  83635. /**
  83636. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83637. */
  83638. disposeOnStop: boolean;
  83639. /**
  83640. * Gets the maximum number of particles active at the same time.
  83641. * @returns The max number of active particles.
  83642. */
  83643. getCapacity(): number;
  83644. /**
  83645. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83646. * @returns True if it has been started, otherwise false.
  83647. */
  83648. isStarted(): boolean;
  83649. /**
  83650. * Animates the particle system for this frame.
  83651. */
  83652. animate(): void;
  83653. /**
  83654. * Renders the particle system in its current state.
  83655. * @returns the current number of particles
  83656. */
  83657. render(): number;
  83658. /**
  83659. * Dispose the particle system and frees its associated resources.
  83660. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83661. */
  83662. dispose(disposeTexture?: boolean): void;
  83663. /**
  83664. * Clones the particle system.
  83665. * @param name The name of the cloned object
  83666. * @param newEmitter The new emitter to use
  83667. * @returns the cloned particle system
  83668. */
  83669. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83670. /**
  83671. * Serializes the particle system to a JSON object.
  83672. * @returns the JSON object
  83673. */
  83674. serialize(): any;
  83675. /**
  83676. * Rebuild the particle system
  83677. */
  83678. rebuild(): void;
  83679. /**
  83680. * Starts the particle system and begins to emit
  83681. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83682. */
  83683. start(delay?: number): void;
  83684. /**
  83685. * Stops the particle system.
  83686. */
  83687. stop(): void;
  83688. /**
  83689. * Remove all active particles
  83690. */
  83691. reset(): void;
  83692. /**
  83693. * Is this system ready to be used/rendered
  83694. * @return true if the system is ready
  83695. */
  83696. isReady(): boolean;
  83697. /**
  83698. * Adds a new color gradient
  83699. * @param gradient defines the gradient to use (between 0 and 1)
  83700. * @param color1 defines the color to affect to the specified gradient
  83701. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83702. * @returns the current particle system
  83703. */
  83704. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83705. /**
  83706. * Remove a specific color gradient
  83707. * @param gradient defines the gradient to remove
  83708. * @returns the current particle system
  83709. */
  83710. removeColorGradient(gradient: number): IParticleSystem;
  83711. /**
  83712. * Adds a new size gradient
  83713. * @param gradient defines the gradient to use (between 0 and 1)
  83714. * @param factor defines the size factor to affect to the specified gradient
  83715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83716. * @returns the current particle system
  83717. */
  83718. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83719. /**
  83720. * Remove a specific size gradient
  83721. * @param gradient defines the gradient to remove
  83722. * @returns the current particle system
  83723. */
  83724. removeSizeGradient(gradient: number): IParticleSystem;
  83725. /**
  83726. * Gets the current list of color gradients.
  83727. * You must use addColorGradient and removeColorGradient to udpate this list
  83728. * @returns the list of color gradients
  83729. */
  83730. getColorGradients(): Nullable<Array<ColorGradient>>;
  83731. /**
  83732. * Gets the current list of size gradients.
  83733. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83734. * @returns the list of size gradients
  83735. */
  83736. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83737. /**
  83738. * Gets the current list of angular speed gradients.
  83739. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83740. * @returns the list of angular speed gradients
  83741. */
  83742. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83743. /**
  83744. * Adds a new angular speed gradient
  83745. * @param gradient defines the gradient to use (between 0 and 1)
  83746. * @param factor defines the angular speed to affect to the specified gradient
  83747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83748. * @returns the current particle system
  83749. */
  83750. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83751. /**
  83752. * Remove a specific angular speed gradient
  83753. * @param gradient defines the gradient to remove
  83754. * @returns the current particle system
  83755. */
  83756. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83757. /**
  83758. * Gets the current list of velocity gradients.
  83759. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83760. * @returns the list of velocity gradients
  83761. */
  83762. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83763. /**
  83764. * Adds a new velocity gradient
  83765. * @param gradient defines the gradient to use (between 0 and 1)
  83766. * @param factor defines the velocity to affect to the specified gradient
  83767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83768. * @returns the current particle system
  83769. */
  83770. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83771. /**
  83772. * Remove a specific velocity gradient
  83773. * @param gradient defines the gradient to remove
  83774. * @returns the current particle system
  83775. */
  83776. removeVelocityGradient(gradient: number): IParticleSystem;
  83777. /**
  83778. * Gets the current list of limit velocity gradients.
  83779. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83780. * @returns the list of limit velocity gradients
  83781. */
  83782. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83783. /**
  83784. * Adds a new limit velocity gradient
  83785. * @param gradient defines the gradient to use (between 0 and 1)
  83786. * @param factor defines the limit velocity to affect to the specified gradient
  83787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83788. * @returns the current particle system
  83789. */
  83790. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83791. /**
  83792. * Remove a specific limit velocity gradient
  83793. * @param gradient defines the gradient to remove
  83794. * @returns the current particle system
  83795. */
  83796. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83797. /**
  83798. * Adds a new drag gradient
  83799. * @param gradient defines the gradient to use (between 0 and 1)
  83800. * @param factor defines the drag to affect to the specified gradient
  83801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83802. * @returns the current particle system
  83803. */
  83804. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83805. /**
  83806. * Remove a specific drag gradient
  83807. * @param gradient defines the gradient to remove
  83808. * @returns the current particle system
  83809. */
  83810. removeDragGradient(gradient: number): IParticleSystem;
  83811. /**
  83812. * Gets the current list of drag gradients.
  83813. * You must use addDragGradient and removeDragGradient to udpate this list
  83814. * @returns the list of drag gradients
  83815. */
  83816. getDragGradients(): Nullable<Array<FactorGradient>>;
  83817. /**
  83818. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83819. * @param gradient defines the gradient to use (between 0 and 1)
  83820. * @param factor defines the emit rate to affect to the specified gradient
  83821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83822. * @returns the current particle system
  83823. */
  83824. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83825. /**
  83826. * Remove a specific emit rate gradient
  83827. * @param gradient defines the gradient to remove
  83828. * @returns the current particle system
  83829. */
  83830. removeEmitRateGradient(gradient: number): IParticleSystem;
  83831. /**
  83832. * Gets the current list of emit rate gradients.
  83833. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83834. * @returns the list of emit rate gradients
  83835. */
  83836. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83837. /**
  83838. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83839. * @param gradient defines the gradient to use (between 0 and 1)
  83840. * @param factor defines the start size to affect to the specified gradient
  83841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83842. * @returns the current particle system
  83843. */
  83844. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83845. /**
  83846. * Remove a specific start size gradient
  83847. * @param gradient defines the gradient to remove
  83848. * @returns the current particle system
  83849. */
  83850. removeStartSizeGradient(gradient: number): IParticleSystem;
  83851. /**
  83852. * Gets the current list of start size gradients.
  83853. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83854. * @returns the list of start size gradients
  83855. */
  83856. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83857. /**
  83858. * Adds a new life time gradient
  83859. * @param gradient defines the gradient to use (between 0 and 1)
  83860. * @param factor defines the life time factor to affect to the specified gradient
  83861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83862. * @returns the current particle system
  83863. */
  83864. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83865. /**
  83866. * Remove a specific life time gradient
  83867. * @param gradient defines the gradient to remove
  83868. * @returns the current particle system
  83869. */
  83870. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83871. /**
  83872. * Gets the current list of life time gradients.
  83873. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83874. * @returns the list of life time gradients
  83875. */
  83876. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83877. /**
  83878. * Gets the current list of color gradients.
  83879. * You must use addColorGradient and removeColorGradient to udpate this list
  83880. * @returns the list of color gradients
  83881. */
  83882. getColorGradients(): Nullable<Array<ColorGradient>>;
  83883. /**
  83884. * Adds a new ramp gradient used to remap particle colors
  83885. * @param gradient defines the gradient to use (between 0 and 1)
  83886. * @param color defines the color to affect to the specified gradient
  83887. * @returns the current particle system
  83888. */
  83889. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83890. /**
  83891. * Gets the current list of ramp gradients.
  83892. * You must use addRampGradient and removeRampGradient to udpate this list
  83893. * @returns the list of ramp gradients
  83894. */
  83895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83896. /** Gets or sets a boolean indicating that ramp gradients must be used
  83897. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83898. */
  83899. useRampGradients: boolean;
  83900. /**
  83901. * Adds a new color remap gradient
  83902. * @param gradient defines the gradient to use (between 0 and 1)
  83903. * @param min defines the color remap minimal range
  83904. * @param max defines the color remap maximal range
  83905. * @returns the current particle system
  83906. */
  83907. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83908. /**
  83909. * Gets the current list of color remap gradients.
  83910. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83911. * @returns the list of color remap gradients
  83912. */
  83913. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83914. /**
  83915. * Adds a new alpha remap gradient
  83916. * @param gradient defines the gradient to use (between 0 and 1)
  83917. * @param min defines the alpha remap minimal range
  83918. * @param max defines the alpha remap maximal range
  83919. * @returns the current particle system
  83920. */
  83921. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83922. /**
  83923. * Gets the current list of alpha remap gradients.
  83924. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83925. * @returns the list of alpha remap gradients
  83926. */
  83927. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83928. /**
  83929. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83930. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83931. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83932. * @returns the emitter
  83933. */
  83934. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83935. /**
  83936. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83937. * @param radius The radius of the hemisphere to emit from
  83938. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83939. * @returns the emitter
  83940. */
  83941. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83942. /**
  83943. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83944. * @param radius The radius of the sphere to emit from
  83945. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83946. * @returns the emitter
  83947. */
  83948. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83949. /**
  83950. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83951. * @param radius The radius of the sphere to emit from
  83952. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83953. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83954. * @returns the emitter
  83955. */
  83956. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83957. /**
  83958. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83959. * @param radius The radius of the emission cylinder
  83960. * @param height The height of the emission cylinder
  83961. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83962. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83963. * @returns the emitter
  83964. */
  83965. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83966. /**
  83967. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83968. * @param radius The radius of the cylinder to emit from
  83969. * @param height The height of the emission cylinder
  83970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83973. * @returns the emitter
  83974. */
  83975. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83976. /**
  83977. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83978. * @param radius The radius of the cone to emit from
  83979. * @param angle The base angle of the cone
  83980. * @returns the emitter
  83981. */
  83982. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83983. /**
  83984. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83985. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83986. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83987. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83988. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83989. * @returns the emitter
  83990. */
  83991. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83992. /**
  83993. * Get hosting scene
  83994. * @returns the scene
  83995. */
  83996. getScene(): Scene;
  83997. }
  83998. }
  83999. declare module BABYLON {
  84000. /** @hidden */
  84001. export var linePixelShader: {
  84002. name: string;
  84003. shader: string;
  84004. };
  84005. }
  84006. declare module BABYLON {
  84007. /** @hidden */
  84008. export var lineVertexShader: {
  84009. name: string;
  84010. shader: string;
  84011. };
  84012. }
  84013. declare module BABYLON {
  84014. interface AbstractMesh {
  84015. /**
  84016. * Gets the edgesRenderer associated with the mesh
  84017. */
  84018. edgesRenderer: Nullable<EdgesRenderer>;
  84019. }
  84020. interface LinesMesh {
  84021. /**
  84022. * Enables the edge rendering mode on the mesh.
  84023. * This mode makes the mesh edges visible
  84024. * @param epsilon defines the maximal distance between two angles to detect a face
  84025. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84026. * @returns the currentAbstractMesh
  84027. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84028. */
  84029. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84030. }
  84031. interface InstancedLinesMesh {
  84032. /**
  84033. * Enables the edge rendering mode on the mesh.
  84034. * This mode makes the mesh edges visible
  84035. * @param epsilon defines the maximal distance between two angles to detect a face
  84036. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84037. * @returns the current InstancedLinesMesh
  84038. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84039. */
  84040. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84041. }
  84042. /**
  84043. * Defines the minimum contract an Edges renderer should follow.
  84044. */
  84045. export interface IEdgesRenderer extends IDisposable {
  84046. /**
  84047. * Gets or sets a boolean indicating if the edgesRenderer is active
  84048. */
  84049. isEnabled: boolean;
  84050. /**
  84051. * Renders the edges of the attached mesh,
  84052. */
  84053. render(): void;
  84054. /**
  84055. * Checks wether or not the edges renderer is ready to render.
  84056. * @return true if ready, otherwise false.
  84057. */
  84058. isReady(): boolean;
  84059. }
  84060. /**
  84061. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84062. */
  84063. export class EdgesRenderer implements IEdgesRenderer {
  84064. /**
  84065. * Define the size of the edges with an orthographic camera
  84066. */
  84067. edgesWidthScalerForOrthographic: number;
  84068. /**
  84069. * Define the size of the edges with a perspective camera
  84070. */
  84071. edgesWidthScalerForPerspective: number;
  84072. protected _source: AbstractMesh;
  84073. protected _linesPositions: number[];
  84074. protected _linesNormals: number[];
  84075. protected _linesIndices: number[];
  84076. protected _epsilon: number;
  84077. protected _indicesCount: number;
  84078. protected _lineShader: ShaderMaterial;
  84079. protected _ib: DataBuffer;
  84080. protected _buffers: {
  84081. [key: string]: Nullable<VertexBuffer>;
  84082. };
  84083. protected _checkVerticesInsteadOfIndices: boolean;
  84084. private _meshRebuildObserver;
  84085. private _meshDisposeObserver;
  84086. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84087. isEnabled: boolean;
  84088. /**
  84089. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84090. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84091. * @param source Mesh used to create edges
  84092. * @param epsilon sum of angles in adjacency to check for edge
  84093. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84094. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84095. */
  84096. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84097. protected _prepareRessources(): void;
  84098. /** @hidden */
  84099. _rebuild(): void;
  84100. /**
  84101. * Releases the required resources for the edges renderer
  84102. */
  84103. dispose(): void;
  84104. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84105. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84106. /**
  84107. * Checks if the pair of p0 and p1 is en edge
  84108. * @param faceIndex
  84109. * @param edge
  84110. * @param faceNormals
  84111. * @param p0
  84112. * @param p1
  84113. * @private
  84114. */
  84115. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84116. /**
  84117. * push line into the position, normal and index buffer
  84118. * @protected
  84119. */
  84120. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84121. /**
  84122. * Generates lines edges from adjacencjes
  84123. * @private
  84124. */
  84125. _generateEdgesLines(): void;
  84126. /**
  84127. * Checks wether or not the edges renderer is ready to render.
  84128. * @return true if ready, otherwise false.
  84129. */
  84130. isReady(): boolean;
  84131. /**
  84132. * Renders the edges of the attached mesh,
  84133. */
  84134. render(): void;
  84135. }
  84136. /**
  84137. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84138. */
  84139. export class LineEdgesRenderer extends EdgesRenderer {
  84140. /**
  84141. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84142. * @param source LineMesh used to generate edges
  84143. * @param epsilon not important (specified angle for edge detection)
  84144. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84145. */
  84146. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84147. /**
  84148. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84149. */
  84150. _generateEdgesLines(): void;
  84151. }
  84152. }
  84153. declare module BABYLON {
  84154. /**
  84155. * This represents the object necessary to create a rendering group.
  84156. * This is exclusively used and created by the rendering manager.
  84157. * To modify the behavior, you use the available helpers in your scene or meshes.
  84158. * @hidden
  84159. */
  84160. export class RenderingGroup {
  84161. index: number;
  84162. private static _zeroVector;
  84163. private _scene;
  84164. private _opaqueSubMeshes;
  84165. private _transparentSubMeshes;
  84166. private _alphaTestSubMeshes;
  84167. private _depthOnlySubMeshes;
  84168. private _particleSystems;
  84169. private _spriteManagers;
  84170. private _opaqueSortCompareFn;
  84171. private _alphaTestSortCompareFn;
  84172. private _transparentSortCompareFn;
  84173. private _renderOpaque;
  84174. private _renderAlphaTest;
  84175. private _renderTransparent;
  84176. /** @hidden */
  84177. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84178. onBeforeTransparentRendering: () => void;
  84179. /**
  84180. * Set the opaque sort comparison function.
  84181. * If null the sub meshes will be render in the order they were created
  84182. */
  84183. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84184. /**
  84185. * Set the alpha test sort comparison function.
  84186. * If null the sub meshes will be render in the order they were created
  84187. */
  84188. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84189. /**
  84190. * Set the transparent sort comparison function.
  84191. * If null the sub meshes will be render in the order they were created
  84192. */
  84193. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84194. /**
  84195. * Creates a new rendering group.
  84196. * @param index The rendering group index
  84197. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84198. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84199. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84200. */
  84201. 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>);
  84202. /**
  84203. * Render all the sub meshes contained in the group.
  84204. * @param customRenderFunction Used to override the default render behaviour of the group.
  84205. * @returns true if rendered some submeshes.
  84206. */
  84207. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84208. /**
  84209. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84210. * @param subMeshes The submeshes to render
  84211. */
  84212. private renderOpaqueSorted;
  84213. /**
  84214. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84215. * @param subMeshes The submeshes to render
  84216. */
  84217. private renderAlphaTestSorted;
  84218. /**
  84219. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84220. * @param subMeshes The submeshes to render
  84221. */
  84222. private renderTransparentSorted;
  84223. /**
  84224. * Renders the submeshes in a specified order.
  84225. * @param subMeshes The submeshes to sort before render
  84226. * @param sortCompareFn The comparison function use to sort
  84227. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84228. * @param transparent Specifies to activate blending if true
  84229. */
  84230. private static renderSorted;
  84231. /**
  84232. * Renders the submeshes in the order they were dispatched (no sort applied).
  84233. * @param subMeshes The submeshes to render
  84234. */
  84235. private static renderUnsorted;
  84236. /**
  84237. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84238. * are rendered back to front if in the same alpha index.
  84239. *
  84240. * @param a The first submesh
  84241. * @param b The second submesh
  84242. * @returns The result of the comparison
  84243. */
  84244. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84245. /**
  84246. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84247. * are rendered back to front.
  84248. *
  84249. * @param a The first submesh
  84250. * @param b The second submesh
  84251. * @returns The result of the comparison
  84252. */
  84253. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84254. /**
  84255. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84256. * are rendered front to back (prevent overdraw).
  84257. *
  84258. * @param a The first submesh
  84259. * @param b The second submesh
  84260. * @returns The result of the comparison
  84261. */
  84262. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84263. /**
  84264. * Resets the different lists of submeshes to prepare a new frame.
  84265. */
  84266. prepare(): void;
  84267. dispose(): void;
  84268. /**
  84269. * Inserts the submesh in its correct queue depending on its material.
  84270. * @param subMesh The submesh to dispatch
  84271. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84272. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84273. */
  84274. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84275. dispatchSprites(spriteManager: ISpriteManager): void;
  84276. dispatchParticles(particleSystem: IParticleSystem): void;
  84277. private _renderParticles;
  84278. private _renderSprites;
  84279. }
  84280. }
  84281. declare module BABYLON {
  84282. /**
  84283. * Interface describing the different options available in the rendering manager
  84284. * regarding Auto Clear between groups.
  84285. */
  84286. export interface IRenderingManagerAutoClearSetup {
  84287. /**
  84288. * Defines whether or not autoclear is enable.
  84289. */
  84290. autoClear: boolean;
  84291. /**
  84292. * Defines whether or not to autoclear the depth buffer.
  84293. */
  84294. depth: boolean;
  84295. /**
  84296. * Defines whether or not to autoclear the stencil buffer.
  84297. */
  84298. stencil: boolean;
  84299. }
  84300. /**
  84301. * This class is used by the onRenderingGroupObservable
  84302. */
  84303. export class RenderingGroupInfo {
  84304. /**
  84305. * The Scene that being rendered
  84306. */
  84307. scene: Scene;
  84308. /**
  84309. * The camera currently used for the rendering pass
  84310. */
  84311. camera: Nullable<Camera>;
  84312. /**
  84313. * The ID of the renderingGroup being processed
  84314. */
  84315. renderingGroupId: number;
  84316. }
  84317. /**
  84318. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84319. * It is enable to manage the different groups as well as the different necessary sort functions.
  84320. * This should not be used directly aside of the few static configurations
  84321. */
  84322. export class RenderingManager {
  84323. /**
  84324. * The max id used for rendering groups (not included)
  84325. */
  84326. static MAX_RENDERINGGROUPS: number;
  84327. /**
  84328. * The min id used for rendering groups (included)
  84329. */
  84330. static MIN_RENDERINGGROUPS: number;
  84331. /**
  84332. * Used to globally prevent autoclearing scenes.
  84333. */
  84334. static AUTOCLEAR: boolean;
  84335. /**
  84336. * @hidden
  84337. */
  84338. _useSceneAutoClearSetup: boolean;
  84339. private _scene;
  84340. private _renderingGroups;
  84341. private _depthStencilBufferAlreadyCleaned;
  84342. private _autoClearDepthStencil;
  84343. private _customOpaqueSortCompareFn;
  84344. private _customAlphaTestSortCompareFn;
  84345. private _customTransparentSortCompareFn;
  84346. private _renderingGroupInfo;
  84347. /**
  84348. * Instantiates a new rendering group for a particular scene
  84349. * @param scene Defines the scene the groups belongs to
  84350. */
  84351. constructor(scene: Scene);
  84352. private _clearDepthStencilBuffer;
  84353. /**
  84354. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84355. * @hidden
  84356. */
  84357. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84358. /**
  84359. * Resets the different information of the group to prepare a new frame
  84360. * @hidden
  84361. */
  84362. reset(): void;
  84363. /**
  84364. * Dispose and release the group and its associated resources.
  84365. * @hidden
  84366. */
  84367. dispose(): void;
  84368. /**
  84369. * Clear the info related to rendering groups preventing retention points during dispose.
  84370. */
  84371. freeRenderingGroups(): void;
  84372. private _prepareRenderingGroup;
  84373. /**
  84374. * Add a sprite manager to the rendering manager in order to render it this frame.
  84375. * @param spriteManager Define the sprite manager to render
  84376. */
  84377. dispatchSprites(spriteManager: ISpriteManager): void;
  84378. /**
  84379. * Add a particle system to the rendering manager in order to render it this frame.
  84380. * @param particleSystem Define the particle system to render
  84381. */
  84382. dispatchParticles(particleSystem: IParticleSystem): void;
  84383. /**
  84384. * Add a submesh to the manager in order to render it this frame
  84385. * @param subMesh The submesh to dispatch
  84386. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84387. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84388. */
  84389. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84390. /**
  84391. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84392. * This allowed control for front to back rendering or reversly depending of the special needs.
  84393. *
  84394. * @param renderingGroupId The rendering group id corresponding to its index
  84395. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84396. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84397. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84398. */
  84399. 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;
  84400. /**
  84401. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84402. *
  84403. * @param renderingGroupId The rendering group id corresponding to its index
  84404. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84405. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84406. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84407. */
  84408. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84409. /**
  84410. * Gets the current auto clear configuration for one rendering group of the rendering
  84411. * manager.
  84412. * @param index the rendering group index to get the information for
  84413. * @returns The auto clear setup for the requested rendering group
  84414. */
  84415. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84416. }
  84417. }
  84418. declare module BABYLON {
  84419. /**
  84420. * This Helps creating a texture that will be created from a camera in your scene.
  84421. * It is basically a dynamic texture that could be used to create special effects for instance.
  84422. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84423. */
  84424. export class RenderTargetTexture extends Texture {
  84425. isCube: boolean;
  84426. /**
  84427. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84428. */
  84429. static readonly REFRESHRATE_RENDER_ONCE: number;
  84430. /**
  84431. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84432. */
  84433. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84434. /**
  84435. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84436. * the central point of your effect and can save a lot of performances.
  84437. */
  84438. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84439. /**
  84440. * Use this predicate to dynamically define the list of mesh you want to render.
  84441. * If set, the renderList property will be overwritten.
  84442. */
  84443. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84444. private _renderList;
  84445. /**
  84446. * Use this list to define the list of mesh you want to render.
  84447. */
  84448. renderList: Nullable<Array<AbstractMesh>>;
  84449. private _hookArray;
  84450. /**
  84451. * Define if particles should be rendered in your texture.
  84452. */
  84453. renderParticles: boolean;
  84454. /**
  84455. * Define if sprites should be rendered in your texture.
  84456. */
  84457. renderSprites: boolean;
  84458. /**
  84459. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84460. */
  84461. coordinatesMode: number;
  84462. /**
  84463. * Define the camera used to render the texture.
  84464. */
  84465. activeCamera: Nullable<Camera>;
  84466. /**
  84467. * Override the render function of the texture with your own one.
  84468. */
  84469. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84470. /**
  84471. * Define if camera post processes should be use while rendering the texture.
  84472. */
  84473. useCameraPostProcesses: boolean;
  84474. /**
  84475. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84476. */
  84477. ignoreCameraViewport: boolean;
  84478. private _postProcessManager;
  84479. private _postProcesses;
  84480. private _resizeObserver;
  84481. /**
  84482. * An event triggered when the texture is unbind.
  84483. */
  84484. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84485. /**
  84486. * An event triggered when the texture is unbind.
  84487. */
  84488. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84489. private _onAfterUnbindObserver;
  84490. /**
  84491. * Set a after unbind callback in the texture.
  84492. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84493. */
  84494. onAfterUnbind: () => void;
  84495. /**
  84496. * An event triggered before rendering the texture
  84497. */
  84498. onBeforeRenderObservable: Observable<number>;
  84499. private _onBeforeRenderObserver;
  84500. /**
  84501. * Set a before render callback in the texture.
  84502. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84503. */
  84504. onBeforeRender: (faceIndex: number) => void;
  84505. /**
  84506. * An event triggered after rendering the texture
  84507. */
  84508. onAfterRenderObservable: Observable<number>;
  84509. private _onAfterRenderObserver;
  84510. /**
  84511. * Set a after render callback in the texture.
  84512. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84513. */
  84514. onAfterRender: (faceIndex: number) => void;
  84515. /**
  84516. * An event triggered after the texture clear
  84517. */
  84518. onClearObservable: Observable<Engine>;
  84519. private _onClearObserver;
  84520. /**
  84521. * Set a clear callback in the texture.
  84522. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84523. */
  84524. onClear: (Engine: Engine) => void;
  84525. /**
  84526. * Define the clear color of the Render Target if it should be different from the scene.
  84527. */
  84528. clearColor: Color4;
  84529. protected _size: number | {
  84530. width: number;
  84531. height: number;
  84532. };
  84533. protected _initialSizeParameter: number | {
  84534. width: number;
  84535. height: number;
  84536. } | {
  84537. ratio: number;
  84538. };
  84539. protected _sizeRatio: Nullable<number>;
  84540. /** @hidden */
  84541. _generateMipMaps: boolean;
  84542. protected _renderingManager: RenderingManager;
  84543. /** @hidden */
  84544. _waitingRenderList: string[];
  84545. protected _doNotChangeAspectRatio: boolean;
  84546. protected _currentRefreshId: number;
  84547. protected _refreshRate: number;
  84548. protected _textureMatrix: Matrix;
  84549. protected _samples: number;
  84550. protected _renderTargetOptions: RenderTargetCreationOptions;
  84551. /**
  84552. * Gets render target creation options that were used.
  84553. */
  84554. readonly renderTargetOptions: RenderTargetCreationOptions;
  84555. protected _engine: Engine;
  84556. protected _onRatioRescale(): void;
  84557. /**
  84558. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84559. * It must define where the camera used to render the texture is set
  84560. */
  84561. boundingBoxPosition: Vector3;
  84562. private _boundingBoxSize;
  84563. /**
  84564. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84565. * When defined, the cubemap will switch to local mode
  84566. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84567. * @example https://www.babylonjs-playground.com/#RNASML
  84568. */
  84569. boundingBoxSize: Vector3;
  84570. /**
  84571. * In case the RTT has been created with a depth texture, get the associated
  84572. * depth texture.
  84573. * Otherwise, return null.
  84574. */
  84575. depthStencilTexture: Nullable<InternalTexture>;
  84576. /**
  84577. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84578. * or used a shadow, depth texture...
  84579. * @param name The friendly name of the texture
  84580. * @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)
  84581. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84582. * @param generateMipMaps True if mip maps need to be generated after render.
  84583. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84584. * @param type The type of the buffer in the RTT (int, half float, float...)
  84585. * @param isCube True if a cube texture needs to be created
  84586. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84587. * @param generateDepthBuffer True to generate a depth buffer
  84588. * @param generateStencilBuffer True to generate a stencil buffer
  84589. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84590. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84591. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84592. */
  84593. constructor(name: string, size: number | {
  84594. width: number;
  84595. height: number;
  84596. } | {
  84597. ratio: number;
  84598. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84599. /**
  84600. * Creates a depth stencil texture.
  84601. * This is only available in WebGL 2 or with the depth texture extension available.
  84602. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84603. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84604. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84605. */
  84606. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84607. private _processSizeParameter;
  84608. /**
  84609. * Define the number of samples to use in case of MSAA.
  84610. * It defaults to one meaning no MSAA has been enabled.
  84611. */
  84612. samples: number;
  84613. /**
  84614. * Resets the refresh counter of the texture and start bak from scratch.
  84615. * Could be useful to regenerate the texture if it is setup to render only once.
  84616. */
  84617. resetRefreshCounter(): void;
  84618. /**
  84619. * Define the refresh rate of the texture or the rendering frequency.
  84620. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84621. */
  84622. refreshRate: number;
  84623. /**
  84624. * Adds a post process to the render target rendering passes.
  84625. * @param postProcess define the post process to add
  84626. */
  84627. addPostProcess(postProcess: PostProcess): void;
  84628. /**
  84629. * Clear all the post processes attached to the render target
  84630. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84631. */
  84632. clearPostProcesses(dispose?: boolean): void;
  84633. /**
  84634. * Remove one of the post process from the list of attached post processes to the texture
  84635. * @param postProcess define the post process to remove from the list
  84636. */
  84637. removePostProcess(postProcess: PostProcess): void;
  84638. /** @hidden */
  84639. _shouldRender(): boolean;
  84640. /**
  84641. * Gets the actual render size of the texture.
  84642. * @returns the width of the render size
  84643. */
  84644. getRenderSize(): number;
  84645. /**
  84646. * Gets the actual render width of the texture.
  84647. * @returns the width of the render size
  84648. */
  84649. getRenderWidth(): number;
  84650. /**
  84651. * Gets the actual render height of the texture.
  84652. * @returns the height of the render size
  84653. */
  84654. getRenderHeight(): number;
  84655. /**
  84656. * Get if the texture can be rescaled or not.
  84657. */
  84658. readonly canRescale: boolean;
  84659. /**
  84660. * Resize the texture using a ratio.
  84661. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84662. */
  84663. scale(ratio: number): void;
  84664. /**
  84665. * Get the texture reflection matrix used to rotate/transform the reflection.
  84666. * @returns the reflection matrix
  84667. */
  84668. getReflectionTextureMatrix(): Matrix;
  84669. /**
  84670. * Resize the texture to a new desired size.
  84671. * Be carrefull as it will recreate all the data in the new texture.
  84672. * @param size Define the new size. It can be:
  84673. * - a number for squared texture,
  84674. * - an object containing { width: number, height: number }
  84675. * - or an object containing a ratio { ratio: number }
  84676. */
  84677. resize(size: number | {
  84678. width: number;
  84679. height: number;
  84680. } | {
  84681. ratio: number;
  84682. }): void;
  84683. /**
  84684. * Renders all the objects from the render list into the texture.
  84685. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84686. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84687. */
  84688. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84689. private _bestReflectionRenderTargetDimension;
  84690. /**
  84691. * @hidden
  84692. * @param faceIndex face index to bind to if this is a cubetexture
  84693. */
  84694. _bindFrameBuffer(faceIndex?: number): void;
  84695. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84696. private renderToTarget;
  84697. /**
  84698. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84699. * This allowed control for front to back rendering or reversly depending of the special needs.
  84700. *
  84701. * @param renderingGroupId The rendering group id corresponding to its index
  84702. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84703. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84704. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84705. */
  84706. 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;
  84707. /**
  84708. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84709. *
  84710. * @param renderingGroupId The rendering group id corresponding to its index
  84711. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84712. */
  84713. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84714. /**
  84715. * Clones the texture.
  84716. * @returns the cloned texture
  84717. */
  84718. clone(): RenderTargetTexture;
  84719. /**
  84720. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84721. * @returns The JSON representation of the texture
  84722. */
  84723. serialize(): any;
  84724. /**
  84725. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84726. */
  84727. disposeFramebufferObjects(): void;
  84728. /**
  84729. * Dispose the texture and release its associated resources.
  84730. */
  84731. dispose(): void;
  84732. /** @hidden */
  84733. _rebuild(): void;
  84734. /**
  84735. * Clear the info related to rendering groups preventing retention point in material dispose.
  84736. */
  84737. freeRenderingGroups(): void;
  84738. /**
  84739. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84740. * @returns the view count
  84741. */
  84742. getViewCount(): number;
  84743. }
  84744. }
  84745. declare module BABYLON {
  84746. /**
  84747. * Base class for the main features of a material in Babylon.js
  84748. */
  84749. export class Material implements IAnimatable {
  84750. /**
  84751. * Returns the triangle fill mode
  84752. */
  84753. static readonly TriangleFillMode: number;
  84754. /**
  84755. * Returns the wireframe mode
  84756. */
  84757. static readonly WireFrameFillMode: number;
  84758. /**
  84759. * Returns the point fill mode
  84760. */
  84761. static readonly PointFillMode: number;
  84762. /**
  84763. * Returns the point list draw mode
  84764. */
  84765. static readonly PointListDrawMode: number;
  84766. /**
  84767. * Returns the line list draw mode
  84768. */
  84769. static readonly LineListDrawMode: number;
  84770. /**
  84771. * Returns the line loop draw mode
  84772. */
  84773. static readonly LineLoopDrawMode: number;
  84774. /**
  84775. * Returns the line strip draw mode
  84776. */
  84777. static readonly LineStripDrawMode: number;
  84778. /**
  84779. * Returns the triangle strip draw mode
  84780. */
  84781. static readonly TriangleStripDrawMode: number;
  84782. /**
  84783. * Returns the triangle fan draw mode
  84784. */
  84785. static readonly TriangleFanDrawMode: number;
  84786. /**
  84787. * Stores the clock-wise side orientation
  84788. */
  84789. static readonly ClockWiseSideOrientation: number;
  84790. /**
  84791. * Stores the counter clock-wise side orientation
  84792. */
  84793. static readonly CounterClockWiseSideOrientation: number;
  84794. /**
  84795. * The dirty texture flag value
  84796. */
  84797. static readonly TextureDirtyFlag: number;
  84798. /**
  84799. * The dirty light flag value
  84800. */
  84801. static readonly LightDirtyFlag: number;
  84802. /**
  84803. * The dirty fresnel flag value
  84804. */
  84805. static readonly FresnelDirtyFlag: number;
  84806. /**
  84807. * The dirty attribute flag value
  84808. */
  84809. static readonly AttributesDirtyFlag: number;
  84810. /**
  84811. * The dirty misc flag value
  84812. */
  84813. static readonly MiscDirtyFlag: number;
  84814. /**
  84815. * The all dirty flag value
  84816. */
  84817. static readonly AllDirtyFlag: number;
  84818. /**
  84819. * The ID of the material
  84820. */
  84821. id: string;
  84822. /**
  84823. * Gets or sets the unique id of the material
  84824. */
  84825. uniqueId: number;
  84826. /**
  84827. * The name of the material
  84828. */
  84829. name: string;
  84830. /**
  84831. * Gets or sets user defined metadata
  84832. */
  84833. metadata: any;
  84834. /**
  84835. * For internal use only. Please do not use.
  84836. */
  84837. reservedDataStore: any;
  84838. /**
  84839. * Specifies if the ready state should be checked on each call
  84840. */
  84841. checkReadyOnEveryCall: boolean;
  84842. /**
  84843. * Specifies if the ready state should be checked once
  84844. */
  84845. checkReadyOnlyOnce: boolean;
  84846. /**
  84847. * The state of the material
  84848. */
  84849. state: string;
  84850. /**
  84851. * The alpha value of the material
  84852. */
  84853. protected _alpha: number;
  84854. /**
  84855. * List of inspectable custom properties (used by the Inspector)
  84856. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84857. */
  84858. inspectableCustomProperties: IInspectable[];
  84859. /**
  84860. * Sets the alpha value of the material
  84861. */
  84862. /**
  84863. * Gets the alpha value of the material
  84864. */
  84865. alpha: number;
  84866. /**
  84867. * Specifies if back face culling is enabled
  84868. */
  84869. protected _backFaceCulling: boolean;
  84870. /**
  84871. * Sets the back-face culling state
  84872. */
  84873. /**
  84874. * Gets the back-face culling state
  84875. */
  84876. backFaceCulling: boolean;
  84877. /**
  84878. * Stores the value for side orientation
  84879. */
  84880. sideOrientation: number;
  84881. /**
  84882. * Callback triggered when the material is compiled
  84883. */
  84884. onCompiled: Nullable<(effect: Effect) => void>;
  84885. /**
  84886. * Callback triggered when an error occurs
  84887. */
  84888. onError: Nullable<(effect: Effect, errors: string) => void>;
  84889. /**
  84890. * Callback triggered to get the render target textures
  84891. */
  84892. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84893. /**
  84894. * Gets a boolean indicating that current material needs to register RTT
  84895. */
  84896. readonly hasRenderTargetTextures: boolean;
  84897. /**
  84898. * Specifies if the material should be serialized
  84899. */
  84900. doNotSerialize: boolean;
  84901. /**
  84902. * @hidden
  84903. */
  84904. _storeEffectOnSubMeshes: boolean;
  84905. /**
  84906. * Stores the animations for the material
  84907. */
  84908. animations: Nullable<Array<Animation>>;
  84909. /**
  84910. * An event triggered when the material is disposed
  84911. */
  84912. onDisposeObservable: Observable<Material>;
  84913. /**
  84914. * An observer which watches for dispose events
  84915. */
  84916. private _onDisposeObserver;
  84917. private _onUnBindObservable;
  84918. /**
  84919. * Called during a dispose event
  84920. */
  84921. onDispose: () => void;
  84922. private _onBindObservable;
  84923. /**
  84924. * An event triggered when the material is bound
  84925. */
  84926. readonly onBindObservable: Observable<AbstractMesh>;
  84927. /**
  84928. * An observer which watches for bind events
  84929. */
  84930. private _onBindObserver;
  84931. /**
  84932. * Called during a bind event
  84933. */
  84934. onBind: (Mesh: AbstractMesh) => void;
  84935. /**
  84936. * An event triggered when the material is unbound
  84937. */
  84938. readonly onUnBindObservable: Observable<Material>;
  84939. /**
  84940. * Stores the value of the alpha mode
  84941. */
  84942. private _alphaMode;
  84943. /**
  84944. * Sets the value of the alpha mode.
  84945. *
  84946. * | Value | Type | Description |
  84947. * | --- | --- | --- |
  84948. * | 0 | ALPHA_DISABLE | |
  84949. * | 1 | ALPHA_ADD | |
  84950. * | 2 | ALPHA_COMBINE | |
  84951. * | 3 | ALPHA_SUBTRACT | |
  84952. * | 4 | ALPHA_MULTIPLY | |
  84953. * | 5 | ALPHA_MAXIMIZED | |
  84954. * | 6 | ALPHA_ONEONE | |
  84955. * | 7 | ALPHA_PREMULTIPLIED | |
  84956. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84957. * | 9 | ALPHA_INTERPOLATE | |
  84958. * | 10 | ALPHA_SCREENMODE | |
  84959. *
  84960. */
  84961. /**
  84962. * Gets the value of the alpha mode
  84963. */
  84964. alphaMode: number;
  84965. /**
  84966. * Stores the state of the need depth pre-pass value
  84967. */
  84968. private _needDepthPrePass;
  84969. /**
  84970. * Sets the need depth pre-pass value
  84971. */
  84972. /**
  84973. * Gets the depth pre-pass value
  84974. */
  84975. needDepthPrePass: boolean;
  84976. /**
  84977. * Specifies if depth writing should be disabled
  84978. */
  84979. disableDepthWrite: boolean;
  84980. /**
  84981. * Specifies if depth writing should be forced
  84982. */
  84983. forceDepthWrite: boolean;
  84984. /**
  84985. * Specifies if there should be a separate pass for culling
  84986. */
  84987. separateCullingPass: boolean;
  84988. /**
  84989. * Stores the state specifing if fog should be enabled
  84990. */
  84991. private _fogEnabled;
  84992. /**
  84993. * Sets the state for enabling fog
  84994. */
  84995. /**
  84996. * Gets the value of the fog enabled state
  84997. */
  84998. fogEnabled: boolean;
  84999. /**
  85000. * Stores the size of points
  85001. */
  85002. pointSize: number;
  85003. /**
  85004. * Stores the z offset value
  85005. */
  85006. zOffset: number;
  85007. /**
  85008. * Gets a value specifying if wireframe mode is enabled
  85009. */
  85010. /**
  85011. * Sets the state of wireframe mode
  85012. */
  85013. wireframe: boolean;
  85014. /**
  85015. * Gets the value specifying if point clouds are enabled
  85016. */
  85017. /**
  85018. * Sets the state of point cloud mode
  85019. */
  85020. pointsCloud: boolean;
  85021. /**
  85022. * Gets the material fill mode
  85023. */
  85024. /**
  85025. * Sets the material fill mode
  85026. */
  85027. fillMode: number;
  85028. /**
  85029. * @hidden
  85030. * Stores the effects for the material
  85031. */
  85032. _effect: Nullable<Effect>;
  85033. /**
  85034. * @hidden
  85035. * Specifies if the material was previously ready
  85036. */
  85037. _wasPreviouslyReady: boolean;
  85038. /**
  85039. * Specifies if uniform buffers should be used
  85040. */
  85041. private _useUBO;
  85042. /**
  85043. * Stores a reference to the scene
  85044. */
  85045. private _scene;
  85046. /**
  85047. * Stores the fill mode state
  85048. */
  85049. private _fillMode;
  85050. /**
  85051. * Specifies if the depth write state should be cached
  85052. */
  85053. private _cachedDepthWriteState;
  85054. /**
  85055. * Stores the uniform buffer
  85056. */
  85057. protected _uniformBuffer: UniformBuffer;
  85058. /** @hidden */
  85059. _indexInSceneMaterialArray: number;
  85060. /** @hidden */
  85061. meshMap: Nullable<{
  85062. [id: string]: AbstractMesh | undefined;
  85063. }>;
  85064. /**
  85065. * Creates a material instance
  85066. * @param name defines the name of the material
  85067. * @param scene defines the scene to reference
  85068. * @param doNotAdd specifies if the material should be added to the scene
  85069. */
  85070. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85071. /**
  85072. * Returns a string representation of the current material
  85073. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85074. * @returns a string with material information
  85075. */
  85076. toString(fullDetails?: boolean): string;
  85077. /**
  85078. * Gets the class name of the material
  85079. * @returns a string with the class name of the material
  85080. */
  85081. getClassName(): string;
  85082. /**
  85083. * Specifies if updates for the material been locked
  85084. */
  85085. readonly isFrozen: boolean;
  85086. /**
  85087. * Locks updates for the material
  85088. */
  85089. freeze(): void;
  85090. /**
  85091. * Unlocks updates for the material
  85092. */
  85093. unfreeze(): void;
  85094. /**
  85095. * Specifies if the material is ready to be used
  85096. * @param mesh defines the mesh to check
  85097. * @param useInstances specifies if instances should be used
  85098. * @returns a boolean indicating if the material is ready to be used
  85099. */
  85100. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85101. /**
  85102. * Specifies that the submesh is ready to be used
  85103. * @param mesh defines the mesh to check
  85104. * @param subMesh defines which submesh to check
  85105. * @param useInstances specifies that instances should be used
  85106. * @returns a boolean indicating that the submesh is ready or not
  85107. */
  85108. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85109. /**
  85110. * Returns the material effect
  85111. * @returns the effect associated with the material
  85112. */
  85113. getEffect(): Nullable<Effect>;
  85114. /**
  85115. * Returns the current scene
  85116. * @returns a Scene
  85117. */
  85118. getScene(): Scene;
  85119. /**
  85120. * Specifies if the material will require alpha blending
  85121. * @returns a boolean specifying if alpha blending is needed
  85122. */
  85123. needAlphaBlending(): boolean;
  85124. /**
  85125. * Specifies if the mesh will require alpha blending
  85126. * @param mesh defines the mesh to check
  85127. * @returns a boolean specifying if alpha blending is needed for the mesh
  85128. */
  85129. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85130. /**
  85131. * Specifies if this material should be rendered in alpha test mode
  85132. * @returns a boolean specifying if an alpha test is needed.
  85133. */
  85134. needAlphaTesting(): boolean;
  85135. /**
  85136. * Gets the texture used for the alpha test
  85137. * @returns the texture to use for alpha testing
  85138. */
  85139. getAlphaTestTexture(): Nullable<BaseTexture>;
  85140. /**
  85141. * Marks the material to indicate that it needs to be re-calculated
  85142. */
  85143. markDirty(): void;
  85144. /** @hidden */
  85145. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85146. /**
  85147. * Binds the material to the mesh
  85148. * @param world defines the world transformation matrix
  85149. * @param mesh defines the mesh to bind the material to
  85150. */
  85151. bind(world: Matrix, mesh?: Mesh): void;
  85152. /**
  85153. * Binds the submesh to the material
  85154. * @param world defines the world transformation matrix
  85155. * @param mesh defines the mesh containing the submesh
  85156. * @param subMesh defines the submesh to bind the material to
  85157. */
  85158. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85159. /**
  85160. * Binds the world matrix to the material
  85161. * @param world defines the world transformation matrix
  85162. */
  85163. bindOnlyWorldMatrix(world: Matrix): void;
  85164. /**
  85165. * Binds the scene's uniform buffer to the effect.
  85166. * @param effect defines the effect to bind to the scene uniform buffer
  85167. * @param sceneUbo defines the uniform buffer storing scene data
  85168. */
  85169. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85170. /**
  85171. * Binds the view matrix to the effect
  85172. * @param effect defines the effect to bind the view matrix to
  85173. */
  85174. bindView(effect: Effect): void;
  85175. /**
  85176. * Binds the view projection matrix to the effect
  85177. * @param effect defines the effect to bind the view projection matrix to
  85178. */
  85179. bindViewProjection(effect: Effect): void;
  85180. /**
  85181. * Specifies if material alpha testing should be turned on for the mesh
  85182. * @param mesh defines the mesh to check
  85183. */
  85184. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85185. /**
  85186. * Processes to execute after binding the material to a mesh
  85187. * @param mesh defines the rendered mesh
  85188. */
  85189. protected _afterBind(mesh?: Mesh): void;
  85190. /**
  85191. * Unbinds the material from the mesh
  85192. */
  85193. unbind(): void;
  85194. /**
  85195. * Gets the active textures from the material
  85196. * @returns an array of textures
  85197. */
  85198. getActiveTextures(): BaseTexture[];
  85199. /**
  85200. * Specifies if the material uses a texture
  85201. * @param texture defines the texture to check against the material
  85202. * @returns a boolean specifying if the material uses the texture
  85203. */
  85204. hasTexture(texture: BaseTexture): boolean;
  85205. /**
  85206. * Makes a duplicate of the material, and gives it a new name
  85207. * @param name defines the new name for the duplicated material
  85208. * @returns the cloned material
  85209. */
  85210. clone(name: string): Nullable<Material>;
  85211. /**
  85212. * Gets the meshes bound to the material
  85213. * @returns an array of meshes bound to the material
  85214. */
  85215. getBindedMeshes(): AbstractMesh[];
  85216. /**
  85217. * Force shader compilation
  85218. * @param mesh defines the mesh associated with this material
  85219. * @param onCompiled defines a function to execute once the material is compiled
  85220. * @param options defines the options to configure the compilation
  85221. */
  85222. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85223. clipPlane: boolean;
  85224. }>): void;
  85225. /**
  85226. * Force shader compilation
  85227. * @param mesh defines the mesh that will use this material
  85228. * @param options defines additional options for compiling the shaders
  85229. * @returns a promise that resolves when the compilation completes
  85230. */
  85231. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85232. clipPlane: boolean;
  85233. }>): Promise<void>;
  85234. private static readonly _AllDirtyCallBack;
  85235. private static readonly _ImageProcessingDirtyCallBack;
  85236. private static readonly _TextureDirtyCallBack;
  85237. private static readonly _FresnelDirtyCallBack;
  85238. private static readonly _MiscDirtyCallBack;
  85239. private static readonly _LightsDirtyCallBack;
  85240. private static readonly _AttributeDirtyCallBack;
  85241. private static _FresnelAndMiscDirtyCallBack;
  85242. private static _TextureAndMiscDirtyCallBack;
  85243. private static readonly _DirtyCallbackArray;
  85244. private static readonly _RunDirtyCallBacks;
  85245. /**
  85246. * Marks a define in the material to indicate that it needs to be re-computed
  85247. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85248. */
  85249. markAsDirty(flag: number): void;
  85250. /**
  85251. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85252. * @param func defines a function which checks material defines against the submeshes
  85253. */
  85254. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85255. /**
  85256. * Indicates that we need to re-calculated for all submeshes
  85257. */
  85258. protected _markAllSubMeshesAsAllDirty(): void;
  85259. /**
  85260. * Indicates that image processing needs to be re-calculated for all submeshes
  85261. */
  85262. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85263. /**
  85264. * Indicates that textures need to be re-calculated for all submeshes
  85265. */
  85266. protected _markAllSubMeshesAsTexturesDirty(): void;
  85267. /**
  85268. * Indicates that fresnel needs to be re-calculated for all submeshes
  85269. */
  85270. protected _markAllSubMeshesAsFresnelDirty(): void;
  85271. /**
  85272. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85273. */
  85274. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85275. /**
  85276. * Indicates that lights need to be re-calculated for all submeshes
  85277. */
  85278. protected _markAllSubMeshesAsLightsDirty(): void;
  85279. /**
  85280. * Indicates that attributes need to be re-calculated for all submeshes
  85281. */
  85282. protected _markAllSubMeshesAsAttributesDirty(): void;
  85283. /**
  85284. * Indicates that misc needs to be re-calculated for all submeshes
  85285. */
  85286. protected _markAllSubMeshesAsMiscDirty(): void;
  85287. /**
  85288. * Indicates that textures and misc need to be re-calculated for all submeshes
  85289. */
  85290. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85291. /**
  85292. * Disposes the material
  85293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85296. */
  85297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85298. /** @hidden */
  85299. private releaseVertexArrayObject;
  85300. /**
  85301. * Serializes this material
  85302. * @returns the serialized material object
  85303. */
  85304. serialize(): any;
  85305. /**
  85306. * Creates a material from parsed material data
  85307. * @param parsedMaterial defines parsed material data
  85308. * @param scene defines the hosting scene
  85309. * @param rootUrl defines the root URL to use to load textures
  85310. * @returns a new material
  85311. */
  85312. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85313. }
  85314. }
  85315. declare module BABYLON {
  85316. /**
  85317. * Base class for submeshes
  85318. */
  85319. export class BaseSubMesh {
  85320. /** @hidden */
  85321. _materialDefines: Nullable<MaterialDefines>;
  85322. /** @hidden */
  85323. _materialEffect: Nullable<Effect>;
  85324. /**
  85325. * Gets associated effect
  85326. */
  85327. readonly effect: Nullable<Effect>;
  85328. /**
  85329. * Sets associated effect (effect used to render this submesh)
  85330. * @param effect defines the effect to associate with
  85331. * @param defines defines the set of defines used to compile this effect
  85332. */
  85333. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85334. }
  85335. /**
  85336. * Defines a subdivision inside a mesh
  85337. */
  85338. export class SubMesh extends BaseSubMesh implements ICullable {
  85339. /** the material index to use */
  85340. materialIndex: number;
  85341. /** vertex index start */
  85342. verticesStart: number;
  85343. /** vertices count */
  85344. verticesCount: number;
  85345. /** index start */
  85346. indexStart: number;
  85347. /** indices count */
  85348. indexCount: number;
  85349. /** @hidden */
  85350. _linesIndexCount: number;
  85351. private _mesh;
  85352. private _renderingMesh;
  85353. private _boundingInfo;
  85354. private _linesIndexBuffer;
  85355. /** @hidden */
  85356. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85357. /** @hidden */
  85358. _trianglePlanes: Plane[];
  85359. /** @hidden */
  85360. _lastColliderTransformMatrix: Nullable<Matrix>;
  85361. /** @hidden */
  85362. _renderId: number;
  85363. /** @hidden */
  85364. _alphaIndex: number;
  85365. /** @hidden */
  85366. _distanceToCamera: number;
  85367. /** @hidden */
  85368. _id: number;
  85369. private _currentMaterial;
  85370. /**
  85371. * Add a new submesh to a mesh
  85372. * @param materialIndex defines the material index to use
  85373. * @param verticesStart defines vertex index start
  85374. * @param verticesCount defines vertices count
  85375. * @param indexStart defines index start
  85376. * @param indexCount defines indices count
  85377. * @param mesh defines the parent mesh
  85378. * @param renderingMesh defines an optional rendering mesh
  85379. * @param createBoundingBox defines if bounding box should be created for this submesh
  85380. * @returns the new submesh
  85381. */
  85382. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85383. /**
  85384. * Creates a new submesh
  85385. * @param materialIndex defines the material index to use
  85386. * @param verticesStart defines vertex index start
  85387. * @param verticesCount defines vertices count
  85388. * @param indexStart defines index start
  85389. * @param indexCount defines indices count
  85390. * @param mesh defines the parent mesh
  85391. * @param renderingMesh defines an optional rendering mesh
  85392. * @param createBoundingBox defines if bounding box should be created for this submesh
  85393. */
  85394. constructor(
  85395. /** the material index to use */
  85396. materialIndex: number,
  85397. /** vertex index start */
  85398. verticesStart: number,
  85399. /** vertices count */
  85400. verticesCount: number,
  85401. /** index start */
  85402. indexStart: number,
  85403. /** indices count */
  85404. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85405. /**
  85406. * Returns true if this submesh covers the entire parent mesh
  85407. * @ignorenaming
  85408. */
  85409. readonly IsGlobal: boolean;
  85410. /**
  85411. * Returns the submesh BoudingInfo object
  85412. * @returns current bounding info (or mesh's one if the submesh is global)
  85413. */
  85414. getBoundingInfo(): BoundingInfo;
  85415. /**
  85416. * Sets the submesh BoundingInfo
  85417. * @param boundingInfo defines the new bounding info to use
  85418. * @returns the SubMesh
  85419. */
  85420. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85421. /**
  85422. * Returns the mesh of the current submesh
  85423. * @return the parent mesh
  85424. */
  85425. getMesh(): AbstractMesh;
  85426. /**
  85427. * Returns the rendering mesh of the submesh
  85428. * @returns the rendering mesh (could be different from parent mesh)
  85429. */
  85430. getRenderingMesh(): Mesh;
  85431. /**
  85432. * Returns the submesh material
  85433. * @returns null or the current material
  85434. */
  85435. getMaterial(): Nullable<Material>;
  85436. /**
  85437. * Sets a new updated BoundingInfo object to the submesh
  85438. * @param data defines an optional position array to use to determine the bounding info
  85439. * @returns the SubMesh
  85440. */
  85441. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85442. /** @hidden */
  85443. _checkCollision(collider: Collider): boolean;
  85444. /**
  85445. * Updates the submesh BoundingInfo
  85446. * @param world defines the world matrix to use to update the bounding info
  85447. * @returns the submesh
  85448. */
  85449. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85450. /**
  85451. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85452. * @param frustumPlanes defines the frustum planes
  85453. * @returns true if the submesh is intersecting with the frustum
  85454. */
  85455. isInFrustum(frustumPlanes: Plane[]): boolean;
  85456. /**
  85457. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85458. * @param frustumPlanes defines the frustum planes
  85459. * @returns true if the submesh is inside the frustum
  85460. */
  85461. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85462. /**
  85463. * Renders the submesh
  85464. * @param enableAlphaMode defines if alpha needs to be used
  85465. * @returns the submesh
  85466. */
  85467. render(enableAlphaMode: boolean): SubMesh;
  85468. /**
  85469. * @hidden
  85470. */
  85471. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85472. /**
  85473. * Checks if the submesh intersects with a ray
  85474. * @param ray defines the ray to test
  85475. * @returns true is the passed ray intersects the submesh bounding box
  85476. */
  85477. canIntersects(ray: Ray): boolean;
  85478. /**
  85479. * Intersects current submesh with a ray
  85480. * @param ray defines the ray to test
  85481. * @param positions defines mesh's positions array
  85482. * @param indices defines mesh's indices array
  85483. * @param fastCheck defines if only bounding info should be used
  85484. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85485. * @returns intersection info or null if no intersection
  85486. */
  85487. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85488. /** @hidden */
  85489. private _intersectLines;
  85490. /** @hidden */
  85491. private _intersectUnIndexedLines;
  85492. /** @hidden */
  85493. private _intersectTriangles;
  85494. /** @hidden */
  85495. private _intersectUnIndexedTriangles;
  85496. /** @hidden */
  85497. _rebuild(): void;
  85498. /**
  85499. * Creates a new submesh from the passed mesh
  85500. * @param newMesh defines the new hosting mesh
  85501. * @param newRenderingMesh defines an optional rendering mesh
  85502. * @returns the new submesh
  85503. */
  85504. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85505. /**
  85506. * Release associated resources
  85507. */
  85508. dispose(): void;
  85509. /**
  85510. * Gets the class name
  85511. * @returns the string "SubMesh".
  85512. */
  85513. getClassName(): string;
  85514. /**
  85515. * Creates a new submesh from indices data
  85516. * @param materialIndex the index of the main mesh material
  85517. * @param startIndex the index where to start the copy in the mesh indices array
  85518. * @param indexCount the number of indices to copy then from the startIndex
  85519. * @param mesh the main mesh to create the submesh from
  85520. * @param renderingMesh the optional rendering mesh
  85521. * @returns a new submesh
  85522. */
  85523. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85524. }
  85525. }
  85526. declare module BABYLON {
  85527. /**
  85528. * Class used to store geometry data (vertex buffers + index buffer)
  85529. */
  85530. export class Geometry implements IGetSetVerticesData {
  85531. /**
  85532. * Gets or sets the ID of the geometry
  85533. */
  85534. id: string;
  85535. /**
  85536. * Gets or sets the unique ID of the geometry
  85537. */
  85538. uniqueId: number;
  85539. /**
  85540. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85541. */
  85542. delayLoadState: number;
  85543. /**
  85544. * Gets the file containing the data to load when running in delay load state
  85545. */
  85546. delayLoadingFile: Nullable<string>;
  85547. /**
  85548. * Callback called when the geometry is updated
  85549. */
  85550. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85551. private _scene;
  85552. private _engine;
  85553. private _meshes;
  85554. private _totalVertices;
  85555. /** @hidden */
  85556. _indices: IndicesArray;
  85557. /** @hidden */
  85558. _vertexBuffers: {
  85559. [key: string]: VertexBuffer;
  85560. };
  85561. private _isDisposed;
  85562. private _extend;
  85563. private _boundingBias;
  85564. /** @hidden */
  85565. _delayInfo: Array<string>;
  85566. private _indexBuffer;
  85567. private _indexBufferIsUpdatable;
  85568. /** @hidden */
  85569. _boundingInfo: Nullable<BoundingInfo>;
  85570. /** @hidden */
  85571. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85572. /** @hidden */
  85573. _softwareSkinningFrameId: number;
  85574. private _vertexArrayObjects;
  85575. private _updatable;
  85576. /** @hidden */
  85577. _positions: Nullable<Vector3[]>;
  85578. /**
  85579. * 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
  85580. */
  85581. /**
  85582. * 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
  85583. */
  85584. boundingBias: Vector2;
  85585. /**
  85586. * Static function used to attach a new empty geometry to a mesh
  85587. * @param mesh defines the mesh to attach the geometry to
  85588. * @returns the new Geometry
  85589. */
  85590. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85591. /**
  85592. * Creates a new geometry
  85593. * @param id defines the unique ID
  85594. * @param scene defines the hosting scene
  85595. * @param vertexData defines the VertexData used to get geometry data
  85596. * @param updatable defines if geometry must be updatable (false by default)
  85597. * @param mesh defines the mesh that will be associated with the geometry
  85598. */
  85599. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85600. /**
  85601. * Gets the current extend of the geometry
  85602. */
  85603. readonly extend: {
  85604. minimum: Vector3;
  85605. maximum: Vector3;
  85606. };
  85607. /**
  85608. * Gets the hosting scene
  85609. * @returns the hosting Scene
  85610. */
  85611. getScene(): Scene;
  85612. /**
  85613. * Gets the hosting engine
  85614. * @returns the hosting Engine
  85615. */
  85616. getEngine(): Engine;
  85617. /**
  85618. * Defines if the geometry is ready to use
  85619. * @returns true if the geometry is ready to be used
  85620. */
  85621. isReady(): boolean;
  85622. /**
  85623. * Gets a value indicating that the geometry should not be serialized
  85624. */
  85625. readonly doNotSerialize: boolean;
  85626. /** @hidden */
  85627. _rebuild(): void;
  85628. /**
  85629. * Affects all geometry data in one call
  85630. * @param vertexData defines the geometry data
  85631. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85632. */
  85633. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85634. /**
  85635. * Set specific vertex data
  85636. * @param kind defines the data kind (Position, normal, etc...)
  85637. * @param data defines the vertex data to use
  85638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85640. */
  85641. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85642. /**
  85643. * Removes a specific vertex data
  85644. * @param kind defines the data kind (Position, normal, etc...)
  85645. */
  85646. removeVerticesData(kind: string): void;
  85647. /**
  85648. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85649. * @param buffer defines the vertex buffer to use
  85650. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85651. */
  85652. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85653. /**
  85654. * Update a specific vertex buffer
  85655. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85656. * It will do nothing if the buffer is not updatable
  85657. * @param kind defines the data kind (Position, normal, etc...)
  85658. * @param data defines the data to use
  85659. * @param offset defines the offset in the target buffer where to store the data
  85660. * @param useBytes set to true if the offset is in bytes
  85661. */
  85662. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85663. /**
  85664. * Update a specific vertex buffer
  85665. * This function will create a new buffer if the current one is not updatable
  85666. * @param kind defines the data kind (Position, normal, etc...)
  85667. * @param data defines the data to use
  85668. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85669. */
  85670. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85671. private _updateBoundingInfo;
  85672. /** @hidden */
  85673. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85674. /**
  85675. * Gets total number of vertices
  85676. * @returns the total number of vertices
  85677. */
  85678. getTotalVertices(): number;
  85679. /**
  85680. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85681. * @param kind defines the data kind (Position, normal, etc...)
  85682. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85683. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85684. * @returns a float array containing vertex data
  85685. */
  85686. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85687. /**
  85688. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85689. * @param kind defines the data kind (Position, normal, etc...)
  85690. * @returns true if the vertex buffer with the specified kind is updatable
  85691. */
  85692. isVertexBufferUpdatable(kind: string): boolean;
  85693. /**
  85694. * Gets a specific vertex buffer
  85695. * @param kind defines the data kind (Position, normal, etc...)
  85696. * @returns a VertexBuffer
  85697. */
  85698. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85699. /**
  85700. * Returns all vertex buffers
  85701. * @return an object holding all vertex buffers indexed by kind
  85702. */
  85703. getVertexBuffers(): Nullable<{
  85704. [key: string]: VertexBuffer;
  85705. }>;
  85706. /**
  85707. * Gets a boolean indicating if specific vertex buffer is present
  85708. * @param kind defines the data kind (Position, normal, etc...)
  85709. * @returns true if data is present
  85710. */
  85711. isVerticesDataPresent(kind: string): boolean;
  85712. /**
  85713. * Gets a list of all attached data kinds (Position, normal, etc...)
  85714. * @returns a list of string containing all kinds
  85715. */
  85716. getVerticesDataKinds(): string[];
  85717. /**
  85718. * Update index buffer
  85719. * @param indices defines the indices to store in the index buffer
  85720. * @param offset defines the offset in the target buffer where to store the data
  85721. * @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)
  85722. */
  85723. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85724. /**
  85725. * Creates a new index buffer
  85726. * @param indices defines the indices to store in the index buffer
  85727. * @param totalVertices defines the total number of vertices (could be null)
  85728. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85729. */
  85730. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85731. /**
  85732. * Return the total number of indices
  85733. * @returns the total number of indices
  85734. */
  85735. getTotalIndices(): number;
  85736. /**
  85737. * Gets the index buffer array
  85738. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85739. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85740. * @returns the index buffer array
  85741. */
  85742. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85743. /**
  85744. * Gets the index buffer
  85745. * @return the index buffer
  85746. */
  85747. getIndexBuffer(): Nullable<DataBuffer>;
  85748. /** @hidden */
  85749. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85750. /**
  85751. * Release the associated resources for a specific mesh
  85752. * @param mesh defines the source mesh
  85753. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85754. */
  85755. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85756. /**
  85757. * Apply current geometry to a given mesh
  85758. * @param mesh defines the mesh to apply geometry to
  85759. */
  85760. applyToMesh(mesh: Mesh): void;
  85761. private _updateExtend;
  85762. private _applyToMesh;
  85763. private notifyUpdate;
  85764. /**
  85765. * Load the geometry if it was flagged as delay loaded
  85766. * @param scene defines the hosting scene
  85767. * @param onLoaded defines a callback called when the geometry is loaded
  85768. */
  85769. load(scene: Scene, onLoaded?: () => void): void;
  85770. private _queueLoad;
  85771. /**
  85772. * Invert the geometry to move from a right handed system to a left handed one.
  85773. */
  85774. toLeftHanded(): void;
  85775. /** @hidden */
  85776. _resetPointsArrayCache(): void;
  85777. /** @hidden */
  85778. _generatePointsArray(): boolean;
  85779. /**
  85780. * Gets a value indicating if the geometry is disposed
  85781. * @returns true if the geometry was disposed
  85782. */
  85783. isDisposed(): boolean;
  85784. private _disposeVertexArrayObjects;
  85785. /**
  85786. * Free all associated resources
  85787. */
  85788. dispose(): void;
  85789. /**
  85790. * Clone the current geometry into a new geometry
  85791. * @param id defines the unique ID of the new geometry
  85792. * @returns a new geometry object
  85793. */
  85794. copy(id: string): Geometry;
  85795. /**
  85796. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85797. * @return a JSON representation of the current geometry data (without the vertices data)
  85798. */
  85799. serialize(): any;
  85800. private toNumberArray;
  85801. /**
  85802. * Serialize all vertices data into a JSON oject
  85803. * @returns a JSON representation of the current geometry data
  85804. */
  85805. serializeVerticeData(): any;
  85806. /**
  85807. * Extracts a clone of a mesh geometry
  85808. * @param mesh defines the source mesh
  85809. * @param id defines the unique ID of the new geometry object
  85810. * @returns the new geometry object
  85811. */
  85812. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85813. /**
  85814. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85815. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85816. * Be aware Math.random() could cause collisions, but:
  85817. * "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"
  85818. * @returns a string containing a new GUID
  85819. */
  85820. static RandomId(): string;
  85821. /** @hidden */
  85822. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85823. private static _CleanMatricesWeights;
  85824. /**
  85825. * Create a new geometry from persisted data (Using .babylon file format)
  85826. * @param parsedVertexData defines the persisted data
  85827. * @param scene defines the hosting scene
  85828. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85829. * @returns the new geometry object
  85830. */
  85831. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85832. }
  85833. }
  85834. declare module BABYLON {
  85835. /**
  85836. * Define an interface for all classes that will get and set the data on vertices
  85837. */
  85838. export interface IGetSetVerticesData {
  85839. /**
  85840. * Gets a boolean indicating if specific vertex data is present
  85841. * @param kind defines the vertex data kind to use
  85842. * @returns true is data kind is present
  85843. */
  85844. isVerticesDataPresent(kind: string): boolean;
  85845. /**
  85846. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85847. * @param kind defines the data kind (Position, normal, etc...)
  85848. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85849. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85850. * @returns a float array containing vertex data
  85851. */
  85852. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85853. /**
  85854. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85855. * @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.
  85856. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85857. * @returns the indices array or an empty array if the mesh has no geometry
  85858. */
  85859. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85860. /**
  85861. * Set specific vertex data
  85862. * @param kind defines the data kind (Position, normal, etc...)
  85863. * @param data defines the vertex data to use
  85864. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85865. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85866. */
  85867. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85868. /**
  85869. * Update a specific associated vertex buffer
  85870. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85871. * - VertexBuffer.PositionKind
  85872. * - VertexBuffer.UVKind
  85873. * - VertexBuffer.UV2Kind
  85874. * - VertexBuffer.UV3Kind
  85875. * - VertexBuffer.UV4Kind
  85876. * - VertexBuffer.UV5Kind
  85877. * - VertexBuffer.UV6Kind
  85878. * - VertexBuffer.ColorKind
  85879. * - VertexBuffer.MatricesIndicesKind
  85880. * - VertexBuffer.MatricesIndicesExtraKind
  85881. * - VertexBuffer.MatricesWeightsKind
  85882. * - VertexBuffer.MatricesWeightsExtraKind
  85883. * @param data defines the data source
  85884. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85885. * @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)
  85886. */
  85887. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85888. /**
  85889. * Creates a new index buffer
  85890. * @param indices defines the indices to store in the index buffer
  85891. * @param totalVertices defines the total number of vertices (could be null)
  85892. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85893. */
  85894. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85895. }
  85896. /**
  85897. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85898. */
  85899. export class VertexData {
  85900. /**
  85901. * Mesh side orientation : usually the external or front surface
  85902. */
  85903. static readonly FRONTSIDE: number;
  85904. /**
  85905. * Mesh side orientation : usually the internal or back surface
  85906. */
  85907. static readonly BACKSIDE: number;
  85908. /**
  85909. * Mesh side orientation : both internal and external or front and back surfaces
  85910. */
  85911. static readonly DOUBLESIDE: number;
  85912. /**
  85913. * Mesh side orientation : by default, `FRONTSIDE`
  85914. */
  85915. static readonly DEFAULTSIDE: number;
  85916. /**
  85917. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85918. */
  85919. positions: Nullable<FloatArray>;
  85920. /**
  85921. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85922. */
  85923. normals: Nullable<FloatArray>;
  85924. /**
  85925. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85926. */
  85927. tangents: Nullable<FloatArray>;
  85928. /**
  85929. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85930. */
  85931. uvs: Nullable<FloatArray>;
  85932. /**
  85933. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85934. */
  85935. uvs2: Nullable<FloatArray>;
  85936. /**
  85937. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85938. */
  85939. uvs3: Nullable<FloatArray>;
  85940. /**
  85941. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85942. */
  85943. uvs4: Nullable<FloatArray>;
  85944. /**
  85945. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85946. */
  85947. uvs5: Nullable<FloatArray>;
  85948. /**
  85949. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85950. */
  85951. uvs6: Nullable<FloatArray>;
  85952. /**
  85953. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85954. */
  85955. colors: Nullable<FloatArray>;
  85956. /**
  85957. * 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).
  85958. */
  85959. matricesIndices: Nullable<FloatArray>;
  85960. /**
  85961. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85962. */
  85963. matricesWeights: Nullable<FloatArray>;
  85964. /**
  85965. * An array extending the number of possible indices
  85966. */
  85967. matricesIndicesExtra: Nullable<FloatArray>;
  85968. /**
  85969. * An array extending the number of possible weights when the number of indices is extended
  85970. */
  85971. matricesWeightsExtra: Nullable<FloatArray>;
  85972. /**
  85973. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85974. */
  85975. indices: Nullable<IndicesArray>;
  85976. /**
  85977. * Uses the passed data array to set the set the values for the specified kind of data
  85978. * @param data a linear array of floating numbers
  85979. * @param kind the type of data that is being set, eg positions, colors etc
  85980. */
  85981. set(data: FloatArray, kind: string): void;
  85982. /**
  85983. * Associates the vertexData to the passed Mesh.
  85984. * Sets it as updatable or not (default `false`)
  85985. * @param mesh the mesh the vertexData is applied to
  85986. * @param updatable when used and having the value true allows new data to update the vertexData
  85987. * @returns the VertexData
  85988. */
  85989. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85990. /**
  85991. * Associates the vertexData to the passed Geometry.
  85992. * Sets it as updatable or not (default `false`)
  85993. * @param geometry the geometry the vertexData is applied to
  85994. * @param updatable when used and having the value true allows new data to update the vertexData
  85995. * @returns VertexData
  85996. */
  85997. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85998. /**
  85999. * Updates the associated mesh
  86000. * @param mesh the mesh to be updated
  86001. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86002. * @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
  86003. * @returns VertexData
  86004. */
  86005. updateMesh(mesh: Mesh): VertexData;
  86006. /**
  86007. * Updates the associated geometry
  86008. * @param geometry the geometry to be updated
  86009. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86010. * @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
  86011. * @returns VertexData.
  86012. */
  86013. updateGeometry(geometry: Geometry): VertexData;
  86014. private _applyTo;
  86015. private _update;
  86016. /**
  86017. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86018. * @param matrix the transforming matrix
  86019. * @returns the VertexData
  86020. */
  86021. transform(matrix: Matrix): VertexData;
  86022. /**
  86023. * Merges the passed VertexData into the current one
  86024. * @param other the VertexData to be merged into the current one
  86025. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86026. * @returns the modified VertexData
  86027. */
  86028. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86029. private _mergeElement;
  86030. private _validate;
  86031. /**
  86032. * Serializes the VertexData
  86033. * @returns a serialized object
  86034. */
  86035. serialize(): any;
  86036. /**
  86037. * Extracts the vertexData from a mesh
  86038. * @param mesh the mesh from which to extract the VertexData
  86039. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86040. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86041. * @returns the object VertexData associated to the passed mesh
  86042. */
  86043. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86044. /**
  86045. * Extracts the vertexData from the geometry
  86046. * @param geometry the geometry from which to extract the VertexData
  86047. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86048. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86049. * @returns the object VertexData associated to the passed mesh
  86050. */
  86051. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86052. private static _ExtractFrom;
  86053. /**
  86054. * Creates the VertexData for a Ribbon
  86055. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86056. * * pathArray array of paths, each of which an array of successive Vector3
  86057. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86058. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86059. * * 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
  86060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86061. * * 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)
  86062. * * 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)
  86063. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86064. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86065. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86066. * @returns the VertexData of the ribbon
  86067. */
  86068. static CreateRibbon(options: {
  86069. pathArray: Vector3[][];
  86070. closeArray?: boolean;
  86071. closePath?: boolean;
  86072. offset?: number;
  86073. sideOrientation?: number;
  86074. frontUVs?: Vector4;
  86075. backUVs?: Vector4;
  86076. invertUV?: boolean;
  86077. uvs?: Vector2[];
  86078. colors?: Color4[];
  86079. }): VertexData;
  86080. /**
  86081. * Creates the VertexData for a box
  86082. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86083. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86084. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86085. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86086. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86087. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86088. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86090. * * 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)
  86091. * * 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)
  86092. * @returns the VertexData of the box
  86093. */
  86094. static CreateBox(options: {
  86095. size?: number;
  86096. width?: number;
  86097. height?: number;
  86098. depth?: number;
  86099. faceUV?: Vector4[];
  86100. faceColors?: Color4[];
  86101. sideOrientation?: number;
  86102. frontUVs?: Vector4;
  86103. backUVs?: Vector4;
  86104. }): VertexData;
  86105. /**
  86106. * Creates the VertexData for a tiled box
  86107. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86108. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86109. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86110. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86112. * @returns the VertexData of the box
  86113. */
  86114. static CreateTiledBox(options: {
  86115. pattern?: number;
  86116. width?: number;
  86117. height?: number;
  86118. depth?: number;
  86119. tileSize?: number;
  86120. tileWidth?: number;
  86121. tileHeight?: number;
  86122. alignHorizontal?: number;
  86123. alignVertical?: number;
  86124. faceUV?: Vector4[];
  86125. faceColors?: Color4[];
  86126. sideOrientation?: number;
  86127. }): VertexData;
  86128. /**
  86129. * Creates the VertexData for a tiled plane
  86130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86131. * * pattern a limited pattern arrangement depending on the number
  86132. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86133. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86134. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86136. * * 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)
  86137. * * 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)
  86138. * @returns the VertexData of the tiled plane
  86139. */
  86140. static CreateTiledPlane(options: {
  86141. pattern?: number;
  86142. tileSize?: number;
  86143. tileWidth?: number;
  86144. tileHeight?: number;
  86145. size?: number;
  86146. width?: number;
  86147. height?: number;
  86148. alignHorizontal?: number;
  86149. alignVertical?: number;
  86150. sideOrientation?: number;
  86151. frontUVs?: Vector4;
  86152. backUVs?: Vector4;
  86153. }): VertexData;
  86154. /**
  86155. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86156. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86157. * * segments sets the number of horizontal strips optional, default 32
  86158. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86159. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86160. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86161. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86162. * * 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
  86163. * * 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
  86164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86165. * * 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)
  86166. * * 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)
  86167. * @returns the VertexData of the ellipsoid
  86168. */
  86169. static CreateSphere(options: {
  86170. segments?: number;
  86171. diameter?: number;
  86172. diameterX?: number;
  86173. diameterY?: number;
  86174. diameterZ?: number;
  86175. arc?: number;
  86176. slice?: number;
  86177. sideOrientation?: number;
  86178. frontUVs?: Vector4;
  86179. backUVs?: Vector4;
  86180. }): VertexData;
  86181. /**
  86182. * Creates the VertexData for a cylinder, cone or prism
  86183. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86184. * * height sets the height (y direction) of the cylinder, optional, default 2
  86185. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86186. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86187. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86188. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86189. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86190. * * 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
  86191. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86192. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86193. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86194. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86196. * * 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)
  86197. * * 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)
  86198. * @returns the VertexData of the cylinder, cone or prism
  86199. */
  86200. static CreateCylinder(options: {
  86201. height?: number;
  86202. diameterTop?: number;
  86203. diameterBottom?: number;
  86204. diameter?: number;
  86205. tessellation?: number;
  86206. subdivisions?: number;
  86207. arc?: number;
  86208. faceColors?: Color4[];
  86209. faceUV?: Vector4[];
  86210. hasRings?: boolean;
  86211. enclose?: boolean;
  86212. sideOrientation?: number;
  86213. frontUVs?: Vector4;
  86214. backUVs?: Vector4;
  86215. }): VertexData;
  86216. /**
  86217. * Creates the VertexData for a torus
  86218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86219. * * diameter the diameter of the torus, optional default 1
  86220. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86221. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86223. * * 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)
  86224. * * 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)
  86225. * @returns the VertexData of the torus
  86226. */
  86227. static CreateTorus(options: {
  86228. diameter?: number;
  86229. thickness?: number;
  86230. tessellation?: number;
  86231. sideOrientation?: number;
  86232. frontUVs?: Vector4;
  86233. backUVs?: Vector4;
  86234. }): VertexData;
  86235. /**
  86236. * Creates the VertexData of the LineSystem
  86237. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86238. * - lines an array of lines, each line being an array of successive Vector3
  86239. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86240. * @returns the VertexData of the LineSystem
  86241. */
  86242. static CreateLineSystem(options: {
  86243. lines: Vector3[][];
  86244. colors?: Nullable<Color4[][]>;
  86245. }): VertexData;
  86246. /**
  86247. * Create the VertexData for a DashedLines
  86248. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86249. * - points an array successive Vector3
  86250. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86251. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86252. * - dashNb the intended total number of dashes, optional, default 200
  86253. * @returns the VertexData for the DashedLines
  86254. */
  86255. static CreateDashedLines(options: {
  86256. points: Vector3[];
  86257. dashSize?: number;
  86258. gapSize?: number;
  86259. dashNb?: number;
  86260. }): VertexData;
  86261. /**
  86262. * Creates the VertexData for a Ground
  86263. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86264. * - width the width (x direction) of the ground, optional, default 1
  86265. * - height the height (z direction) of the ground, optional, default 1
  86266. * - subdivisions the number of subdivisions per side, optional, default 1
  86267. * @returns the VertexData of the Ground
  86268. */
  86269. static CreateGround(options: {
  86270. width?: number;
  86271. height?: number;
  86272. subdivisions?: number;
  86273. subdivisionsX?: number;
  86274. subdivisionsY?: number;
  86275. }): VertexData;
  86276. /**
  86277. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86279. * * xmin the ground minimum X coordinate, optional, default -1
  86280. * * zmin the ground minimum Z coordinate, optional, default -1
  86281. * * xmax the ground maximum X coordinate, optional, default 1
  86282. * * zmax the ground maximum Z coordinate, optional, default 1
  86283. * * 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}
  86284. * * 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}
  86285. * @returns the VertexData of the TiledGround
  86286. */
  86287. static CreateTiledGround(options: {
  86288. xmin: number;
  86289. zmin: number;
  86290. xmax: number;
  86291. zmax: number;
  86292. subdivisions?: {
  86293. w: number;
  86294. h: number;
  86295. };
  86296. precision?: {
  86297. w: number;
  86298. h: number;
  86299. };
  86300. }): VertexData;
  86301. /**
  86302. * Creates the VertexData of the Ground designed from a heightmap
  86303. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86304. * * width the width (x direction) of the ground
  86305. * * height the height (z direction) of the ground
  86306. * * subdivisions the number of subdivisions per side
  86307. * * minHeight the minimum altitude on the ground, optional, default 0
  86308. * * maxHeight the maximum altitude on the ground, optional default 1
  86309. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86310. * * buffer the array holding the image color data
  86311. * * bufferWidth the width of image
  86312. * * bufferHeight the height of image
  86313. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86314. * @returns the VertexData of the Ground designed from a heightmap
  86315. */
  86316. static CreateGroundFromHeightMap(options: {
  86317. width: number;
  86318. height: number;
  86319. subdivisions: number;
  86320. minHeight: number;
  86321. maxHeight: number;
  86322. colorFilter: Color3;
  86323. buffer: Uint8Array;
  86324. bufferWidth: number;
  86325. bufferHeight: number;
  86326. alphaFilter: number;
  86327. }): VertexData;
  86328. /**
  86329. * Creates the VertexData for a Plane
  86330. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86331. * * size sets the width and height of the plane to the value of size, optional default 1
  86332. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86333. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86335. * * 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)
  86336. * * 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)
  86337. * @returns the VertexData of the box
  86338. */
  86339. static CreatePlane(options: {
  86340. size?: number;
  86341. width?: number;
  86342. height?: number;
  86343. sideOrientation?: number;
  86344. frontUVs?: Vector4;
  86345. backUVs?: Vector4;
  86346. }): VertexData;
  86347. /**
  86348. * Creates the VertexData of the Disc or regular Polygon
  86349. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86350. * * radius the radius of the disc, optional default 0.5
  86351. * * tessellation the number of polygon sides, optional, default 64
  86352. * * 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
  86353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86354. * * 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)
  86355. * * 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)
  86356. * @returns the VertexData of the box
  86357. */
  86358. static CreateDisc(options: {
  86359. radius?: number;
  86360. tessellation?: number;
  86361. arc?: number;
  86362. sideOrientation?: number;
  86363. frontUVs?: Vector4;
  86364. backUVs?: Vector4;
  86365. }): VertexData;
  86366. /**
  86367. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86368. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86369. * @param polygon a mesh built from polygonTriangulation.build()
  86370. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86371. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86372. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86373. * @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)
  86374. * @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)
  86375. * @returns the VertexData of the Polygon
  86376. */
  86377. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86378. /**
  86379. * Creates the VertexData of the IcoSphere
  86380. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86381. * * radius the radius of the IcoSphere, optional default 1
  86382. * * radiusX allows stretching in the x direction, optional, default radius
  86383. * * radiusY allows stretching in the y direction, optional, default radius
  86384. * * radiusZ allows stretching in the z direction, optional, default radius
  86385. * * flat when true creates a flat shaded mesh, optional, default true
  86386. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86387. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86388. * * 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)
  86389. * * 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)
  86390. * @returns the VertexData of the IcoSphere
  86391. */
  86392. static CreateIcoSphere(options: {
  86393. radius?: number;
  86394. radiusX?: number;
  86395. radiusY?: number;
  86396. radiusZ?: number;
  86397. flat?: boolean;
  86398. subdivisions?: number;
  86399. sideOrientation?: number;
  86400. frontUVs?: Vector4;
  86401. backUVs?: Vector4;
  86402. }): VertexData;
  86403. /**
  86404. * Creates the VertexData for a Polyhedron
  86405. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86406. * * type provided types are:
  86407. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86408. * * 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)
  86409. * * size the size of the IcoSphere, optional default 1
  86410. * * sizeX allows stretching in the x direction, optional, default size
  86411. * * sizeY allows stretching in the y direction, optional, default size
  86412. * * sizeZ allows stretching in the z direction, optional, default size
  86413. * * 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
  86414. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86415. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86416. * * flat when true creates a flat shaded mesh, optional, default true
  86417. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86419. * * 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)
  86420. * * 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)
  86421. * @returns the VertexData of the Polyhedron
  86422. */
  86423. static CreatePolyhedron(options: {
  86424. type?: number;
  86425. size?: number;
  86426. sizeX?: number;
  86427. sizeY?: number;
  86428. sizeZ?: number;
  86429. custom?: any;
  86430. faceUV?: Vector4[];
  86431. faceColors?: Color4[];
  86432. flat?: boolean;
  86433. sideOrientation?: number;
  86434. frontUVs?: Vector4;
  86435. backUVs?: Vector4;
  86436. }): VertexData;
  86437. /**
  86438. * Creates the VertexData for a TorusKnot
  86439. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86440. * * radius the radius of the torus knot, optional, default 2
  86441. * * tube the thickness of the tube, optional, default 0.5
  86442. * * radialSegments the number of sides on each tube segments, optional, default 32
  86443. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86444. * * p the number of windings around the z axis, optional, default 2
  86445. * * q the number of windings around the x axis, optional, default 3
  86446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86447. * * 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)
  86448. * * 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)
  86449. * @returns the VertexData of the Torus Knot
  86450. */
  86451. static CreateTorusKnot(options: {
  86452. radius?: number;
  86453. tube?: number;
  86454. radialSegments?: number;
  86455. tubularSegments?: number;
  86456. p?: number;
  86457. q?: number;
  86458. sideOrientation?: number;
  86459. frontUVs?: Vector4;
  86460. backUVs?: Vector4;
  86461. }): VertexData;
  86462. /**
  86463. * Compute normals for given positions and indices
  86464. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86465. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86466. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86467. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86468. * * facetNormals : optional array of facet normals (vector3)
  86469. * * facetPositions : optional array of facet positions (vector3)
  86470. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86471. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86472. * * bInfo : optional bounding info, required for facetPartitioning computation
  86473. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86474. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86475. * * useRightHandedSystem: optional boolean to for right handed system computation
  86476. * * depthSort : optional boolean to enable the facet depth sort computation
  86477. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86478. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86479. */
  86480. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86481. facetNormals?: any;
  86482. facetPositions?: any;
  86483. facetPartitioning?: any;
  86484. ratio?: number;
  86485. bInfo?: any;
  86486. bbSize?: Vector3;
  86487. subDiv?: any;
  86488. useRightHandedSystem?: boolean;
  86489. depthSort?: boolean;
  86490. distanceTo?: Vector3;
  86491. depthSortedFacets?: any;
  86492. }): void;
  86493. /** @hidden */
  86494. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86495. /**
  86496. * Applies VertexData created from the imported parameters to the geometry
  86497. * @param parsedVertexData the parsed data from an imported file
  86498. * @param geometry the geometry to apply the VertexData to
  86499. */
  86500. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86501. }
  86502. }
  86503. declare module BABYLON {
  86504. /**
  86505. * Class containing static functions to help procedurally build meshes
  86506. */
  86507. export class DiscBuilder {
  86508. /**
  86509. * Creates a plane polygonal mesh. By default, this is a disc
  86510. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86511. * * 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
  86512. * * 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
  86513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86516. * @param name defines the name of the mesh
  86517. * @param options defines the options used to create the mesh
  86518. * @param scene defines the hosting scene
  86519. * @returns the plane polygonal mesh
  86520. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86521. */
  86522. static CreateDisc(name: string, options: {
  86523. radius?: number;
  86524. tessellation?: number;
  86525. arc?: number;
  86526. updatable?: boolean;
  86527. sideOrientation?: number;
  86528. frontUVs?: Vector4;
  86529. backUVs?: Vector4;
  86530. }, scene?: Nullable<Scene>): Mesh;
  86531. }
  86532. }
  86533. declare module BABYLON {
  86534. /**
  86535. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86536. *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.
  86537. * The SPS is also a particle system. It provides some methods to manage the particles.
  86538. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86539. *
  86540. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86541. */
  86542. export class SolidParticleSystem implements IDisposable {
  86543. /**
  86544. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86545. * Example : var p = SPS.particles[i];
  86546. */
  86547. particles: SolidParticle[];
  86548. /**
  86549. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86550. */
  86551. nbParticles: number;
  86552. /**
  86553. * If the particles must ever face the camera (default false). Useful for planar particles.
  86554. */
  86555. billboard: boolean;
  86556. /**
  86557. * Recompute normals when adding a shape
  86558. */
  86559. recomputeNormals: boolean;
  86560. /**
  86561. * This a counter ofr your own usage. It's not set by any SPS functions.
  86562. */
  86563. counter: number;
  86564. /**
  86565. * The SPS name. This name is also given to the underlying mesh.
  86566. */
  86567. name: string;
  86568. /**
  86569. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86570. */
  86571. mesh: Mesh;
  86572. /**
  86573. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86574. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86575. */
  86576. vars: any;
  86577. /**
  86578. * This array is populated when the SPS is set as 'pickable'.
  86579. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86580. * Each element of this array is an object `{idx: int, faceId: int}`.
  86581. * `idx` is the picked particle index in the `SPS.particles` array
  86582. * `faceId` is the picked face index counted within this particle.
  86583. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86584. */
  86585. pickedParticles: {
  86586. idx: number;
  86587. faceId: number;
  86588. }[];
  86589. /**
  86590. * This array is populated when `enableDepthSort` is set to true.
  86591. * Each element of this array is an instance of the class DepthSortedParticle.
  86592. */
  86593. depthSortedParticles: DepthSortedParticle[];
  86594. /**
  86595. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86596. * @hidden
  86597. */
  86598. _bSphereOnly: boolean;
  86599. /**
  86600. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86601. * @hidden
  86602. */
  86603. _bSphereRadiusFactor: number;
  86604. private _scene;
  86605. private _positions;
  86606. private _indices;
  86607. private _normals;
  86608. private _colors;
  86609. private _uvs;
  86610. private _indices32;
  86611. private _positions32;
  86612. private _normals32;
  86613. private _fixedNormal32;
  86614. private _colors32;
  86615. private _uvs32;
  86616. private _index;
  86617. private _updatable;
  86618. private _pickable;
  86619. private _isVisibilityBoxLocked;
  86620. private _alwaysVisible;
  86621. private _depthSort;
  86622. private _shapeCounter;
  86623. private _copy;
  86624. private _color;
  86625. private _computeParticleColor;
  86626. private _computeParticleTexture;
  86627. private _computeParticleRotation;
  86628. private _computeParticleVertex;
  86629. private _computeBoundingBox;
  86630. private _depthSortParticles;
  86631. private _camera;
  86632. private _mustUnrotateFixedNormals;
  86633. private _particlesIntersect;
  86634. private _needs32Bits;
  86635. /**
  86636. * Creates a SPS (Solid Particle System) object.
  86637. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86638. * @param scene (Scene) is the scene in which the SPS is added.
  86639. * @param options defines the options of the sps e.g.
  86640. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86641. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86642. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86643. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86644. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86645. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86646. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86647. */
  86648. constructor(name: string, scene: Scene, options?: {
  86649. updatable?: boolean;
  86650. isPickable?: boolean;
  86651. enableDepthSort?: boolean;
  86652. particleIntersection?: boolean;
  86653. boundingSphereOnly?: boolean;
  86654. bSphereRadiusFactor?: number;
  86655. });
  86656. /**
  86657. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86658. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86659. * @returns the created mesh
  86660. */
  86661. buildMesh(): Mesh;
  86662. /**
  86663. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86664. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86665. * Thus the particles generated from `digest()` have their property `position` set yet.
  86666. * @param mesh ( Mesh ) is the mesh to be digested
  86667. * @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
  86668. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86669. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86670. * @returns the current SPS
  86671. */
  86672. digest(mesh: Mesh, options?: {
  86673. facetNb?: number;
  86674. number?: number;
  86675. delta?: number;
  86676. }): SolidParticleSystem;
  86677. private _unrotateFixedNormals;
  86678. private _resetCopy;
  86679. private _meshBuilder;
  86680. private _posToShape;
  86681. private _uvsToShapeUV;
  86682. private _addParticle;
  86683. /**
  86684. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86685. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86686. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86687. * @param nb (positive integer) the number of particles to be created from this model
  86688. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86689. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86690. * @returns the number of shapes in the system
  86691. */
  86692. addShape(mesh: Mesh, nb: number, options?: {
  86693. positionFunction?: any;
  86694. vertexFunction?: any;
  86695. }): number;
  86696. private _rebuildParticle;
  86697. /**
  86698. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86699. * @returns the SPS.
  86700. */
  86701. rebuildMesh(): SolidParticleSystem;
  86702. /**
  86703. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86704. * This method calls `updateParticle()` for each particle of the SPS.
  86705. * For an animated SPS, it is usually called within the render loop.
  86706. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86707. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86708. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86709. * @returns the SPS.
  86710. */
  86711. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86712. /**
  86713. * Disposes the SPS.
  86714. */
  86715. dispose(): void;
  86716. /**
  86717. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86719. * @returns the SPS.
  86720. */
  86721. refreshVisibleSize(): SolidParticleSystem;
  86722. /**
  86723. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86724. * @param size the size (float) of the visibility box
  86725. * note : this doesn't lock the SPS mesh bounding box.
  86726. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86727. */
  86728. setVisibilityBox(size: number): void;
  86729. /**
  86730. * Gets whether the SPS as always visible or not
  86731. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86732. */
  86733. /**
  86734. * Sets the SPS as always visible or not
  86735. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86736. */
  86737. isAlwaysVisible: boolean;
  86738. /**
  86739. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86740. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86741. */
  86742. /**
  86743. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86745. */
  86746. isVisibilityBoxLocked: boolean;
  86747. /**
  86748. * Tells to `setParticles()` to compute the particle rotations or not.
  86749. * Default value : true. The SPS is faster when it's set to false.
  86750. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86751. */
  86752. /**
  86753. * Gets if `setParticles()` computes the particle rotations or not.
  86754. * Default value : true. The SPS is faster when it's set to false.
  86755. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86756. */
  86757. computeParticleRotation: boolean;
  86758. /**
  86759. * Tells to `setParticles()` to compute the particle colors or not.
  86760. * Default value : true. The SPS is faster when it's set to false.
  86761. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86762. */
  86763. /**
  86764. * Gets if `setParticles()` computes the particle colors or not.
  86765. * Default value : true. The SPS is faster when it's set to false.
  86766. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86767. */
  86768. computeParticleColor: boolean;
  86769. /**
  86770. * Gets if `setParticles()` computes the particle textures or not.
  86771. * Default value : true. The SPS is faster when it's set to false.
  86772. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86773. */
  86774. computeParticleTexture: boolean;
  86775. /**
  86776. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86777. * Default value : false. The SPS is faster when it's set to false.
  86778. * Note : the particle custom vertex positions aren't stored values.
  86779. */
  86780. /**
  86781. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86782. * Default value : false. The SPS is faster when it's set to false.
  86783. * Note : the particle custom vertex positions aren't stored values.
  86784. */
  86785. computeParticleVertex: boolean;
  86786. /**
  86787. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86788. */
  86789. /**
  86790. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86791. */
  86792. computeBoundingBox: boolean;
  86793. /**
  86794. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86795. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86796. * Default : `true`
  86797. */
  86798. /**
  86799. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86800. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86801. * Default : `true`
  86802. */
  86803. depthSortParticles: boolean;
  86804. /**
  86805. * This function does nothing. It may be overwritten to set all the particle first values.
  86806. * The SPS doesn't call this function, you may have to call it by your own.
  86807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86808. */
  86809. initParticles(): void;
  86810. /**
  86811. * This function does nothing. It may be overwritten to recycle a particle.
  86812. * The SPS doesn't call this function, you may have to call it by your own.
  86813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86814. * @param particle The particle to recycle
  86815. * @returns the recycled particle
  86816. */
  86817. recycleParticle(particle: SolidParticle): SolidParticle;
  86818. /**
  86819. * Updates a particle : this function should be overwritten by the user.
  86820. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86822. * @example : just set a particle position or velocity and recycle conditions
  86823. * @param particle The particle to update
  86824. * @returns the updated particle
  86825. */
  86826. updateParticle(particle: SolidParticle): SolidParticle;
  86827. /**
  86828. * Updates a vertex of a particle : it can be overwritten by the user.
  86829. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86830. * @param particle the current particle
  86831. * @param vertex the current index of the current particle
  86832. * @param pt the index of the current vertex in the particle shape
  86833. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86834. * @example : just set a vertex particle position
  86835. * @returns the updated vertex
  86836. */
  86837. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86838. /**
  86839. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86840. * This does nothing and may be overwritten by the user.
  86841. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86842. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86843. * @param update the boolean update value actually passed to setParticles()
  86844. */
  86845. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86846. /**
  86847. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86848. * This will be passed three parameters.
  86849. * This does nothing and may be overwritten by the user.
  86850. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86852. * @param update the boolean update value actually passed to setParticles()
  86853. */
  86854. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86855. }
  86856. }
  86857. declare module BABYLON {
  86858. /**
  86859. * Represents one particle of a solid particle system.
  86860. */
  86861. export class SolidParticle {
  86862. /**
  86863. * particle global index
  86864. */
  86865. idx: number;
  86866. /**
  86867. * The color of the particle
  86868. */
  86869. color: Nullable<Color4>;
  86870. /**
  86871. * The world space position of the particle.
  86872. */
  86873. position: Vector3;
  86874. /**
  86875. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86876. */
  86877. rotation: Vector3;
  86878. /**
  86879. * The world space rotation quaternion of the particle.
  86880. */
  86881. rotationQuaternion: Nullable<Quaternion>;
  86882. /**
  86883. * The scaling of the particle.
  86884. */
  86885. scaling: Vector3;
  86886. /**
  86887. * The uvs of the particle.
  86888. */
  86889. uvs: Vector4;
  86890. /**
  86891. * The current speed of the particle.
  86892. */
  86893. velocity: Vector3;
  86894. /**
  86895. * The pivot point in the particle local space.
  86896. */
  86897. pivot: Vector3;
  86898. /**
  86899. * Must the particle be translated from its pivot point in its local space ?
  86900. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86901. * Default : false
  86902. */
  86903. translateFromPivot: boolean;
  86904. /**
  86905. * Is the particle active or not ?
  86906. */
  86907. alive: boolean;
  86908. /**
  86909. * Is the particle visible or not ?
  86910. */
  86911. isVisible: boolean;
  86912. /**
  86913. * Index of this particle in the global "positions" array (Internal use)
  86914. * @hidden
  86915. */
  86916. _pos: number;
  86917. /**
  86918. * @hidden Index of this particle in the global "indices" array (Internal use)
  86919. */
  86920. _ind: number;
  86921. /**
  86922. * @hidden ModelShape of this particle (Internal use)
  86923. */
  86924. _model: ModelShape;
  86925. /**
  86926. * ModelShape id of this particle
  86927. */
  86928. shapeId: number;
  86929. /**
  86930. * Index of the particle in its shape id (Internal use)
  86931. */
  86932. idxInShape: number;
  86933. /**
  86934. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86935. */
  86936. _modelBoundingInfo: BoundingInfo;
  86937. /**
  86938. * @hidden Particle BoundingInfo object (Internal use)
  86939. */
  86940. _boundingInfo: BoundingInfo;
  86941. /**
  86942. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86943. */
  86944. _sps: SolidParticleSystem;
  86945. /**
  86946. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86947. */
  86948. _stillInvisible: boolean;
  86949. /**
  86950. * @hidden Last computed particle rotation matrix
  86951. */
  86952. _rotationMatrix: number[];
  86953. /**
  86954. * Parent particle Id, if any.
  86955. * Default null.
  86956. */
  86957. parentId: Nullable<number>;
  86958. /**
  86959. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86960. * The possible values are :
  86961. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86962. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86963. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86965. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86966. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86967. * */
  86968. cullingStrategy: number;
  86969. /**
  86970. * @hidden Internal global position in the SPS.
  86971. */
  86972. _globalPosition: Vector3;
  86973. /**
  86974. * Creates a Solid Particle object.
  86975. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86976. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86977. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86978. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86979. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86980. * @param shapeId (integer) is the model shape identifier in the SPS.
  86981. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86982. * @param sps defines the sps it is associated to
  86983. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86984. */
  86985. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86986. /**
  86987. * Legacy support, changed scale to scaling
  86988. */
  86989. /**
  86990. * Legacy support, changed scale to scaling
  86991. */
  86992. scale: Vector3;
  86993. /**
  86994. * Legacy support, changed quaternion to rotationQuaternion
  86995. */
  86996. /**
  86997. * Legacy support, changed quaternion to rotationQuaternion
  86998. */
  86999. quaternion: Nullable<Quaternion>;
  87000. /**
  87001. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  87002. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  87003. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  87004. * @returns true if it intersects
  87005. */
  87006. intersectsMesh(target: Mesh | SolidParticle): boolean;
  87007. /**
  87008. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  87009. * A particle is in the frustum if its bounding box intersects the frustum
  87010. * @param frustumPlanes defines the frustum to test
  87011. * @returns true if the particle is in the frustum planes
  87012. */
  87013. isInFrustum(frustumPlanes: Plane[]): boolean;
  87014. /**
  87015. * get the rotation matrix of the particle
  87016. * @hidden
  87017. */
  87018. getRotationMatrix(m: Matrix): void;
  87019. }
  87020. /**
  87021. * Represents the shape of the model used by one particle of a solid particle system.
  87022. * SPS internal tool, don't use it manually.
  87023. */
  87024. export class ModelShape {
  87025. /**
  87026. * The shape id
  87027. * @hidden
  87028. */
  87029. shapeID: number;
  87030. /**
  87031. * flat array of model positions (internal use)
  87032. * @hidden
  87033. */
  87034. _shape: Vector3[];
  87035. /**
  87036. * flat array of model UVs (internal use)
  87037. * @hidden
  87038. */
  87039. _shapeUV: number[];
  87040. /**
  87041. * length of the shape in the model indices array (internal use)
  87042. * @hidden
  87043. */
  87044. _indicesLength: number;
  87045. /**
  87046. * Custom position function (internal use)
  87047. * @hidden
  87048. */
  87049. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87050. /**
  87051. * Custom vertex function (internal use)
  87052. * @hidden
  87053. */
  87054. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87055. /**
  87056. * 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.
  87057. * SPS internal tool, don't use it manually.
  87058. * @hidden
  87059. */
  87060. 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>);
  87061. }
  87062. /**
  87063. * Represents a Depth Sorted Particle in the solid particle system.
  87064. */
  87065. export class DepthSortedParticle {
  87066. /**
  87067. * Index of the particle in the "indices" array
  87068. */
  87069. ind: number;
  87070. /**
  87071. * Length of the particle shape in the "indices" array
  87072. */
  87073. indicesLength: number;
  87074. /**
  87075. * Squared distance from the particle to the camera
  87076. */
  87077. sqDistance: number;
  87078. }
  87079. }
  87080. declare module BABYLON {
  87081. /**
  87082. * @hidden
  87083. */
  87084. export class _MeshCollisionData {
  87085. _checkCollisions: boolean;
  87086. _collisionMask: number;
  87087. _collisionGroup: number;
  87088. _collider: Nullable<Collider>;
  87089. _oldPositionForCollisions: Vector3;
  87090. _diffPositionForCollisions: Vector3;
  87091. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87092. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87093. }
  87094. }
  87095. declare module BABYLON {
  87096. /** @hidden */
  87097. class _FacetDataStorage {
  87098. facetPositions: Vector3[];
  87099. facetNormals: Vector3[];
  87100. facetPartitioning: number[][];
  87101. facetNb: number;
  87102. partitioningSubdivisions: number;
  87103. partitioningBBoxRatio: number;
  87104. facetDataEnabled: boolean;
  87105. facetParameters: any;
  87106. bbSize: Vector3;
  87107. subDiv: {
  87108. max: number;
  87109. X: number;
  87110. Y: number;
  87111. Z: number;
  87112. };
  87113. facetDepthSort: boolean;
  87114. facetDepthSortEnabled: boolean;
  87115. depthSortedIndices: IndicesArray;
  87116. depthSortedFacets: {
  87117. ind: number;
  87118. sqDistance: number;
  87119. }[];
  87120. facetDepthSortFunction: (f1: {
  87121. ind: number;
  87122. sqDistance: number;
  87123. }, f2: {
  87124. ind: number;
  87125. sqDistance: number;
  87126. }) => number;
  87127. facetDepthSortFrom: Vector3;
  87128. facetDepthSortOrigin: Vector3;
  87129. invertedMatrix: Matrix;
  87130. }
  87131. /**
  87132. * @hidden
  87133. **/
  87134. class _InternalAbstractMeshDataInfo {
  87135. _hasVertexAlpha: boolean;
  87136. _useVertexColors: boolean;
  87137. _numBoneInfluencers: number;
  87138. _applyFog: boolean;
  87139. _receiveShadows: boolean;
  87140. _facetData: _FacetDataStorage;
  87141. _visibility: number;
  87142. _skeleton: Nullable<Skeleton>;
  87143. _layerMask: number;
  87144. _computeBonesUsingShaders: boolean;
  87145. _isActive: boolean;
  87146. _onlyForInstances: boolean;
  87147. _isActiveIntermediate: boolean;
  87148. _onlyForInstancesIntermediate: boolean;
  87149. }
  87150. /**
  87151. * Class used to store all common mesh properties
  87152. */
  87153. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87154. /** No occlusion */
  87155. static OCCLUSION_TYPE_NONE: number;
  87156. /** Occlusion set to optimisitic */
  87157. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87158. /** Occlusion set to strict */
  87159. static OCCLUSION_TYPE_STRICT: number;
  87160. /** Use an accurante occlusion algorithm */
  87161. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87162. /** Use a conservative occlusion algorithm */
  87163. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87164. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87165. * Test order :
  87166. * Is the bounding sphere outside the frustum ?
  87167. * If not, are the bounding box vertices outside the frustum ?
  87168. * It not, then the cullable object is in the frustum.
  87169. */
  87170. static readonly CULLINGSTRATEGY_STANDARD: number;
  87171. /** Culling strategy : Bounding Sphere Only.
  87172. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87173. * It's also less accurate than the standard because some not visible objects can still be selected.
  87174. * Test : is the bounding sphere outside the frustum ?
  87175. * If not, then the cullable object is in the frustum.
  87176. */
  87177. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87178. /** Culling strategy : Optimistic Inclusion.
  87179. * This in an inclusion test first, then the standard exclusion test.
  87180. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87181. * 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.
  87182. * Anyway, it's as accurate as the standard strategy.
  87183. * Test :
  87184. * Is the cullable object bounding sphere center in the frustum ?
  87185. * If not, apply the default culling strategy.
  87186. */
  87187. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87188. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87189. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87190. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87191. * 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.
  87192. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87193. * Test :
  87194. * Is the cullable object bounding sphere center in the frustum ?
  87195. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87196. */
  87197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87198. /**
  87199. * No billboard
  87200. */
  87201. static readonly BILLBOARDMODE_NONE: number;
  87202. /** Billboard on X axis */
  87203. static readonly BILLBOARDMODE_X: number;
  87204. /** Billboard on Y axis */
  87205. static readonly BILLBOARDMODE_Y: number;
  87206. /** Billboard on Z axis */
  87207. static readonly BILLBOARDMODE_Z: number;
  87208. /** Billboard on all axes */
  87209. static readonly BILLBOARDMODE_ALL: number;
  87210. /** @hidden */
  87211. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87212. /**
  87213. * The culling strategy to use to check whether the mesh must be rendered or not.
  87214. * This value can be changed at any time and will be used on the next render mesh selection.
  87215. * The possible values are :
  87216. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87217. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87218. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87219. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87220. * Please read each static variable documentation to get details about the culling process.
  87221. * */
  87222. cullingStrategy: number;
  87223. /**
  87224. * Gets the number of facets in the mesh
  87225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87226. */
  87227. readonly facetNb: number;
  87228. /**
  87229. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87231. */
  87232. partitioningSubdivisions: number;
  87233. /**
  87234. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87235. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87237. */
  87238. partitioningBBoxRatio: number;
  87239. /**
  87240. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87241. * Works only for updatable meshes.
  87242. * Doesn't work with multi-materials
  87243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87244. */
  87245. mustDepthSortFacets: boolean;
  87246. /**
  87247. * The location (Vector3) where the facet depth sort must be computed from.
  87248. * By default, the active camera position.
  87249. * Used only when facet depth sort is enabled
  87250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87251. */
  87252. facetDepthSortFrom: Vector3;
  87253. /**
  87254. * gets a boolean indicating if facetData is enabled
  87255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87256. */
  87257. readonly isFacetDataEnabled: boolean;
  87258. /** @hidden */
  87259. _updateNonUniformScalingState(value: boolean): boolean;
  87260. /**
  87261. * An event triggered when this mesh collides with another one
  87262. */
  87263. onCollideObservable: Observable<AbstractMesh>;
  87264. /** Set a function to call when this mesh collides with another one */
  87265. onCollide: () => void;
  87266. /**
  87267. * An event triggered when the collision's position changes
  87268. */
  87269. onCollisionPositionChangeObservable: Observable<Vector3>;
  87270. /** Set a function to call when the collision's position changes */
  87271. onCollisionPositionChange: () => void;
  87272. /**
  87273. * An event triggered when material is changed
  87274. */
  87275. onMaterialChangedObservable: Observable<AbstractMesh>;
  87276. /**
  87277. * Gets or sets the orientation for POV movement & rotation
  87278. */
  87279. definedFacingForward: boolean;
  87280. /** @hidden */
  87281. _occlusionQuery: Nullable<WebGLQuery>;
  87282. /** @hidden */
  87283. _renderingGroup: Nullable<RenderingGroup>;
  87284. /**
  87285. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87286. */
  87287. /**
  87288. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87289. */
  87290. visibility: number;
  87291. /** Gets or sets the alpha index used to sort transparent meshes
  87292. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87293. */
  87294. alphaIndex: number;
  87295. /**
  87296. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87297. */
  87298. isVisible: boolean;
  87299. /**
  87300. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87301. */
  87302. isPickable: boolean;
  87303. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87304. showSubMeshesBoundingBox: boolean;
  87305. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87306. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87307. */
  87308. isBlocker: boolean;
  87309. /**
  87310. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87311. */
  87312. enablePointerMoveEvents: boolean;
  87313. /**
  87314. * Specifies the rendering group id for this mesh (0 by default)
  87315. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87316. */
  87317. renderingGroupId: number;
  87318. private _material;
  87319. /** Gets or sets current material */
  87320. material: Nullable<Material>;
  87321. /**
  87322. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87323. * @see http://doc.babylonjs.com/babylon101/shadows
  87324. */
  87325. receiveShadows: boolean;
  87326. /** Defines color to use when rendering outline */
  87327. outlineColor: Color3;
  87328. /** Define width to use when rendering outline */
  87329. outlineWidth: number;
  87330. /** Defines color to use when rendering overlay */
  87331. overlayColor: Color3;
  87332. /** Defines alpha to use when rendering overlay */
  87333. overlayAlpha: number;
  87334. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87335. hasVertexAlpha: boolean;
  87336. /** 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) */
  87337. useVertexColors: boolean;
  87338. /**
  87339. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87340. */
  87341. computeBonesUsingShaders: boolean;
  87342. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87343. numBoneInfluencers: number;
  87344. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87345. applyFog: boolean;
  87346. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87347. useOctreeForRenderingSelection: boolean;
  87348. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87349. useOctreeForPicking: boolean;
  87350. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87351. useOctreeForCollisions: boolean;
  87352. /**
  87353. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87354. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87355. */
  87356. layerMask: number;
  87357. /**
  87358. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87359. */
  87360. alwaysSelectAsActiveMesh: boolean;
  87361. /**
  87362. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87363. */
  87364. doNotSyncBoundingInfo: boolean;
  87365. /**
  87366. * Gets or sets the current action manager
  87367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87368. */
  87369. actionManager: Nullable<AbstractActionManager>;
  87370. private _meshCollisionData;
  87371. /**
  87372. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87374. */
  87375. ellipsoid: Vector3;
  87376. /**
  87377. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87379. */
  87380. ellipsoidOffset: Vector3;
  87381. /**
  87382. * Gets or sets a collision mask used to mask collisions (default is -1).
  87383. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87384. */
  87385. collisionMask: number;
  87386. /**
  87387. * Gets or sets the current collision group mask (-1 by default).
  87388. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87389. */
  87390. collisionGroup: number;
  87391. /**
  87392. * Defines edge width used when edgesRenderer is enabled
  87393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87394. */
  87395. edgesWidth: number;
  87396. /**
  87397. * Defines edge color used when edgesRenderer is enabled
  87398. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87399. */
  87400. edgesColor: Color4;
  87401. /** @hidden */
  87402. _edgesRenderer: Nullable<IEdgesRenderer>;
  87403. /** @hidden */
  87404. _masterMesh: Nullable<AbstractMesh>;
  87405. /** @hidden */
  87406. _boundingInfo: Nullable<BoundingInfo>;
  87407. /** @hidden */
  87408. _renderId: number;
  87409. /**
  87410. * Gets or sets the list of subMeshes
  87411. * @see http://doc.babylonjs.com/how_to/multi_materials
  87412. */
  87413. subMeshes: SubMesh[];
  87414. /** @hidden */
  87415. _intersectionsInProgress: AbstractMesh[];
  87416. /** @hidden */
  87417. _unIndexed: boolean;
  87418. /** @hidden */
  87419. _lightSources: Light[];
  87420. /** Gets the list of lights affecting that mesh */
  87421. readonly lightSources: Light[];
  87422. /** @hidden */
  87423. readonly _positions: Nullable<Vector3[]>;
  87424. /** @hidden */
  87425. _waitingData: {
  87426. lods: Nullable<any>;
  87427. actions: Nullable<any>;
  87428. freezeWorldMatrix: Nullable<boolean>;
  87429. };
  87430. /** @hidden */
  87431. _bonesTransformMatrices: Nullable<Float32Array>;
  87432. /** @hidden */
  87433. _transformMatrixTexture: Nullable<RawTexture>;
  87434. /**
  87435. * Gets or sets a skeleton to apply skining transformations
  87436. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87437. */
  87438. skeleton: Nullable<Skeleton>;
  87439. /**
  87440. * An event triggered when the mesh is rebuilt.
  87441. */
  87442. onRebuildObservable: Observable<AbstractMesh>;
  87443. /**
  87444. * Creates a new AbstractMesh
  87445. * @param name defines the name of the mesh
  87446. * @param scene defines the hosting scene
  87447. */
  87448. constructor(name: string, scene?: Nullable<Scene>);
  87449. /**
  87450. * Returns the string "AbstractMesh"
  87451. * @returns "AbstractMesh"
  87452. */
  87453. getClassName(): string;
  87454. /**
  87455. * Gets a string representation of the current mesh
  87456. * @param fullDetails defines a boolean indicating if full details must be included
  87457. * @returns a string representation of the current mesh
  87458. */
  87459. toString(fullDetails?: boolean): string;
  87460. /**
  87461. * @hidden
  87462. */
  87463. protected _getEffectiveParent(): Nullable<Node>;
  87464. /** @hidden */
  87465. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87466. /** @hidden */
  87467. _rebuild(): void;
  87468. /** @hidden */
  87469. _resyncLightSources(): void;
  87470. /** @hidden */
  87471. _resyncLighSource(light: Light): void;
  87472. /** @hidden */
  87473. _unBindEffect(): void;
  87474. /** @hidden */
  87475. _removeLightSource(light: Light): void;
  87476. private _markSubMeshesAsDirty;
  87477. /** @hidden */
  87478. _markSubMeshesAsLightDirty(): void;
  87479. /** @hidden */
  87480. _markSubMeshesAsAttributesDirty(): void;
  87481. /** @hidden */
  87482. _markSubMeshesAsMiscDirty(): void;
  87483. /**
  87484. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87485. */
  87486. scaling: Vector3;
  87487. /**
  87488. * Returns true if the mesh is blocked. Implemented by child classes
  87489. */
  87490. readonly isBlocked: boolean;
  87491. /**
  87492. * Returns the mesh itself by default. Implemented by child classes
  87493. * @param camera defines the camera to use to pick the right LOD level
  87494. * @returns the currentAbstractMesh
  87495. */
  87496. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87497. /**
  87498. * Returns 0 by default. Implemented by child classes
  87499. * @returns an integer
  87500. */
  87501. getTotalVertices(): number;
  87502. /**
  87503. * Returns a positive integer : the total number of indices in this mesh geometry.
  87504. * @returns the numner of indices or zero if the mesh has no geometry.
  87505. */
  87506. getTotalIndices(): number;
  87507. /**
  87508. * Returns null by default. Implemented by child classes
  87509. * @returns null
  87510. */
  87511. getIndices(): Nullable<IndicesArray>;
  87512. /**
  87513. * Returns the array of the requested vertex data kind. Implemented by child classes
  87514. * @param kind defines the vertex data kind to use
  87515. * @returns null
  87516. */
  87517. getVerticesData(kind: string): Nullable<FloatArray>;
  87518. /**
  87519. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87520. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87521. * Note that a new underlying VertexBuffer object is created each call.
  87522. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87523. * @param kind defines vertex data kind:
  87524. * * VertexBuffer.PositionKind
  87525. * * VertexBuffer.UVKind
  87526. * * VertexBuffer.UV2Kind
  87527. * * VertexBuffer.UV3Kind
  87528. * * VertexBuffer.UV4Kind
  87529. * * VertexBuffer.UV5Kind
  87530. * * VertexBuffer.UV6Kind
  87531. * * VertexBuffer.ColorKind
  87532. * * VertexBuffer.MatricesIndicesKind
  87533. * * VertexBuffer.MatricesIndicesExtraKind
  87534. * * VertexBuffer.MatricesWeightsKind
  87535. * * VertexBuffer.MatricesWeightsExtraKind
  87536. * @param data defines the data source
  87537. * @param updatable defines if the data must be flagged as updatable (or static)
  87538. * @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
  87539. * @returns the current mesh
  87540. */
  87541. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87542. /**
  87543. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87544. * If the mesh has no geometry, it is simply returned as it is.
  87545. * @param kind defines vertex data kind:
  87546. * * VertexBuffer.PositionKind
  87547. * * VertexBuffer.UVKind
  87548. * * VertexBuffer.UV2Kind
  87549. * * VertexBuffer.UV3Kind
  87550. * * VertexBuffer.UV4Kind
  87551. * * VertexBuffer.UV5Kind
  87552. * * VertexBuffer.UV6Kind
  87553. * * VertexBuffer.ColorKind
  87554. * * VertexBuffer.MatricesIndicesKind
  87555. * * VertexBuffer.MatricesIndicesExtraKind
  87556. * * VertexBuffer.MatricesWeightsKind
  87557. * * VertexBuffer.MatricesWeightsExtraKind
  87558. * @param data defines the data source
  87559. * @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
  87560. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87561. * @returns the current mesh
  87562. */
  87563. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87564. /**
  87565. * Sets the mesh indices,
  87566. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87567. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87568. * @param totalVertices Defines the total number of vertices
  87569. * @returns the current mesh
  87570. */
  87571. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87572. /**
  87573. * Gets a boolean indicating if specific vertex data is present
  87574. * @param kind defines the vertex data kind to use
  87575. * @returns true is data kind is present
  87576. */
  87577. isVerticesDataPresent(kind: string): boolean;
  87578. /**
  87579. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87580. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87581. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87582. * @returns a BoundingInfo
  87583. */
  87584. getBoundingInfo(): BoundingInfo;
  87585. /**
  87586. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87587. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87588. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87589. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87590. * @returns the current mesh
  87591. */
  87592. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87593. /**
  87594. * Overwrite the current bounding info
  87595. * @param boundingInfo defines the new bounding info
  87596. * @returns the current mesh
  87597. */
  87598. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87599. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87600. readonly useBones: boolean;
  87601. /** @hidden */
  87602. _preActivate(): void;
  87603. /** @hidden */
  87604. _preActivateForIntermediateRendering(renderId: number): void;
  87605. /** @hidden */
  87606. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87607. /** @hidden */
  87608. _postActivate(): void;
  87609. /** @hidden */
  87610. _freeze(): void;
  87611. /** @hidden */
  87612. _unFreeze(): void;
  87613. /**
  87614. * Gets the current world matrix
  87615. * @returns a Matrix
  87616. */
  87617. getWorldMatrix(): Matrix;
  87618. /** @hidden */
  87619. _getWorldMatrixDeterminant(): number;
  87620. /**
  87621. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87622. */
  87623. readonly isAnInstance: boolean;
  87624. /**
  87625. * Perform relative position change from the point of view of behind the front of the mesh.
  87626. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87627. * Supports definition of mesh facing forward or backward
  87628. * @param amountRight defines the distance on the right axis
  87629. * @param amountUp defines the distance on the up axis
  87630. * @param amountForward defines the distance on the forward axis
  87631. * @returns the current mesh
  87632. */
  87633. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87634. /**
  87635. * Calculate relative position change from the point of view of behind the front of the mesh.
  87636. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87637. * Supports definition of mesh facing forward or backward
  87638. * @param amountRight defines the distance on the right axis
  87639. * @param amountUp defines the distance on the up axis
  87640. * @param amountForward defines the distance on the forward axis
  87641. * @returns the new displacement vector
  87642. */
  87643. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87644. /**
  87645. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87646. * Supports definition of mesh facing forward or backward
  87647. * @param flipBack defines the flip
  87648. * @param twirlClockwise defines the twirl
  87649. * @param tiltRight defines the tilt
  87650. * @returns the current mesh
  87651. */
  87652. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87653. /**
  87654. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87655. * Supports definition of mesh facing forward or backward.
  87656. * @param flipBack defines the flip
  87657. * @param twirlClockwise defines the twirl
  87658. * @param tiltRight defines the tilt
  87659. * @returns the new rotation vector
  87660. */
  87661. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87662. /**
  87663. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87664. * This means the mesh underlying bounding box and sphere are recomputed.
  87665. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87666. * @returns the current mesh
  87667. */
  87668. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87669. /** @hidden */
  87670. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87671. /** @hidden */
  87672. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87673. /** @hidden */
  87674. _updateBoundingInfo(): AbstractMesh;
  87675. /** @hidden */
  87676. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87677. /** @hidden */
  87678. protected _afterComputeWorldMatrix(): void;
  87679. /** @hidden */
  87680. readonly _effectiveMesh: AbstractMesh;
  87681. /**
  87682. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87683. * A mesh is in the frustum if its bounding box intersects the frustum
  87684. * @param frustumPlanes defines the frustum to test
  87685. * @returns true if the mesh is in the frustum planes
  87686. */
  87687. isInFrustum(frustumPlanes: Plane[]): boolean;
  87688. /**
  87689. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87690. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87691. * @param frustumPlanes defines the frustum to test
  87692. * @returns true if the mesh is completely in the frustum planes
  87693. */
  87694. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87695. /**
  87696. * True if the mesh intersects another mesh or a SolidParticle object
  87697. * @param mesh defines a target mesh or SolidParticle to test
  87698. * @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)
  87699. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87700. * @returns true if there is an intersection
  87701. */
  87702. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87703. /**
  87704. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87705. * @param point defines the point to test
  87706. * @returns true if there is an intersection
  87707. */
  87708. intersectsPoint(point: Vector3): boolean;
  87709. /**
  87710. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87712. */
  87713. checkCollisions: boolean;
  87714. /**
  87715. * Gets Collider object used to compute collisions (not physics)
  87716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87717. */
  87718. readonly collider: Nullable<Collider>;
  87719. /**
  87720. * Move the mesh using collision engine
  87721. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87722. * @param displacement defines the requested displacement vector
  87723. * @returns the current mesh
  87724. */
  87725. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87726. private _onCollisionPositionChange;
  87727. /** @hidden */
  87728. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87729. /** @hidden */
  87730. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87731. /** @hidden */
  87732. _checkCollision(collider: Collider): AbstractMesh;
  87733. /** @hidden */
  87734. _generatePointsArray(): boolean;
  87735. /**
  87736. * Checks if the passed Ray intersects with the mesh
  87737. * @param ray defines the ray to use
  87738. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87739. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87740. * @returns the picking info
  87741. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87742. */
  87743. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87744. /**
  87745. * Clones the current mesh
  87746. * @param name defines the mesh name
  87747. * @param newParent defines the new mesh parent
  87748. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87749. * @returns the new mesh
  87750. */
  87751. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87752. /**
  87753. * Disposes all the submeshes of the current meshnp
  87754. * @returns the current mesh
  87755. */
  87756. releaseSubMeshes(): AbstractMesh;
  87757. /**
  87758. * Releases resources associated with this abstract mesh.
  87759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87761. */
  87762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87763. /**
  87764. * Adds the passed mesh as a child to the current mesh
  87765. * @param mesh defines the child mesh
  87766. * @returns the current mesh
  87767. */
  87768. addChild(mesh: AbstractMesh): AbstractMesh;
  87769. /**
  87770. * Removes the passed mesh from the current mesh children list
  87771. * @param mesh defines the child mesh
  87772. * @returns the current mesh
  87773. */
  87774. removeChild(mesh: AbstractMesh): AbstractMesh;
  87775. /** @hidden */
  87776. private _initFacetData;
  87777. /**
  87778. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87779. * This method can be called within the render loop.
  87780. * 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
  87781. * @returns the current mesh
  87782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87783. */
  87784. updateFacetData(): AbstractMesh;
  87785. /**
  87786. * Returns the facetLocalNormals array.
  87787. * The normals are expressed in the mesh local spac
  87788. * @returns an array of Vector3
  87789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87790. */
  87791. getFacetLocalNormals(): Vector3[];
  87792. /**
  87793. * Returns the facetLocalPositions array.
  87794. * The facet positions are expressed in the mesh local space
  87795. * @returns an array of Vector3
  87796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87797. */
  87798. getFacetLocalPositions(): Vector3[];
  87799. /**
  87800. * Returns the facetLocalPartioning array
  87801. * @returns an array of array of numbers
  87802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87803. */
  87804. getFacetLocalPartitioning(): number[][];
  87805. /**
  87806. * Returns the i-th facet position in the world system.
  87807. * This method allocates a new Vector3 per call
  87808. * @param i defines the facet index
  87809. * @returns a new Vector3
  87810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87811. */
  87812. getFacetPosition(i: number): Vector3;
  87813. /**
  87814. * Sets the reference Vector3 with the i-th facet position in the world system
  87815. * @param i defines the facet index
  87816. * @param ref defines the target vector
  87817. * @returns the current mesh
  87818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87819. */
  87820. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87821. /**
  87822. * Returns the i-th facet normal in the world system.
  87823. * This method allocates a new Vector3 per call
  87824. * @param i defines the facet index
  87825. * @returns a new Vector3
  87826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87827. */
  87828. getFacetNormal(i: number): Vector3;
  87829. /**
  87830. * Sets the reference Vector3 with the i-th facet normal in the world system
  87831. * @param i defines the facet index
  87832. * @param ref defines the target vector
  87833. * @returns the current mesh
  87834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87835. */
  87836. getFacetNormalToRef(i: number, ref: Vector3): this;
  87837. /**
  87838. * 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)
  87839. * @param x defines x coordinate
  87840. * @param y defines y coordinate
  87841. * @param z defines z coordinate
  87842. * @returns the array of facet indexes
  87843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87844. */
  87845. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87846. /**
  87847. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87848. * @param projected sets as the (x,y,z) world projection on the facet
  87849. * @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
  87850. * @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
  87851. * @param x defines x coordinate
  87852. * @param y defines y coordinate
  87853. * @param z defines z coordinate
  87854. * @returns the face index if found (or null instead)
  87855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87856. */
  87857. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87858. /**
  87859. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87860. * @param projected sets as the (x,y,z) local projection on the facet
  87861. * @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
  87862. * @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
  87863. * @param x defines x coordinate
  87864. * @param y defines y coordinate
  87865. * @param z defines z coordinate
  87866. * @returns the face index if found (or null instead)
  87867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87868. */
  87869. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87870. /**
  87871. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87872. * @returns the parameters
  87873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87874. */
  87875. getFacetDataParameters(): any;
  87876. /**
  87877. * Disables the feature FacetData and frees the related memory
  87878. * @returns the current mesh
  87879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87880. */
  87881. disableFacetData(): AbstractMesh;
  87882. /**
  87883. * Updates the AbstractMesh indices array
  87884. * @param indices defines the data source
  87885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87886. * @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)
  87887. * @returns the current mesh
  87888. */
  87889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87890. /**
  87891. * Creates new normals data for the mesh
  87892. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87893. * @returns the current mesh
  87894. */
  87895. createNormals(updatable: boolean): AbstractMesh;
  87896. /**
  87897. * Align the mesh with a normal
  87898. * @param normal defines the normal to use
  87899. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87900. * @returns the current mesh
  87901. */
  87902. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87903. /** @hidden */
  87904. _checkOcclusionQuery(): boolean;
  87905. /**
  87906. * Disables the mesh edge rendering mode
  87907. * @returns the currentAbstractMesh
  87908. */
  87909. disableEdgesRendering(): AbstractMesh;
  87910. /**
  87911. * Enables the edge rendering mode on the mesh.
  87912. * This mode makes the mesh edges visible
  87913. * @param epsilon defines the maximal distance between two angles to detect a face
  87914. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87915. * @returns the currentAbstractMesh
  87916. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87917. */
  87918. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87919. }
  87920. }
  87921. declare module BABYLON {
  87922. /**
  87923. * Interface used to define ActionEvent
  87924. */
  87925. export interface IActionEvent {
  87926. /** The mesh or sprite that triggered the action */
  87927. source: any;
  87928. /** The X mouse cursor position at the time of the event */
  87929. pointerX: number;
  87930. /** The Y mouse cursor position at the time of the event */
  87931. pointerY: number;
  87932. /** The mesh that is currently pointed at (can be null) */
  87933. meshUnderPointer: Nullable<AbstractMesh>;
  87934. /** the original (browser) event that triggered the ActionEvent */
  87935. sourceEvent?: any;
  87936. /** additional data for the event */
  87937. additionalData?: any;
  87938. }
  87939. /**
  87940. * ActionEvent is the event being sent when an action is triggered.
  87941. */
  87942. export class ActionEvent implements IActionEvent {
  87943. /** The mesh or sprite that triggered the action */
  87944. source: any;
  87945. /** The X mouse cursor position at the time of the event */
  87946. pointerX: number;
  87947. /** The Y mouse cursor position at the time of the event */
  87948. pointerY: number;
  87949. /** The mesh that is currently pointed at (can be null) */
  87950. meshUnderPointer: Nullable<AbstractMesh>;
  87951. /** the original (browser) event that triggered the ActionEvent */
  87952. sourceEvent?: any;
  87953. /** additional data for the event */
  87954. additionalData?: any;
  87955. /**
  87956. * Creates a new ActionEvent
  87957. * @param source The mesh or sprite that triggered the action
  87958. * @param pointerX The X mouse cursor position at the time of the event
  87959. * @param pointerY The Y mouse cursor position at the time of the event
  87960. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87961. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87962. * @param additionalData additional data for the event
  87963. */
  87964. constructor(
  87965. /** The mesh or sprite that triggered the action */
  87966. source: any,
  87967. /** The X mouse cursor position at the time of the event */
  87968. pointerX: number,
  87969. /** The Y mouse cursor position at the time of the event */
  87970. pointerY: number,
  87971. /** The mesh that is currently pointed at (can be null) */
  87972. meshUnderPointer: Nullable<AbstractMesh>,
  87973. /** the original (browser) event that triggered the ActionEvent */
  87974. sourceEvent?: any,
  87975. /** additional data for the event */
  87976. additionalData?: any);
  87977. /**
  87978. * Helper function to auto-create an ActionEvent from a source mesh.
  87979. * @param source The source mesh that triggered the event
  87980. * @param evt The original (browser) event
  87981. * @param additionalData additional data for the event
  87982. * @returns the new ActionEvent
  87983. */
  87984. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87985. /**
  87986. * Helper function to auto-create an ActionEvent from a source sprite
  87987. * @param source The source sprite that triggered the event
  87988. * @param scene Scene associated with the sprite
  87989. * @param evt The original (browser) event
  87990. * @param additionalData additional data for the event
  87991. * @returns the new ActionEvent
  87992. */
  87993. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87994. /**
  87995. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87996. * @param scene the scene where the event occurred
  87997. * @param evt The original (browser) event
  87998. * @returns the new ActionEvent
  87999. */
  88000. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  88001. /**
  88002. * Helper function to auto-create an ActionEvent from a primitive
  88003. * @param prim defines the target primitive
  88004. * @param pointerPos defines the pointer position
  88005. * @param evt The original (browser) event
  88006. * @param additionalData additional data for the event
  88007. * @returns the new ActionEvent
  88008. */
  88009. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  88010. }
  88011. }
  88012. declare module BABYLON {
  88013. /**
  88014. * Abstract class used to decouple action Manager from scene and meshes.
  88015. * Do not instantiate.
  88016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88017. */
  88018. export abstract class AbstractActionManager implements IDisposable {
  88019. /** Gets the list of active triggers */
  88020. static Triggers: {
  88021. [key: string]: number;
  88022. };
  88023. /** Gets the cursor to use when hovering items */
  88024. hoverCursor: string;
  88025. /** Gets the list of actions */
  88026. actions: IAction[];
  88027. /**
  88028. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  88029. */
  88030. isRecursive: boolean;
  88031. /**
  88032. * Releases all associated resources
  88033. */
  88034. abstract dispose(): void;
  88035. /**
  88036. * Does this action manager has pointer triggers
  88037. */
  88038. abstract readonly hasPointerTriggers: boolean;
  88039. /**
  88040. * Does this action manager has pick triggers
  88041. */
  88042. abstract readonly hasPickTriggers: boolean;
  88043. /**
  88044. * Process a specific trigger
  88045. * @param trigger defines the trigger to process
  88046. * @param evt defines the event details to be processed
  88047. */
  88048. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88049. /**
  88050. * Does this action manager handles actions of any of the given triggers
  88051. * @param triggers defines the triggers to be tested
  88052. * @return a boolean indicating whether one (or more) of the triggers is handled
  88053. */
  88054. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88055. /**
  88056. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88057. * speed.
  88058. * @param triggerA defines the trigger to be tested
  88059. * @param triggerB defines the trigger to be tested
  88060. * @return a boolean indicating whether one (or more) of the triggers is handled
  88061. */
  88062. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88063. /**
  88064. * Does this action manager handles actions of a given trigger
  88065. * @param trigger defines the trigger to be tested
  88066. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88067. * @return whether the trigger is handled
  88068. */
  88069. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88070. /**
  88071. * Serialize this manager to a JSON object
  88072. * @param name defines the property name to store this manager
  88073. * @returns a JSON representation of this manager
  88074. */
  88075. abstract serialize(name: string): any;
  88076. /**
  88077. * Registers an action to this action manager
  88078. * @param action defines the action to be registered
  88079. * @return the action amended (prepared) after registration
  88080. */
  88081. abstract registerAction(action: IAction): Nullable<IAction>;
  88082. /**
  88083. * Unregisters an action to this action manager
  88084. * @param action defines the action to be unregistered
  88085. * @return a boolean indicating whether the action has been unregistered
  88086. */
  88087. abstract unregisterAction(action: IAction): Boolean;
  88088. /**
  88089. * Does exist one action manager with at least one trigger
  88090. **/
  88091. static readonly HasTriggers: boolean;
  88092. /**
  88093. * Does exist one action manager with at least one pick trigger
  88094. **/
  88095. static readonly HasPickTriggers: boolean;
  88096. /**
  88097. * Does exist one action manager that handles actions of a given trigger
  88098. * @param trigger defines the trigger to be tested
  88099. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88100. **/
  88101. static HasSpecificTrigger(trigger: number): boolean;
  88102. }
  88103. }
  88104. declare module BABYLON {
  88105. /**
  88106. * Defines how a node can be built from a string name.
  88107. */
  88108. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88109. /**
  88110. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88111. */
  88112. export class Node implements IBehaviorAware<Node> {
  88113. /** @hidden */
  88114. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88115. private static _NodeConstructors;
  88116. /**
  88117. * Add a new node constructor
  88118. * @param type defines the type name of the node to construct
  88119. * @param constructorFunc defines the constructor function
  88120. */
  88121. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88122. /**
  88123. * Returns a node constructor based on type name
  88124. * @param type defines the type name
  88125. * @param name defines the new node name
  88126. * @param scene defines the hosting scene
  88127. * @param options defines optional options to transmit to constructors
  88128. * @returns the new constructor or null
  88129. */
  88130. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88131. /**
  88132. * Gets or sets the name of the node
  88133. */
  88134. name: string;
  88135. /**
  88136. * Gets or sets the id of the node
  88137. */
  88138. id: string;
  88139. /**
  88140. * Gets or sets the unique id of the node
  88141. */
  88142. uniqueId: number;
  88143. /**
  88144. * Gets or sets a string used to store user defined state for the node
  88145. */
  88146. state: string;
  88147. /**
  88148. * Gets or sets an object used to store user defined information for the node
  88149. */
  88150. metadata: any;
  88151. /**
  88152. * For internal use only. Please do not use.
  88153. */
  88154. reservedDataStore: any;
  88155. /**
  88156. * List of inspectable custom properties (used by the Inspector)
  88157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88158. */
  88159. inspectableCustomProperties: IInspectable[];
  88160. /**
  88161. * Gets or sets a boolean used to define if the node must be serialized
  88162. */
  88163. doNotSerialize: boolean;
  88164. /** @hidden */
  88165. _isDisposed: boolean;
  88166. /**
  88167. * Gets a list of Animations associated with the node
  88168. */
  88169. animations: Animation[];
  88170. protected _ranges: {
  88171. [name: string]: Nullable<AnimationRange>;
  88172. };
  88173. /**
  88174. * Callback raised when the node is ready to be used
  88175. */
  88176. onReady: Nullable<(node: Node) => void>;
  88177. private _isEnabled;
  88178. private _isParentEnabled;
  88179. private _isReady;
  88180. /** @hidden */
  88181. _currentRenderId: number;
  88182. private _parentUpdateId;
  88183. /** @hidden */
  88184. _childUpdateId: number;
  88185. /** @hidden */
  88186. _waitingParentId: Nullable<string>;
  88187. /** @hidden */
  88188. _scene: Scene;
  88189. /** @hidden */
  88190. _cache: any;
  88191. private _parentNode;
  88192. private _children;
  88193. /** @hidden */
  88194. _worldMatrix: Matrix;
  88195. /** @hidden */
  88196. _worldMatrixDeterminant: number;
  88197. /** @hidden */
  88198. _worldMatrixDeterminantIsDirty: boolean;
  88199. /** @hidden */
  88200. private _sceneRootNodesIndex;
  88201. /**
  88202. * Gets a boolean indicating if the node has been disposed
  88203. * @returns true if the node was disposed
  88204. */
  88205. isDisposed(): boolean;
  88206. /**
  88207. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88208. * @see https://doc.babylonjs.com/how_to/parenting
  88209. */
  88210. parent: Nullable<Node>;
  88211. private addToSceneRootNodes;
  88212. private removeFromSceneRootNodes;
  88213. private _animationPropertiesOverride;
  88214. /**
  88215. * Gets or sets the animation properties override
  88216. */
  88217. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88218. /**
  88219. * Gets a string idenfifying the name of the class
  88220. * @returns "Node" string
  88221. */
  88222. getClassName(): string;
  88223. /** @hidden */
  88224. readonly _isNode: boolean;
  88225. /**
  88226. * An event triggered when the mesh is disposed
  88227. */
  88228. onDisposeObservable: Observable<Node>;
  88229. private _onDisposeObserver;
  88230. /**
  88231. * Sets a callback that will be raised when the node will be disposed
  88232. */
  88233. onDispose: () => void;
  88234. /**
  88235. * Creates a new Node
  88236. * @param name the name and id to be given to this node
  88237. * @param scene the scene this node will be added to
  88238. * @param addToRootNodes the node will be added to scene.rootNodes
  88239. */
  88240. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88241. /**
  88242. * Gets the scene of the node
  88243. * @returns a scene
  88244. */
  88245. getScene(): Scene;
  88246. /**
  88247. * Gets the engine of the node
  88248. * @returns a Engine
  88249. */
  88250. getEngine(): Engine;
  88251. private _behaviors;
  88252. /**
  88253. * Attach a behavior to the node
  88254. * @see http://doc.babylonjs.com/features/behaviour
  88255. * @param behavior defines the behavior to attach
  88256. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88257. * @returns the current Node
  88258. */
  88259. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88260. /**
  88261. * Remove an attached behavior
  88262. * @see http://doc.babylonjs.com/features/behaviour
  88263. * @param behavior defines the behavior to attach
  88264. * @returns the current Node
  88265. */
  88266. removeBehavior(behavior: Behavior<Node>): Node;
  88267. /**
  88268. * Gets the list of attached behaviors
  88269. * @see http://doc.babylonjs.com/features/behaviour
  88270. */
  88271. readonly behaviors: Behavior<Node>[];
  88272. /**
  88273. * Gets an attached behavior by name
  88274. * @param name defines the name of the behavior to look for
  88275. * @see http://doc.babylonjs.com/features/behaviour
  88276. * @returns null if behavior was not found else the requested behavior
  88277. */
  88278. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88279. /**
  88280. * Returns the latest update of the World matrix
  88281. * @returns a Matrix
  88282. */
  88283. getWorldMatrix(): Matrix;
  88284. /** @hidden */
  88285. _getWorldMatrixDeterminant(): number;
  88286. /**
  88287. * Returns directly the latest state of the mesh World matrix.
  88288. * A Matrix is returned.
  88289. */
  88290. readonly worldMatrixFromCache: Matrix;
  88291. /** @hidden */
  88292. _initCache(): void;
  88293. /** @hidden */
  88294. updateCache(force?: boolean): void;
  88295. /** @hidden */
  88296. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88297. /** @hidden */
  88298. _updateCache(ignoreParentClass?: boolean): void;
  88299. /** @hidden */
  88300. _isSynchronized(): boolean;
  88301. /** @hidden */
  88302. _markSyncedWithParent(): void;
  88303. /** @hidden */
  88304. isSynchronizedWithParent(): boolean;
  88305. /** @hidden */
  88306. isSynchronized(): boolean;
  88307. /**
  88308. * Is this node ready to be used/rendered
  88309. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88310. * @return true if the node is ready
  88311. */
  88312. isReady(completeCheck?: boolean): boolean;
  88313. /**
  88314. * Is this node enabled?
  88315. * 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
  88316. * @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
  88317. * @return whether this node (and its parent) is enabled
  88318. */
  88319. isEnabled(checkAncestors?: boolean): boolean;
  88320. /** @hidden */
  88321. protected _syncParentEnabledState(): void;
  88322. /**
  88323. * Set the enabled state of this node
  88324. * @param value defines the new enabled state
  88325. */
  88326. setEnabled(value: boolean): void;
  88327. /**
  88328. * Is this node a descendant of the given node?
  88329. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88330. * @param ancestor defines the parent node to inspect
  88331. * @returns a boolean indicating if this node is a descendant of the given node
  88332. */
  88333. isDescendantOf(ancestor: Node): boolean;
  88334. /** @hidden */
  88335. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88336. /**
  88337. * Will return all nodes that have this node as ascendant
  88338. * @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
  88339. * @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
  88340. * @return all children nodes of all types
  88341. */
  88342. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88343. /**
  88344. * Get all child-meshes of this node
  88345. * @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)
  88346. * @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
  88347. * @returns an array of AbstractMesh
  88348. */
  88349. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88350. /**
  88351. * Get all direct children of this node
  88352. * @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
  88353. * @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)
  88354. * @returns an array of Node
  88355. */
  88356. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88357. /** @hidden */
  88358. _setReady(state: boolean): void;
  88359. /**
  88360. * Get an animation by name
  88361. * @param name defines the name of the animation to look for
  88362. * @returns null if not found else the requested animation
  88363. */
  88364. getAnimationByName(name: string): Nullable<Animation>;
  88365. /**
  88366. * Creates an animation range for this node
  88367. * @param name defines the name of the range
  88368. * @param from defines the starting key
  88369. * @param to defines the end key
  88370. */
  88371. createAnimationRange(name: string, from: number, to: number): void;
  88372. /**
  88373. * Delete a specific animation range
  88374. * @param name defines the name of the range to delete
  88375. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88376. */
  88377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88378. /**
  88379. * Get an animation range by name
  88380. * @param name defines the name of the animation range to look for
  88381. * @returns null if not found else the requested animation range
  88382. */
  88383. getAnimationRange(name: string): Nullable<AnimationRange>;
  88384. /**
  88385. * Gets the list of all animation ranges defined on this node
  88386. * @returns an array
  88387. */
  88388. getAnimationRanges(): Nullable<AnimationRange>[];
  88389. /**
  88390. * Will start the animation sequence
  88391. * @param name defines the range frames for animation sequence
  88392. * @param loop defines if the animation should loop (false by default)
  88393. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88394. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88395. * @returns the object created for this animation. If range does not exist, it will return null
  88396. */
  88397. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88398. /**
  88399. * Serialize animation ranges into a JSON compatible object
  88400. * @returns serialization object
  88401. */
  88402. serializeAnimationRanges(): any;
  88403. /**
  88404. * Computes the world matrix of the node
  88405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88406. * @returns the world matrix
  88407. */
  88408. computeWorldMatrix(force?: boolean): Matrix;
  88409. /**
  88410. * Releases resources associated with this node.
  88411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88413. */
  88414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88415. /**
  88416. * Parse animation range data from a serialization object and store them into a given node
  88417. * @param node defines where to store the animation ranges
  88418. * @param parsedNode defines the serialization object to read data from
  88419. * @param scene defines the hosting scene
  88420. */
  88421. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88422. /**
  88423. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88424. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88425. * @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
  88426. * @returns the new bounding vectors
  88427. */
  88428. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88429. min: Vector3;
  88430. max: Vector3;
  88431. };
  88432. }
  88433. }
  88434. declare module BABYLON {
  88435. /**
  88436. * @hidden
  88437. */
  88438. export class _IAnimationState {
  88439. key: number;
  88440. repeatCount: number;
  88441. workValue?: any;
  88442. loopMode?: number;
  88443. offsetValue?: any;
  88444. highLimitValue?: any;
  88445. }
  88446. /**
  88447. * Class used to store any kind of animation
  88448. */
  88449. export class Animation {
  88450. /**Name of the animation */
  88451. name: string;
  88452. /**Property to animate */
  88453. targetProperty: string;
  88454. /**The frames per second of the animation */
  88455. framePerSecond: number;
  88456. /**The data type of the animation */
  88457. dataType: number;
  88458. /**The loop mode of the animation */
  88459. loopMode?: number | undefined;
  88460. /**Specifies if blending should be enabled */
  88461. enableBlending?: boolean | undefined;
  88462. /**
  88463. * Use matrix interpolation instead of using direct key value when animating matrices
  88464. */
  88465. static AllowMatricesInterpolation: boolean;
  88466. /**
  88467. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88468. */
  88469. static AllowMatrixDecomposeForInterpolation: boolean;
  88470. /**
  88471. * Stores the key frames of the animation
  88472. */
  88473. private _keys;
  88474. /**
  88475. * Stores the easing function of the animation
  88476. */
  88477. private _easingFunction;
  88478. /**
  88479. * @hidden Internal use only
  88480. */
  88481. _runtimeAnimations: RuntimeAnimation[];
  88482. /**
  88483. * The set of event that will be linked to this animation
  88484. */
  88485. private _events;
  88486. /**
  88487. * Stores an array of target property paths
  88488. */
  88489. targetPropertyPath: string[];
  88490. /**
  88491. * Stores the blending speed of the animation
  88492. */
  88493. blendingSpeed: number;
  88494. /**
  88495. * Stores the animation ranges for the animation
  88496. */
  88497. private _ranges;
  88498. /**
  88499. * @hidden Internal use
  88500. */
  88501. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88502. /**
  88503. * Sets up an animation
  88504. * @param property The property to animate
  88505. * @param animationType The animation type to apply
  88506. * @param framePerSecond The frames per second of the animation
  88507. * @param easingFunction The easing function used in the animation
  88508. * @returns The created animation
  88509. */
  88510. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88511. /**
  88512. * Create and start an animation on a node
  88513. * @param name defines the name of the global animation that will be run on all nodes
  88514. * @param node defines the root node where the animation will take place
  88515. * @param targetProperty defines property to animate
  88516. * @param framePerSecond defines the number of frame per second yo use
  88517. * @param totalFrame defines the number of frames in total
  88518. * @param from defines the initial value
  88519. * @param to defines the final value
  88520. * @param loopMode defines which loop mode you want to use (off by default)
  88521. * @param easingFunction defines the easing function to use (linear by default)
  88522. * @param onAnimationEnd defines the callback to call when animation end
  88523. * @returns the animatable created for this animation
  88524. */
  88525. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88526. /**
  88527. * Create and start an animation on a node and its descendants
  88528. * @param name defines the name of the global animation that will be run on all nodes
  88529. * @param node defines the root node where the animation will take place
  88530. * @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
  88531. * @param targetProperty defines property to animate
  88532. * @param framePerSecond defines the number of frame per second to use
  88533. * @param totalFrame defines the number of frames in total
  88534. * @param from defines the initial value
  88535. * @param to defines the final value
  88536. * @param loopMode defines which loop mode you want to use (off by default)
  88537. * @param easingFunction defines the easing function to use (linear by default)
  88538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88539. * @returns the list of animatables created for all nodes
  88540. * @example https://www.babylonjs-playground.com/#MH0VLI
  88541. */
  88542. 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[]>;
  88543. /**
  88544. * Creates a new animation, merges it with the existing animations and starts it
  88545. * @param name Name of the animation
  88546. * @param node Node which contains the scene that begins the animations
  88547. * @param targetProperty Specifies which property to animate
  88548. * @param framePerSecond The frames per second of the animation
  88549. * @param totalFrame The total number of frames
  88550. * @param from The frame at the beginning of the animation
  88551. * @param to The frame at the end of the animation
  88552. * @param loopMode Specifies the loop mode of the animation
  88553. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88554. * @param onAnimationEnd Callback to run once the animation is complete
  88555. * @returns Nullable animation
  88556. */
  88557. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88558. /**
  88559. * Transition property of an host to the target Value
  88560. * @param property The property to transition
  88561. * @param targetValue The target Value of the property
  88562. * @param host The object where the property to animate belongs
  88563. * @param scene Scene used to run the animation
  88564. * @param frameRate Framerate (in frame/s) to use
  88565. * @param transition The transition type we want to use
  88566. * @param duration The duration of the animation, in milliseconds
  88567. * @param onAnimationEnd Callback trigger at the end of the animation
  88568. * @returns Nullable animation
  88569. */
  88570. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88571. /**
  88572. * Return the array of runtime animations currently using this animation
  88573. */
  88574. readonly runtimeAnimations: RuntimeAnimation[];
  88575. /**
  88576. * Specifies if any of the runtime animations are currently running
  88577. */
  88578. readonly hasRunningRuntimeAnimations: boolean;
  88579. /**
  88580. * Initializes the animation
  88581. * @param name Name of the animation
  88582. * @param targetProperty Property to animate
  88583. * @param framePerSecond The frames per second of the animation
  88584. * @param dataType The data type of the animation
  88585. * @param loopMode The loop mode of the animation
  88586. * @param enableBlending Specifies if blending should be enabled
  88587. */
  88588. constructor(
  88589. /**Name of the animation */
  88590. name: string,
  88591. /**Property to animate */
  88592. targetProperty: string,
  88593. /**The frames per second of the animation */
  88594. framePerSecond: number,
  88595. /**The data type of the animation */
  88596. dataType: number,
  88597. /**The loop mode of the animation */
  88598. loopMode?: number | undefined,
  88599. /**Specifies if blending should be enabled */
  88600. enableBlending?: boolean | undefined);
  88601. /**
  88602. * Converts the animation to a string
  88603. * @param fullDetails support for multiple levels of logging within scene loading
  88604. * @returns String form of the animation
  88605. */
  88606. toString(fullDetails?: boolean): string;
  88607. /**
  88608. * Add an event to this animation
  88609. * @param event Event to add
  88610. */
  88611. addEvent(event: AnimationEvent): void;
  88612. /**
  88613. * Remove all events found at the given frame
  88614. * @param frame The frame to remove events from
  88615. */
  88616. removeEvents(frame: number): void;
  88617. /**
  88618. * Retrieves all the events from the animation
  88619. * @returns Events from the animation
  88620. */
  88621. getEvents(): AnimationEvent[];
  88622. /**
  88623. * Creates an animation range
  88624. * @param name Name of the animation range
  88625. * @param from Starting frame of the animation range
  88626. * @param to Ending frame of the animation
  88627. */
  88628. createRange(name: string, from: number, to: number): void;
  88629. /**
  88630. * Deletes an animation range by name
  88631. * @param name Name of the animation range to delete
  88632. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88633. */
  88634. deleteRange(name: string, deleteFrames?: boolean): void;
  88635. /**
  88636. * Gets the animation range by name, or null if not defined
  88637. * @param name Name of the animation range
  88638. * @returns Nullable animation range
  88639. */
  88640. getRange(name: string): Nullable<AnimationRange>;
  88641. /**
  88642. * Gets the key frames from the animation
  88643. * @returns The key frames of the animation
  88644. */
  88645. getKeys(): Array<IAnimationKey>;
  88646. /**
  88647. * Gets the highest frame rate of the animation
  88648. * @returns Highest frame rate of the animation
  88649. */
  88650. getHighestFrame(): number;
  88651. /**
  88652. * Gets the easing function of the animation
  88653. * @returns Easing function of the animation
  88654. */
  88655. getEasingFunction(): IEasingFunction;
  88656. /**
  88657. * Sets the easing function of the animation
  88658. * @param easingFunction A custom mathematical formula for animation
  88659. */
  88660. setEasingFunction(easingFunction: EasingFunction): void;
  88661. /**
  88662. * Interpolates a scalar linearly
  88663. * @param startValue Start value of the animation curve
  88664. * @param endValue End value of the animation curve
  88665. * @param gradient Scalar amount to interpolate
  88666. * @returns Interpolated scalar value
  88667. */
  88668. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88669. /**
  88670. * Interpolates a scalar cubically
  88671. * @param startValue Start value of the animation curve
  88672. * @param outTangent End tangent of the animation
  88673. * @param endValue End value of the animation curve
  88674. * @param inTangent Start tangent of the animation curve
  88675. * @param gradient Scalar amount to interpolate
  88676. * @returns Interpolated scalar value
  88677. */
  88678. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88679. /**
  88680. * Interpolates a quaternion using a spherical linear interpolation
  88681. * @param startValue Start value of the animation curve
  88682. * @param endValue End value of the animation curve
  88683. * @param gradient Scalar amount to interpolate
  88684. * @returns Interpolated quaternion value
  88685. */
  88686. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88687. /**
  88688. * Interpolates a quaternion cubically
  88689. * @param startValue Start value of the animation curve
  88690. * @param outTangent End tangent of the animation curve
  88691. * @param endValue End value of the animation curve
  88692. * @param inTangent Start tangent of the animation curve
  88693. * @param gradient Scalar amount to interpolate
  88694. * @returns Interpolated quaternion value
  88695. */
  88696. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88697. /**
  88698. * Interpolates a Vector3 linearl
  88699. * @param startValue Start value of the animation curve
  88700. * @param endValue End value of the animation curve
  88701. * @param gradient Scalar amount to interpolate
  88702. * @returns Interpolated scalar value
  88703. */
  88704. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88705. /**
  88706. * Interpolates a Vector3 cubically
  88707. * @param startValue Start value of the animation curve
  88708. * @param outTangent End tangent of the animation
  88709. * @param endValue End value of the animation curve
  88710. * @param inTangent Start tangent of the animation curve
  88711. * @param gradient Scalar amount to interpolate
  88712. * @returns InterpolatedVector3 value
  88713. */
  88714. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88715. /**
  88716. * Interpolates a Vector2 linearly
  88717. * @param startValue Start value of the animation curve
  88718. * @param endValue End value of the animation curve
  88719. * @param gradient Scalar amount to interpolate
  88720. * @returns Interpolated Vector2 value
  88721. */
  88722. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88723. /**
  88724. * Interpolates a Vector2 cubically
  88725. * @param startValue Start value of the animation curve
  88726. * @param outTangent End tangent of the animation
  88727. * @param endValue End value of the animation curve
  88728. * @param inTangent Start tangent of the animation curve
  88729. * @param gradient Scalar amount to interpolate
  88730. * @returns Interpolated Vector2 value
  88731. */
  88732. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88733. /**
  88734. * Interpolates a size linearly
  88735. * @param startValue Start value of the animation curve
  88736. * @param endValue End value of the animation curve
  88737. * @param gradient Scalar amount to interpolate
  88738. * @returns Interpolated Size value
  88739. */
  88740. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88741. /**
  88742. * Interpolates a Color3 linearly
  88743. * @param startValue Start value of the animation curve
  88744. * @param endValue End value of the animation curve
  88745. * @param gradient Scalar amount to interpolate
  88746. * @returns Interpolated Color3 value
  88747. */
  88748. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88749. /**
  88750. * @hidden Internal use only
  88751. */
  88752. _getKeyValue(value: any): any;
  88753. /**
  88754. * @hidden Internal use only
  88755. */
  88756. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88757. /**
  88758. * Defines the function to use to interpolate matrices
  88759. * @param startValue defines the start matrix
  88760. * @param endValue defines the end matrix
  88761. * @param gradient defines the gradient between both matrices
  88762. * @param result defines an optional target matrix where to store the interpolation
  88763. * @returns the interpolated matrix
  88764. */
  88765. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88766. /**
  88767. * Makes a copy of the animation
  88768. * @returns Cloned animation
  88769. */
  88770. clone(): Animation;
  88771. /**
  88772. * Sets the key frames of the animation
  88773. * @param values The animation key frames to set
  88774. */
  88775. setKeys(values: Array<IAnimationKey>): void;
  88776. /**
  88777. * Serializes the animation to an object
  88778. * @returns Serialized object
  88779. */
  88780. serialize(): any;
  88781. /**
  88782. * Float animation type
  88783. */
  88784. private static _ANIMATIONTYPE_FLOAT;
  88785. /**
  88786. * Vector3 animation type
  88787. */
  88788. private static _ANIMATIONTYPE_VECTOR3;
  88789. /**
  88790. * Quaternion animation type
  88791. */
  88792. private static _ANIMATIONTYPE_QUATERNION;
  88793. /**
  88794. * Matrix animation type
  88795. */
  88796. private static _ANIMATIONTYPE_MATRIX;
  88797. /**
  88798. * Color3 animation type
  88799. */
  88800. private static _ANIMATIONTYPE_COLOR3;
  88801. /**
  88802. * Vector2 animation type
  88803. */
  88804. private static _ANIMATIONTYPE_VECTOR2;
  88805. /**
  88806. * Size animation type
  88807. */
  88808. private static _ANIMATIONTYPE_SIZE;
  88809. /**
  88810. * Relative Loop Mode
  88811. */
  88812. private static _ANIMATIONLOOPMODE_RELATIVE;
  88813. /**
  88814. * Cycle Loop Mode
  88815. */
  88816. private static _ANIMATIONLOOPMODE_CYCLE;
  88817. /**
  88818. * Constant Loop Mode
  88819. */
  88820. private static _ANIMATIONLOOPMODE_CONSTANT;
  88821. /**
  88822. * Get the float animation type
  88823. */
  88824. static readonly ANIMATIONTYPE_FLOAT: number;
  88825. /**
  88826. * Get the Vector3 animation type
  88827. */
  88828. static readonly ANIMATIONTYPE_VECTOR3: number;
  88829. /**
  88830. * Get the Vector2 animation type
  88831. */
  88832. static readonly ANIMATIONTYPE_VECTOR2: number;
  88833. /**
  88834. * Get the Size animation type
  88835. */
  88836. static readonly ANIMATIONTYPE_SIZE: number;
  88837. /**
  88838. * Get the Quaternion animation type
  88839. */
  88840. static readonly ANIMATIONTYPE_QUATERNION: number;
  88841. /**
  88842. * Get the Matrix animation type
  88843. */
  88844. static readonly ANIMATIONTYPE_MATRIX: number;
  88845. /**
  88846. * Get the Color3 animation type
  88847. */
  88848. static readonly ANIMATIONTYPE_COLOR3: number;
  88849. /**
  88850. * Get the Relative Loop Mode
  88851. */
  88852. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88853. /**
  88854. * Get the Cycle Loop Mode
  88855. */
  88856. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88857. /**
  88858. * Get the Constant Loop Mode
  88859. */
  88860. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88861. /** @hidden */
  88862. static _UniversalLerp(left: any, right: any, amount: number): any;
  88863. /**
  88864. * Parses an animation object and creates an animation
  88865. * @param parsedAnimation Parsed animation object
  88866. * @returns Animation object
  88867. */
  88868. static Parse(parsedAnimation: any): Animation;
  88869. /**
  88870. * Appends the serialized animations from the source animations
  88871. * @param source Source containing the animations
  88872. * @param destination Target to store the animations
  88873. */
  88874. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88875. }
  88876. }
  88877. declare module BABYLON {
  88878. /**
  88879. * Base class of all the textures in babylon.
  88880. * It groups all the common properties the materials, post process, lights... might need
  88881. * in order to make a correct use of the texture.
  88882. */
  88883. export class BaseTexture implements IAnimatable {
  88884. /**
  88885. * Default anisotropic filtering level for the application.
  88886. * It is set to 4 as a good tradeoff between perf and quality.
  88887. */
  88888. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88889. /**
  88890. * Gets or sets the unique id of the texture
  88891. */
  88892. uniqueId: number;
  88893. /**
  88894. * Define the name of the texture.
  88895. */
  88896. name: string;
  88897. /**
  88898. * Gets or sets an object used to store user defined information.
  88899. */
  88900. metadata: any;
  88901. /**
  88902. * For internal use only. Please do not use.
  88903. */
  88904. reservedDataStore: any;
  88905. private _hasAlpha;
  88906. /**
  88907. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88908. */
  88909. hasAlpha: boolean;
  88910. /**
  88911. * Defines if the alpha value should be determined via the rgb values.
  88912. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88913. */
  88914. getAlphaFromRGB: boolean;
  88915. /**
  88916. * Intensity or strength of the texture.
  88917. * It is commonly used by materials to fine tune the intensity of the texture
  88918. */
  88919. level: number;
  88920. /**
  88921. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88922. * This is part of the texture as textures usually maps to one uv set.
  88923. */
  88924. coordinatesIndex: number;
  88925. private _coordinatesMode;
  88926. /**
  88927. * How a texture is mapped.
  88928. *
  88929. * | Value | Type | Description |
  88930. * | ----- | ----------------------------------- | ----------- |
  88931. * | 0 | EXPLICIT_MODE | |
  88932. * | 1 | SPHERICAL_MODE | |
  88933. * | 2 | PLANAR_MODE | |
  88934. * | 3 | CUBIC_MODE | |
  88935. * | 4 | PROJECTION_MODE | |
  88936. * | 5 | SKYBOX_MODE | |
  88937. * | 6 | INVCUBIC_MODE | |
  88938. * | 7 | EQUIRECTANGULAR_MODE | |
  88939. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88940. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88941. */
  88942. coordinatesMode: number;
  88943. /**
  88944. * | Value | Type | Description |
  88945. * | ----- | ------------------ | ----------- |
  88946. * | 0 | CLAMP_ADDRESSMODE | |
  88947. * | 1 | WRAP_ADDRESSMODE | |
  88948. * | 2 | MIRROR_ADDRESSMODE | |
  88949. */
  88950. wrapU: number;
  88951. /**
  88952. * | Value | Type | Description |
  88953. * | ----- | ------------------ | ----------- |
  88954. * | 0 | CLAMP_ADDRESSMODE | |
  88955. * | 1 | WRAP_ADDRESSMODE | |
  88956. * | 2 | MIRROR_ADDRESSMODE | |
  88957. */
  88958. wrapV: number;
  88959. /**
  88960. * | Value | Type | Description |
  88961. * | ----- | ------------------ | ----------- |
  88962. * | 0 | CLAMP_ADDRESSMODE | |
  88963. * | 1 | WRAP_ADDRESSMODE | |
  88964. * | 2 | MIRROR_ADDRESSMODE | |
  88965. */
  88966. wrapR: number;
  88967. /**
  88968. * With compliant hardware and browser (supporting anisotropic filtering)
  88969. * this defines the level of anisotropic filtering in the texture.
  88970. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88971. */
  88972. anisotropicFilteringLevel: number;
  88973. /**
  88974. * Define if the texture is a cube texture or if false a 2d texture.
  88975. */
  88976. isCube: boolean;
  88977. /**
  88978. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88979. */
  88980. is3D: boolean;
  88981. /**
  88982. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88983. * HDR texture are usually stored in linear space.
  88984. * This only impacts the PBR and Background materials
  88985. */
  88986. gammaSpace: boolean;
  88987. /**
  88988. * Gets whether or not the texture contains RGBD data.
  88989. */
  88990. readonly isRGBD: boolean;
  88991. /**
  88992. * Is Z inverted in the texture (useful in a cube texture).
  88993. */
  88994. invertZ: boolean;
  88995. /**
  88996. * Are mip maps generated for this texture or not.
  88997. */
  88998. readonly noMipmap: boolean;
  88999. /**
  89000. * @hidden
  89001. */
  89002. lodLevelInAlpha: boolean;
  89003. /**
  89004. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89005. */
  89006. lodGenerationOffset: number;
  89007. /**
  89008. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89009. */
  89010. lodGenerationScale: number;
  89011. /**
  89012. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89013. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89014. * average roughness values.
  89015. */
  89016. linearSpecularLOD: boolean;
  89017. /**
  89018. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89019. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89020. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89021. */
  89022. irradianceTexture: Nullable<BaseTexture>;
  89023. /**
  89024. * Define if the texture is a render target.
  89025. */
  89026. isRenderTarget: boolean;
  89027. /**
  89028. * Define the unique id of the texture in the scene.
  89029. */
  89030. readonly uid: string;
  89031. /**
  89032. * Return a string representation of the texture.
  89033. * @returns the texture as a string
  89034. */
  89035. toString(): string;
  89036. /**
  89037. * Get the class name of the texture.
  89038. * @returns "BaseTexture"
  89039. */
  89040. getClassName(): string;
  89041. /**
  89042. * Define the list of animation attached to the texture.
  89043. */
  89044. animations: Animation[];
  89045. /**
  89046. * An event triggered when the texture is disposed.
  89047. */
  89048. onDisposeObservable: Observable<BaseTexture>;
  89049. private _onDisposeObserver;
  89050. /**
  89051. * Callback triggered when the texture has been disposed.
  89052. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89053. */
  89054. onDispose: () => void;
  89055. /**
  89056. * Define the current state of the loading sequence when in delayed load mode.
  89057. */
  89058. delayLoadState: number;
  89059. private _scene;
  89060. /** @hidden */
  89061. _texture: Nullable<InternalTexture>;
  89062. private _uid;
  89063. /**
  89064. * Define if the texture is preventinga material to render or not.
  89065. * If not and the texture is not ready, the engine will use a default black texture instead.
  89066. */
  89067. readonly isBlocking: boolean;
  89068. /**
  89069. * Instantiates a new BaseTexture.
  89070. * Base class of all the textures in babylon.
  89071. * It groups all the common properties the materials, post process, lights... might need
  89072. * in order to make a correct use of the texture.
  89073. * @param scene Define the scene the texture blongs to
  89074. */
  89075. constructor(scene: Nullable<Scene>);
  89076. /**
  89077. * Get the scene the texture belongs to.
  89078. * @returns the scene or null if undefined
  89079. */
  89080. getScene(): Nullable<Scene>;
  89081. /**
  89082. * Get the texture transform matrix used to offset tile the texture for istance.
  89083. * @returns the transformation matrix
  89084. */
  89085. getTextureMatrix(): Matrix;
  89086. /**
  89087. * Get the texture reflection matrix used to rotate/transform the reflection.
  89088. * @returns the reflection matrix
  89089. */
  89090. getReflectionTextureMatrix(): Matrix;
  89091. /**
  89092. * Get the underlying lower level texture from Babylon.
  89093. * @returns the insternal texture
  89094. */
  89095. getInternalTexture(): Nullable<InternalTexture>;
  89096. /**
  89097. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89098. * @returns true if ready or not blocking
  89099. */
  89100. isReadyOrNotBlocking(): boolean;
  89101. /**
  89102. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89103. * @returns true if fully ready
  89104. */
  89105. isReady(): boolean;
  89106. private _cachedSize;
  89107. /**
  89108. * Get the size of the texture.
  89109. * @returns the texture size.
  89110. */
  89111. getSize(): ISize;
  89112. /**
  89113. * Get the base size of the texture.
  89114. * It can be different from the size if the texture has been resized for POT for instance
  89115. * @returns the base size
  89116. */
  89117. getBaseSize(): ISize;
  89118. /**
  89119. * Update the sampling mode of the texture.
  89120. * Default is Trilinear mode.
  89121. *
  89122. * | Value | Type | Description |
  89123. * | ----- | ------------------ | ----------- |
  89124. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89125. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89126. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89127. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89128. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89129. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89130. * | 7 | NEAREST_LINEAR | |
  89131. * | 8 | NEAREST_NEAREST | |
  89132. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89133. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89134. * | 11 | LINEAR_LINEAR | |
  89135. * | 12 | LINEAR_NEAREST | |
  89136. *
  89137. * > _mag_: magnification filter (close to the viewer)
  89138. * > _min_: minification filter (far from the viewer)
  89139. * > _mip_: filter used between mip map levels
  89140. *@param samplingMode Define the new sampling mode of the texture
  89141. */
  89142. updateSamplingMode(samplingMode: number): void;
  89143. /**
  89144. * Scales the texture if is `canRescale()`
  89145. * @param ratio the resize factor we want to use to rescale
  89146. */
  89147. scale(ratio: number): void;
  89148. /**
  89149. * Get if the texture can rescale.
  89150. */
  89151. readonly canRescale: boolean;
  89152. /** @hidden */
  89153. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89154. /** @hidden */
  89155. _rebuild(): void;
  89156. /**
  89157. * Triggers the load sequence in delayed load mode.
  89158. */
  89159. delayLoad(): void;
  89160. /**
  89161. * Clones the texture.
  89162. * @returns the cloned texture
  89163. */
  89164. clone(): Nullable<BaseTexture>;
  89165. /**
  89166. * Get the texture underlying type (INT, FLOAT...)
  89167. */
  89168. readonly textureType: number;
  89169. /**
  89170. * Get the texture underlying format (RGB, RGBA...)
  89171. */
  89172. readonly textureFormat: number;
  89173. /**
  89174. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89175. * This will returns an RGBA array buffer containing either in values (0-255) or
  89176. * float values (0-1) depending of the underlying buffer type.
  89177. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89178. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89179. * @param buffer defines a user defined buffer to fill with data (can be null)
  89180. * @returns The Array buffer containing the pixels data.
  89181. */
  89182. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89183. /**
  89184. * Release and destroy the underlying lower level texture aka internalTexture.
  89185. */
  89186. releaseInternalTexture(): void;
  89187. /**
  89188. * Get the polynomial representation of the texture data.
  89189. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89190. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89191. */
  89192. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89193. /** @hidden */
  89194. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89195. /** @hidden */
  89196. readonly _lodTextureMid: Nullable<BaseTexture>;
  89197. /** @hidden */
  89198. readonly _lodTextureLow: Nullable<BaseTexture>;
  89199. /**
  89200. * Dispose the texture and release its associated resources.
  89201. */
  89202. dispose(): void;
  89203. /**
  89204. * Serialize the texture into a JSON representation that can be parsed later on.
  89205. * @returns the JSON representation of the texture
  89206. */
  89207. serialize(): any;
  89208. /**
  89209. * Helper function to be called back once a list of texture contains only ready textures.
  89210. * @param textures Define the list of textures to wait for
  89211. * @param callback Define the callback triggered once the entire list will be ready
  89212. */
  89213. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89214. }
  89215. }
  89216. declare module BABYLON {
  89217. /**
  89218. * Uniform buffer objects.
  89219. *
  89220. * Handles blocks of uniform on the GPU.
  89221. *
  89222. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89223. *
  89224. * For more information, please refer to :
  89225. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89226. */
  89227. export class UniformBuffer {
  89228. private _engine;
  89229. private _buffer;
  89230. private _data;
  89231. private _bufferData;
  89232. private _dynamic?;
  89233. private _uniformLocations;
  89234. private _uniformSizes;
  89235. private _uniformLocationPointer;
  89236. private _needSync;
  89237. private _noUBO;
  89238. private _currentEffect;
  89239. private static _MAX_UNIFORM_SIZE;
  89240. private static _tempBuffer;
  89241. /**
  89242. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89243. * This is dynamic to allow compat with webgl 1 and 2.
  89244. * You will need to pass the name of the uniform as well as the value.
  89245. */
  89246. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89247. /**
  89248. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89249. * This is dynamic to allow compat with webgl 1 and 2.
  89250. * You will need to pass the name of the uniform as well as the value.
  89251. */
  89252. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89253. /**
  89254. * Lambda to Update a single float in a uniform buffer.
  89255. * This is dynamic to allow compat with webgl 1 and 2.
  89256. * You will need to pass the name of the uniform as well as the value.
  89257. */
  89258. updateFloat: (name: string, x: number) => void;
  89259. /**
  89260. * Lambda to Update a vec2 of float in a uniform buffer.
  89261. * This is dynamic to allow compat with webgl 1 and 2.
  89262. * You will need to pass the name of the uniform as well as the value.
  89263. */
  89264. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89265. /**
  89266. * Lambda to Update a vec3 of float in a uniform buffer.
  89267. * This is dynamic to allow compat with webgl 1 and 2.
  89268. * You will need to pass the name of the uniform as well as the value.
  89269. */
  89270. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89271. /**
  89272. * Lambda to Update a vec4 of float in a uniform buffer.
  89273. * This is dynamic to allow compat with webgl 1 and 2.
  89274. * You will need to pass the name of the uniform as well as the value.
  89275. */
  89276. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89277. /**
  89278. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89279. * This is dynamic to allow compat with webgl 1 and 2.
  89280. * You will need to pass the name of the uniform as well as the value.
  89281. */
  89282. updateMatrix: (name: string, mat: Matrix) => void;
  89283. /**
  89284. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89285. * This is dynamic to allow compat with webgl 1 and 2.
  89286. * You will need to pass the name of the uniform as well as the value.
  89287. */
  89288. updateVector3: (name: string, vector: Vector3) => void;
  89289. /**
  89290. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89291. * This is dynamic to allow compat with webgl 1 and 2.
  89292. * You will need to pass the name of the uniform as well as the value.
  89293. */
  89294. updateVector4: (name: string, vector: Vector4) => void;
  89295. /**
  89296. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89297. * This is dynamic to allow compat with webgl 1 and 2.
  89298. * You will need to pass the name of the uniform as well as the value.
  89299. */
  89300. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89301. /**
  89302. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89303. * This is dynamic to allow compat with webgl 1 and 2.
  89304. * You will need to pass the name of the uniform as well as the value.
  89305. */
  89306. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89307. /**
  89308. * Instantiates a new Uniform buffer objects.
  89309. *
  89310. * Handles blocks of uniform on the GPU.
  89311. *
  89312. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89313. *
  89314. * For more information, please refer to :
  89315. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89316. * @param engine Define the engine the buffer is associated with
  89317. * @param data Define the data contained in the buffer
  89318. * @param dynamic Define if the buffer is updatable
  89319. */
  89320. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89321. /**
  89322. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89323. * or just falling back on setUniformXXX calls.
  89324. */
  89325. readonly useUbo: boolean;
  89326. /**
  89327. * Indicates if the WebGL underlying uniform buffer is in sync
  89328. * with the javascript cache data.
  89329. */
  89330. readonly isSync: boolean;
  89331. /**
  89332. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89333. * Also, a dynamic UniformBuffer will disable cache verification and always
  89334. * update the underlying WebGL uniform buffer to the GPU.
  89335. * @returns if Dynamic, otherwise false
  89336. */
  89337. isDynamic(): boolean;
  89338. /**
  89339. * The data cache on JS side.
  89340. * @returns the underlying data as a float array
  89341. */
  89342. getData(): Float32Array;
  89343. /**
  89344. * The underlying WebGL Uniform buffer.
  89345. * @returns the webgl buffer
  89346. */
  89347. getBuffer(): Nullable<DataBuffer>;
  89348. /**
  89349. * std140 layout specifies how to align data within an UBO structure.
  89350. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89351. * for specs.
  89352. */
  89353. private _fillAlignment;
  89354. /**
  89355. * Adds an uniform in the buffer.
  89356. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89357. * for the layout to be correct !
  89358. * @param name Name of the uniform, as used in the uniform block in the shader.
  89359. * @param size Data size, or data directly.
  89360. */
  89361. addUniform(name: string, size: number | number[]): void;
  89362. /**
  89363. * Adds a Matrix 4x4 to the uniform buffer.
  89364. * @param name Name of the uniform, as used in the uniform block in the shader.
  89365. * @param mat A 4x4 matrix.
  89366. */
  89367. addMatrix(name: string, mat: Matrix): void;
  89368. /**
  89369. * Adds a vec2 to the uniform buffer.
  89370. * @param name Name of the uniform, as used in the uniform block in the shader.
  89371. * @param x Define the x component value of the vec2
  89372. * @param y Define the y component value of the vec2
  89373. */
  89374. addFloat2(name: string, x: number, y: number): void;
  89375. /**
  89376. * Adds a vec3 to the uniform buffer.
  89377. * @param name Name of the uniform, as used in the uniform block in the shader.
  89378. * @param x Define the x component value of the vec3
  89379. * @param y Define the y component value of the vec3
  89380. * @param z Define the z component value of the vec3
  89381. */
  89382. addFloat3(name: string, x: number, y: number, z: number): void;
  89383. /**
  89384. * Adds a vec3 to the uniform buffer.
  89385. * @param name Name of the uniform, as used in the uniform block in the shader.
  89386. * @param color Define the vec3 from a Color
  89387. */
  89388. addColor3(name: string, color: Color3): void;
  89389. /**
  89390. * Adds a vec4 to the uniform buffer.
  89391. * @param name Name of the uniform, as used in the uniform block in the shader.
  89392. * @param color Define the rgb components from a Color
  89393. * @param alpha Define the a component of the vec4
  89394. */
  89395. addColor4(name: string, color: Color3, alpha: number): void;
  89396. /**
  89397. * Adds a vec3 to the uniform buffer.
  89398. * @param name Name of the uniform, as used in the uniform block in the shader.
  89399. * @param vector Define the vec3 components from a Vector
  89400. */
  89401. addVector3(name: string, vector: Vector3): void;
  89402. /**
  89403. * Adds a Matrix 3x3 to the uniform buffer.
  89404. * @param name Name of the uniform, as used in the uniform block in the shader.
  89405. */
  89406. addMatrix3x3(name: string): void;
  89407. /**
  89408. * Adds a Matrix 2x2 to the uniform buffer.
  89409. * @param name Name of the uniform, as used in the uniform block in the shader.
  89410. */
  89411. addMatrix2x2(name: string): void;
  89412. /**
  89413. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89414. */
  89415. create(): void;
  89416. /** @hidden */
  89417. _rebuild(): void;
  89418. /**
  89419. * Updates the WebGL Uniform Buffer on the GPU.
  89420. * If the `dynamic` flag is set to true, no cache comparison is done.
  89421. * Otherwise, the buffer will be updated only if the cache differs.
  89422. */
  89423. update(): void;
  89424. /**
  89425. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89426. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89427. * @param data Define the flattened data
  89428. * @param size Define the size of the data.
  89429. */
  89430. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89431. private _updateMatrix3x3ForUniform;
  89432. private _updateMatrix3x3ForEffect;
  89433. private _updateMatrix2x2ForEffect;
  89434. private _updateMatrix2x2ForUniform;
  89435. private _updateFloatForEffect;
  89436. private _updateFloatForUniform;
  89437. private _updateFloat2ForEffect;
  89438. private _updateFloat2ForUniform;
  89439. private _updateFloat3ForEffect;
  89440. private _updateFloat3ForUniform;
  89441. private _updateFloat4ForEffect;
  89442. private _updateFloat4ForUniform;
  89443. private _updateMatrixForEffect;
  89444. private _updateMatrixForUniform;
  89445. private _updateVector3ForEffect;
  89446. private _updateVector3ForUniform;
  89447. private _updateVector4ForEffect;
  89448. private _updateVector4ForUniform;
  89449. private _updateColor3ForEffect;
  89450. private _updateColor3ForUniform;
  89451. private _updateColor4ForEffect;
  89452. private _updateColor4ForUniform;
  89453. /**
  89454. * Sets a sampler uniform on the effect.
  89455. * @param name Define the name of the sampler.
  89456. * @param texture Define the texture to set in the sampler
  89457. */
  89458. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89459. /**
  89460. * Directly updates the value of the uniform in the cache AND on the GPU.
  89461. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89462. * @param data Define the flattened data
  89463. */
  89464. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89465. /**
  89466. * Binds this uniform buffer to an effect.
  89467. * @param effect Define the effect to bind the buffer to
  89468. * @param name Name of the uniform block in the shader.
  89469. */
  89470. bindToEffect(effect: Effect, name: string): void;
  89471. /**
  89472. * Disposes the uniform buffer.
  89473. */
  89474. dispose(): void;
  89475. }
  89476. }
  89477. declare module BABYLON {
  89478. /**
  89479. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89481. */
  89482. export class Analyser {
  89483. /**
  89484. * Gets or sets the smoothing
  89485. * @ignorenaming
  89486. */
  89487. SMOOTHING: number;
  89488. /**
  89489. * Gets or sets the FFT table size
  89490. * @ignorenaming
  89491. */
  89492. FFT_SIZE: number;
  89493. /**
  89494. * Gets or sets the bar graph amplitude
  89495. * @ignorenaming
  89496. */
  89497. BARGRAPHAMPLITUDE: number;
  89498. /**
  89499. * Gets or sets the position of the debug canvas
  89500. * @ignorenaming
  89501. */
  89502. DEBUGCANVASPOS: {
  89503. x: number;
  89504. y: number;
  89505. };
  89506. /**
  89507. * Gets or sets the debug canvas size
  89508. * @ignorenaming
  89509. */
  89510. DEBUGCANVASSIZE: {
  89511. width: number;
  89512. height: number;
  89513. };
  89514. private _byteFreqs;
  89515. private _byteTime;
  89516. private _floatFreqs;
  89517. private _webAudioAnalyser;
  89518. private _debugCanvas;
  89519. private _debugCanvasContext;
  89520. private _scene;
  89521. private _registerFunc;
  89522. private _audioEngine;
  89523. /**
  89524. * Creates a new analyser
  89525. * @param scene defines hosting scene
  89526. */
  89527. constructor(scene: Scene);
  89528. /**
  89529. * Get the number of data values you will have to play with for the visualization
  89530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89531. * @returns a number
  89532. */
  89533. getFrequencyBinCount(): number;
  89534. /**
  89535. * Gets the current frequency data as a byte array
  89536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89537. * @returns a Uint8Array
  89538. */
  89539. getByteFrequencyData(): Uint8Array;
  89540. /**
  89541. * Gets the current waveform as a byte array
  89542. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89543. * @returns a Uint8Array
  89544. */
  89545. getByteTimeDomainData(): Uint8Array;
  89546. /**
  89547. * Gets the current frequency data as a float array
  89548. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89549. * @returns a Float32Array
  89550. */
  89551. getFloatFrequencyData(): Float32Array;
  89552. /**
  89553. * Renders the debug canvas
  89554. */
  89555. drawDebugCanvas(): void;
  89556. /**
  89557. * Stops rendering the debug canvas and removes it
  89558. */
  89559. stopDebugCanvas(): void;
  89560. /**
  89561. * Connects two audio nodes
  89562. * @param inputAudioNode defines first node to connect
  89563. * @param outputAudioNode defines second node to connect
  89564. */
  89565. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89566. /**
  89567. * Releases all associated resources
  89568. */
  89569. dispose(): void;
  89570. }
  89571. }
  89572. declare module BABYLON {
  89573. /**
  89574. * This represents an audio engine and it is responsible
  89575. * to play, synchronize and analyse sounds throughout the application.
  89576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89577. */
  89578. export interface IAudioEngine extends IDisposable {
  89579. /**
  89580. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89581. */
  89582. readonly canUseWebAudio: boolean;
  89583. /**
  89584. * Gets the current AudioContext if available.
  89585. */
  89586. readonly audioContext: Nullable<AudioContext>;
  89587. /**
  89588. * The master gain node defines the global audio volume of your audio engine.
  89589. */
  89590. readonly masterGain: GainNode;
  89591. /**
  89592. * Gets whether or not mp3 are supported by your browser.
  89593. */
  89594. readonly isMP3supported: boolean;
  89595. /**
  89596. * Gets whether or not ogg are supported by your browser.
  89597. */
  89598. readonly isOGGsupported: boolean;
  89599. /**
  89600. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89601. * @ignoreNaming
  89602. */
  89603. WarnedWebAudioUnsupported: boolean;
  89604. /**
  89605. * Defines if the audio engine relies on a custom unlocked button.
  89606. * In this case, the embedded button will not be displayed.
  89607. */
  89608. useCustomUnlockedButton: boolean;
  89609. /**
  89610. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89611. */
  89612. readonly unlocked: boolean;
  89613. /**
  89614. * Event raised when audio has been unlocked on the browser.
  89615. */
  89616. onAudioUnlockedObservable: Observable<AudioEngine>;
  89617. /**
  89618. * Event raised when audio has been locked on the browser.
  89619. */
  89620. onAudioLockedObservable: Observable<AudioEngine>;
  89621. /**
  89622. * Flags the audio engine in Locked state.
  89623. * This happens due to new browser policies preventing audio to autoplay.
  89624. */
  89625. lock(): void;
  89626. /**
  89627. * Unlocks the audio engine once a user action has been done on the dom.
  89628. * This is helpful to resume play once browser policies have been satisfied.
  89629. */
  89630. unlock(): void;
  89631. }
  89632. /**
  89633. * This represents the default audio engine used in babylon.
  89634. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89636. */
  89637. export class AudioEngine implements IAudioEngine {
  89638. private _audioContext;
  89639. private _audioContextInitialized;
  89640. private _muteButton;
  89641. private _hostElement;
  89642. /**
  89643. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89644. */
  89645. canUseWebAudio: boolean;
  89646. /**
  89647. * The master gain node defines the global audio volume of your audio engine.
  89648. */
  89649. masterGain: GainNode;
  89650. /**
  89651. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89652. * @ignoreNaming
  89653. */
  89654. WarnedWebAudioUnsupported: boolean;
  89655. /**
  89656. * Gets whether or not mp3 are supported by your browser.
  89657. */
  89658. isMP3supported: boolean;
  89659. /**
  89660. * Gets whether or not ogg are supported by your browser.
  89661. */
  89662. isOGGsupported: boolean;
  89663. /**
  89664. * Gets whether audio has been unlocked on the device.
  89665. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89666. * a user interaction has happened.
  89667. */
  89668. unlocked: boolean;
  89669. /**
  89670. * Defines if the audio engine relies on a custom unlocked button.
  89671. * In this case, the embedded button will not be displayed.
  89672. */
  89673. useCustomUnlockedButton: boolean;
  89674. /**
  89675. * Event raised when audio has been unlocked on the browser.
  89676. */
  89677. onAudioUnlockedObservable: Observable<AudioEngine>;
  89678. /**
  89679. * Event raised when audio has been locked on the browser.
  89680. */
  89681. onAudioLockedObservable: Observable<AudioEngine>;
  89682. /**
  89683. * Gets the current AudioContext if available.
  89684. */
  89685. readonly audioContext: Nullable<AudioContext>;
  89686. private _connectedAnalyser;
  89687. /**
  89688. * Instantiates a new audio engine.
  89689. *
  89690. * There should be only one per page as some browsers restrict the number
  89691. * of audio contexts you can create.
  89692. * @param hostElement defines the host element where to display the mute icon if necessary
  89693. */
  89694. constructor(hostElement?: Nullable<HTMLElement>);
  89695. /**
  89696. * Flags the audio engine in Locked state.
  89697. * This happens due to new browser policies preventing audio to autoplay.
  89698. */
  89699. lock(): void;
  89700. /**
  89701. * Unlocks the audio engine once a user action has been done on the dom.
  89702. * This is helpful to resume play once browser policies have been satisfied.
  89703. */
  89704. unlock(): void;
  89705. private _resumeAudioContext;
  89706. private _initializeAudioContext;
  89707. private _tryToRun;
  89708. private _triggerRunningState;
  89709. private _triggerSuspendedState;
  89710. private _displayMuteButton;
  89711. private _moveButtonToTopLeft;
  89712. private _onResize;
  89713. private _hideMuteButton;
  89714. /**
  89715. * Destroy and release the resources associated with the audio ccontext.
  89716. */
  89717. dispose(): void;
  89718. /**
  89719. * Gets the global volume sets on the master gain.
  89720. * @returns the global volume if set or -1 otherwise
  89721. */
  89722. getGlobalVolume(): number;
  89723. /**
  89724. * Sets the global volume of your experience (sets on the master gain).
  89725. * @param newVolume Defines the new global volume of the application
  89726. */
  89727. setGlobalVolume(newVolume: number): void;
  89728. /**
  89729. * Connect the audio engine to an audio analyser allowing some amazing
  89730. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89732. * @param analyser The analyser to connect to the engine
  89733. */
  89734. connectToAnalyser(analyser: Analyser): void;
  89735. }
  89736. }
  89737. declare module BABYLON {
  89738. /**
  89739. * Interface used to present a loading screen while loading a scene
  89740. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89741. */
  89742. export interface ILoadingScreen {
  89743. /**
  89744. * Function called to display the loading screen
  89745. */
  89746. displayLoadingUI: () => void;
  89747. /**
  89748. * Function called to hide the loading screen
  89749. */
  89750. hideLoadingUI: () => void;
  89751. /**
  89752. * Gets or sets the color to use for the background
  89753. */
  89754. loadingUIBackgroundColor: string;
  89755. /**
  89756. * Gets or sets the text to display while loading
  89757. */
  89758. loadingUIText: string;
  89759. }
  89760. /**
  89761. * Class used for the default loading screen
  89762. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89763. */
  89764. export class DefaultLoadingScreen implements ILoadingScreen {
  89765. private _renderingCanvas;
  89766. private _loadingText;
  89767. private _loadingDivBackgroundColor;
  89768. private _loadingDiv;
  89769. private _loadingTextDiv;
  89770. /** Gets or sets the logo url to use for the default loading screen */
  89771. static DefaultLogoUrl: string;
  89772. /** Gets or sets the spinner url to use for the default loading screen */
  89773. static DefaultSpinnerUrl: string;
  89774. /**
  89775. * Creates a new default loading screen
  89776. * @param _renderingCanvas defines the canvas used to render the scene
  89777. * @param _loadingText defines the default text to display
  89778. * @param _loadingDivBackgroundColor defines the default background color
  89779. */
  89780. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89781. /**
  89782. * Function called to display the loading screen
  89783. */
  89784. displayLoadingUI(): void;
  89785. /**
  89786. * Function called to hide the loading screen
  89787. */
  89788. hideLoadingUI(): void;
  89789. /**
  89790. * Gets or sets the text to display while loading
  89791. */
  89792. loadingUIText: string;
  89793. /**
  89794. * Gets or sets the color to use for the background
  89795. */
  89796. loadingUIBackgroundColor: string;
  89797. private _resizeLoadingUI;
  89798. }
  89799. }
  89800. declare module BABYLON {
  89801. /** @hidden */
  89802. export class WebGLPipelineContext implements IPipelineContext {
  89803. engine: Engine;
  89804. program: Nullable<WebGLProgram>;
  89805. context?: WebGLRenderingContext;
  89806. vertexShader?: WebGLShader;
  89807. fragmentShader?: WebGLShader;
  89808. isParallelCompiled: boolean;
  89809. onCompiled?: () => void;
  89810. transformFeedback?: WebGLTransformFeedback | null;
  89811. readonly isAsync: boolean;
  89812. readonly isReady: boolean;
  89813. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89814. }
  89815. }
  89816. declare module BABYLON {
  89817. /** @hidden */
  89818. export class WebGLDataBuffer extends DataBuffer {
  89819. private _buffer;
  89820. constructor(resource: WebGLBuffer);
  89821. readonly underlyingResource: any;
  89822. }
  89823. }
  89824. declare module BABYLON {
  89825. /** @hidden */
  89826. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89827. attributeProcessor(attribute: string): string;
  89828. varyingProcessor(varying: string, isFragment: boolean): string;
  89829. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89830. }
  89831. }
  89832. declare module BABYLON {
  89833. /**
  89834. * Settings for finer control over video usage
  89835. */
  89836. export interface VideoTextureSettings {
  89837. /**
  89838. * Applies `autoplay` to video, if specified
  89839. */
  89840. autoPlay?: boolean;
  89841. /**
  89842. * Applies `loop` to video, if specified
  89843. */
  89844. loop?: boolean;
  89845. /**
  89846. * Automatically updates internal texture from video at every frame in the render loop
  89847. */
  89848. autoUpdateTexture: boolean;
  89849. /**
  89850. * Image src displayed during the video loading or until the user interacts with the video.
  89851. */
  89852. poster?: string;
  89853. }
  89854. /**
  89855. * If you want to display a video in your scene, this is the special texture for that.
  89856. * This special texture works similar to other textures, with the exception of a few parameters.
  89857. * @see https://doc.babylonjs.com/how_to/video_texture
  89858. */
  89859. export class VideoTexture extends Texture {
  89860. /**
  89861. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89862. */
  89863. readonly autoUpdateTexture: boolean;
  89864. /**
  89865. * The video instance used by the texture internally
  89866. */
  89867. readonly video: HTMLVideoElement;
  89868. private _onUserActionRequestedObservable;
  89869. /**
  89870. * Event triggerd when a dom action is required by the user to play the video.
  89871. * This happens due to recent changes in browser policies preventing video to auto start.
  89872. */
  89873. readonly onUserActionRequestedObservable: Observable<Texture>;
  89874. private _generateMipMaps;
  89875. private _engine;
  89876. private _stillImageCaptured;
  89877. private _displayingPosterTexture;
  89878. private _settings;
  89879. private _createInternalTextureOnEvent;
  89880. /**
  89881. * Creates a video texture.
  89882. * If you want to display a video in your scene, this is the special texture for that.
  89883. * This special texture works similar to other textures, with the exception of a few parameters.
  89884. * @see https://doc.babylonjs.com/how_to/video_texture
  89885. * @param name optional name, will detect from video source, if not defined
  89886. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89887. * @param scene is obviously the current scene.
  89888. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89889. * @param invertY is false by default but can be used to invert video on Y axis
  89890. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89891. * @param settings allows finer control over video usage
  89892. */
  89893. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89894. private _getName;
  89895. private _getVideo;
  89896. private _createInternalTexture;
  89897. private reset;
  89898. /**
  89899. * @hidden Internal method to initiate `update`.
  89900. */
  89901. _rebuild(): void;
  89902. /**
  89903. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89904. */
  89905. update(): void;
  89906. /**
  89907. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89908. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89909. */
  89910. updateTexture(isVisible: boolean): void;
  89911. protected _updateInternalTexture: () => void;
  89912. /**
  89913. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89914. * @param url New url.
  89915. */
  89916. updateURL(url: string): void;
  89917. /**
  89918. * Dispose the texture and release its associated resources.
  89919. */
  89920. dispose(): void;
  89921. /**
  89922. * Creates a video texture straight from a stream.
  89923. * @param scene Define the scene the texture should be created in
  89924. * @param stream Define the stream the texture should be created from
  89925. * @returns The created video texture as a promise
  89926. */
  89927. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89928. /**
  89929. * Creates a video texture straight from your WebCam video feed.
  89930. * @param scene Define the scene the texture should be created in
  89931. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89932. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89933. * @returns The created video texture as a promise
  89934. */
  89935. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89936. minWidth: number;
  89937. maxWidth: number;
  89938. minHeight: number;
  89939. maxHeight: number;
  89940. deviceId: string;
  89941. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89942. /**
  89943. * Creates a video texture straight from your WebCam video feed.
  89944. * @param scene Define the scene the texture should be created in
  89945. * @param onReady Define a callback to triggered once the texture will be ready
  89946. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89947. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89948. */
  89949. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89950. minWidth: number;
  89951. maxWidth: number;
  89952. minHeight: number;
  89953. maxHeight: number;
  89954. deviceId: string;
  89955. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89956. }
  89957. }
  89958. declare module BABYLON {
  89959. /**
  89960. * Interface for attribute information associated with buffer instanciation
  89961. */
  89962. export class InstancingAttributeInfo {
  89963. /**
  89964. * Index/offset of the attribute in the vertex shader
  89965. */
  89966. index: number;
  89967. /**
  89968. * size of the attribute, 1, 2, 3 or 4
  89969. */
  89970. attributeSize: number;
  89971. /**
  89972. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89973. * default is FLOAT
  89974. */
  89975. attribyteType: number;
  89976. /**
  89977. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89978. */
  89979. normalized: boolean;
  89980. /**
  89981. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89982. */
  89983. offset: number;
  89984. /**
  89985. * Name of the GLSL attribute, for debugging purpose only
  89986. */
  89987. attributeName: string;
  89988. }
  89989. /**
  89990. * Define options used to create a depth texture
  89991. */
  89992. export class DepthTextureCreationOptions {
  89993. /** Specifies whether or not a stencil should be allocated in the texture */
  89994. generateStencil?: boolean;
  89995. /** Specifies whether or not bilinear filtering is enable on the texture */
  89996. bilinearFiltering?: boolean;
  89997. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89998. comparisonFunction?: number;
  89999. /** Specifies if the created texture is a cube texture */
  90000. isCube?: boolean;
  90001. }
  90002. /**
  90003. * Class used to describe the capabilities of the engine relatively to the current browser
  90004. */
  90005. export class EngineCapabilities {
  90006. /** Maximum textures units per fragment shader */
  90007. maxTexturesImageUnits: number;
  90008. /** Maximum texture units per vertex shader */
  90009. maxVertexTextureImageUnits: number;
  90010. /** Maximum textures units in the entire pipeline */
  90011. maxCombinedTexturesImageUnits: number;
  90012. /** Maximum texture size */
  90013. maxTextureSize: number;
  90014. /** Maximum cube texture size */
  90015. maxCubemapTextureSize: number;
  90016. /** Maximum render texture size */
  90017. maxRenderTextureSize: number;
  90018. /** Maximum number of vertex attributes */
  90019. maxVertexAttribs: number;
  90020. /** Maximum number of varyings */
  90021. maxVaryingVectors: number;
  90022. /** Maximum number of uniforms per vertex shader */
  90023. maxVertexUniformVectors: number;
  90024. /** Maximum number of uniforms per fragment shader */
  90025. maxFragmentUniformVectors: number;
  90026. /** Defines if standard derivates (dx/dy) are supported */
  90027. standardDerivatives: boolean;
  90028. /** Defines if s3tc texture compression is supported */
  90029. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  90030. /** Defines if pvrtc texture compression is supported */
  90031. pvrtc: any;
  90032. /** Defines if etc1 texture compression is supported */
  90033. etc1: any;
  90034. /** Defines if etc2 texture compression is supported */
  90035. etc2: any;
  90036. /** Defines if astc texture compression is supported */
  90037. astc: any;
  90038. /** Defines if float textures are supported */
  90039. textureFloat: boolean;
  90040. /** Defines if vertex array objects are supported */
  90041. vertexArrayObject: boolean;
  90042. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90043. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90044. /** Gets the maximum level of anisotropy supported */
  90045. maxAnisotropy: number;
  90046. /** Defines if instancing is supported */
  90047. instancedArrays: boolean;
  90048. /** Defines if 32 bits indices are supported */
  90049. uintIndices: boolean;
  90050. /** Defines if high precision shaders are supported */
  90051. highPrecisionShaderSupported: boolean;
  90052. /** Defines if depth reading in the fragment shader is supported */
  90053. fragmentDepthSupported: boolean;
  90054. /** Defines if float texture linear filtering is supported*/
  90055. textureFloatLinearFiltering: boolean;
  90056. /** Defines if rendering to float textures is supported */
  90057. textureFloatRender: boolean;
  90058. /** Defines if half float textures are supported*/
  90059. textureHalfFloat: boolean;
  90060. /** Defines if half float texture linear filtering is supported*/
  90061. textureHalfFloatLinearFiltering: boolean;
  90062. /** Defines if rendering to half float textures is supported */
  90063. textureHalfFloatRender: boolean;
  90064. /** Defines if textureLOD shader command is supported */
  90065. textureLOD: boolean;
  90066. /** Defines if draw buffers extension is supported */
  90067. drawBuffersExtension: boolean;
  90068. /** Defines if depth textures are supported */
  90069. depthTextureExtension: boolean;
  90070. /** Defines if float color buffer are supported */
  90071. colorBufferFloat: boolean;
  90072. /** Gets disjoint timer query extension (null if not supported) */
  90073. timerQuery: EXT_disjoint_timer_query;
  90074. /** Defines if timestamp can be used with timer query */
  90075. canUseTimestampForTimerQuery: boolean;
  90076. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90077. multiview: any;
  90078. /** Function used to let the system compiles shaders in background */
  90079. parallelShaderCompile: {
  90080. COMPLETION_STATUS_KHR: number;
  90081. };
  90082. }
  90083. /** Interface defining initialization parameters for Engine class */
  90084. export interface EngineOptions extends WebGLContextAttributes {
  90085. /**
  90086. * Defines if the engine should no exceed a specified device ratio
  90087. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90088. */
  90089. limitDeviceRatio?: number;
  90090. /**
  90091. * Defines if webvr should be enabled automatically
  90092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90093. */
  90094. autoEnableWebVR?: boolean;
  90095. /**
  90096. * Defines if webgl2 should be turned off even if supported
  90097. * @see http://doc.babylonjs.com/features/webgl2
  90098. */
  90099. disableWebGL2Support?: boolean;
  90100. /**
  90101. * Defines if webaudio should be initialized as well
  90102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90103. */
  90104. audioEngine?: boolean;
  90105. /**
  90106. * Defines if animations should run using a deterministic lock step
  90107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90108. */
  90109. deterministicLockstep?: boolean;
  90110. /** Defines the maximum steps to use with deterministic lock step mode */
  90111. lockstepMaxSteps?: number;
  90112. /**
  90113. * Defines that engine should ignore context lost events
  90114. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90115. */
  90116. doNotHandleContextLost?: boolean;
  90117. /**
  90118. * Defines that engine should ignore modifying touch action attribute and style
  90119. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90120. */
  90121. doNotHandleTouchAction?: boolean;
  90122. /**
  90123. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90124. */
  90125. useHighPrecisionFloats?: boolean;
  90126. }
  90127. /**
  90128. * Defines the interface used by display changed events
  90129. */
  90130. export interface IDisplayChangedEventArgs {
  90131. /** Gets the vrDisplay object (if any) */
  90132. vrDisplay: Nullable<any>;
  90133. /** Gets a boolean indicating if webVR is supported */
  90134. vrSupported: boolean;
  90135. }
  90136. /**
  90137. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90138. */
  90139. export class Engine {
  90140. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90141. static ExceptionList: ({
  90142. key: string;
  90143. capture: string;
  90144. captureConstraint: number;
  90145. targets: string[];
  90146. } | {
  90147. key: string;
  90148. capture: null;
  90149. captureConstraint: null;
  90150. targets: string[];
  90151. })[];
  90152. /** Gets the list of created engines */
  90153. static readonly Instances: Engine[];
  90154. /**
  90155. * Gets the latest created engine
  90156. */
  90157. static readonly LastCreatedEngine: Nullable<Engine>;
  90158. /**
  90159. * Gets the latest created scene
  90160. */
  90161. static readonly LastCreatedScene: Nullable<Scene>;
  90162. /**
  90163. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90164. * @param flag defines which part of the materials must be marked as dirty
  90165. * @param predicate defines a predicate used to filter which materials should be affected
  90166. */
  90167. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90168. /** @hidden */
  90169. static _TextureLoaders: IInternalTextureLoader[];
  90170. /** Defines that alpha blending is disabled */
  90171. static readonly ALPHA_DISABLE: number;
  90172. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90173. static readonly ALPHA_ADD: number;
  90174. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90175. static readonly ALPHA_COMBINE: number;
  90176. /** Defines that alpha blending to DEST - SRC * DEST */
  90177. static readonly ALPHA_SUBTRACT: number;
  90178. /** Defines that alpha blending to SRC * DEST */
  90179. static readonly ALPHA_MULTIPLY: number;
  90180. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90181. static readonly ALPHA_MAXIMIZED: number;
  90182. /** Defines that alpha blending to SRC + DEST */
  90183. static readonly ALPHA_ONEONE: number;
  90184. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90185. static readonly ALPHA_PREMULTIPLIED: number;
  90186. /**
  90187. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90188. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90189. */
  90190. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90191. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90192. static readonly ALPHA_INTERPOLATE: number;
  90193. /**
  90194. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90195. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90196. */
  90197. static readonly ALPHA_SCREENMODE: number;
  90198. /** Defines that the ressource is not delayed*/
  90199. static readonly DELAYLOADSTATE_NONE: number;
  90200. /** Defines that the ressource was successfully delay loaded */
  90201. static readonly DELAYLOADSTATE_LOADED: number;
  90202. /** Defines that the ressource is currently delay loading */
  90203. static readonly DELAYLOADSTATE_LOADING: number;
  90204. /** Defines that the ressource is delayed and has not started loading */
  90205. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90207. static readonly NEVER: number;
  90208. /** 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 */
  90209. static readonly ALWAYS: number;
  90210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90211. static readonly LESS: number;
  90212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90213. static readonly EQUAL: number;
  90214. /** 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 */
  90215. static readonly LEQUAL: number;
  90216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90217. static readonly GREATER: number;
  90218. /** 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 */
  90219. static readonly GEQUAL: number;
  90220. /** 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 */
  90221. static readonly NOTEQUAL: number;
  90222. /** Passed to stencilOperation to specify that stencil value must be kept */
  90223. static readonly KEEP: number;
  90224. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90225. static readonly REPLACE: number;
  90226. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90227. static readonly INCR: number;
  90228. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90229. static readonly DECR: number;
  90230. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90231. static readonly INVERT: number;
  90232. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90233. static readonly INCR_WRAP: number;
  90234. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90235. static readonly DECR_WRAP: number;
  90236. /** Texture is not repeating outside of 0..1 UVs */
  90237. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90238. /** Texture is repeating outside of 0..1 UVs */
  90239. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90240. /** Texture is repeating and mirrored */
  90241. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90242. /** ALPHA */
  90243. static readonly TEXTUREFORMAT_ALPHA: number;
  90244. /** LUMINANCE */
  90245. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90246. /** LUMINANCE_ALPHA */
  90247. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90248. /** RGB */
  90249. static readonly TEXTUREFORMAT_RGB: number;
  90250. /** RGBA */
  90251. static readonly TEXTUREFORMAT_RGBA: number;
  90252. /** RED */
  90253. static readonly TEXTUREFORMAT_RED: number;
  90254. /** RED (2nd reference) */
  90255. static readonly TEXTUREFORMAT_R: number;
  90256. /** RG */
  90257. static readonly TEXTUREFORMAT_RG: number;
  90258. /** RED_INTEGER */
  90259. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90260. /** RED_INTEGER (2nd reference) */
  90261. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90262. /** RG_INTEGER */
  90263. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90264. /** RGB_INTEGER */
  90265. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90266. /** RGBA_INTEGER */
  90267. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90268. /** UNSIGNED_BYTE */
  90269. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90270. /** UNSIGNED_BYTE (2nd reference) */
  90271. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90272. /** FLOAT */
  90273. static readonly TEXTURETYPE_FLOAT: number;
  90274. /** HALF_FLOAT */
  90275. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90276. /** BYTE */
  90277. static readonly TEXTURETYPE_BYTE: number;
  90278. /** SHORT */
  90279. static readonly TEXTURETYPE_SHORT: number;
  90280. /** UNSIGNED_SHORT */
  90281. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90282. /** INT */
  90283. static readonly TEXTURETYPE_INT: number;
  90284. /** UNSIGNED_INT */
  90285. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90286. /** UNSIGNED_SHORT_4_4_4_4 */
  90287. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90288. /** UNSIGNED_SHORT_5_5_5_1 */
  90289. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90290. /** UNSIGNED_SHORT_5_6_5 */
  90291. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90292. /** UNSIGNED_INT_2_10_10_10_REV */
  90293. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90294. /** UNSIGNED_INT_24_8 */
  90295. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90296. /** UNSIGNED_INT_10F_11F_11F_REV */
  90297. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90298. /** UNSIGNED_INT_5_9_9_9_REV */
  90299. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90300. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90301. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90302. /** nearest is mag = nearest and min = nearest and mip = linear */
  90303. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90305. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90306. /** Trilinear is mag = linear and min = linear and mip = linear */
  90307. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90308. /** nearest is mag = nearest and min = nearest and mip = linear */
  90309. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90310. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90311. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90312. /** Trilinear is mag = linear and min = linear and mip = linear */
  90313. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90314. /** mag = nearest and min = nearest and mip = nearest */
  90315. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90316. /** mag = nearest and min = linear and mip = nearest */
  90317. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90318. /** mag = nearest and min = linear and mip = linear */
  90319. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90320. /** mag = nearest and min = linear and mip = none */
  90321. static readonly TEXTURE_NEAREST_LINEAR: number;
  90322. /** mag = nearest and min = nearest and mip = none */
  90323. static readonly TEXTURE_NEAREST_NEAREST: number;
  90324. /** mag = linear and min = nearest and mip = nearest */
  90325. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90326. /** mag = linear and min = nearest and mip = linear */
  90327. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90328. /** mag = linear and min = linear and mip = none */
  90329. static readonly TEXTURE_LINEAR_LINEAR: number;
  90330. /** mag = linear and min = nearest and mip = none */
  90331. static readonly TEXTURE_LINEAR_NEAREST: number;
  90332. /** Explicit coordinates mode */
  90333. static readonly TEXTURE_EXPLICIT_MODE: number;
  90334. /** Spherical coordinates mode */
  90335. static readonly TEXTURE_SPHERICAL_MODE: number;
  90336. /** Planar coordinates mode */
  90337. static readonly TEXTURE_PLANAR_MODE: number;
  90338. /** Cubic coordinates mode */
  90339. static readonly TEXTURE_CUBIC_MODE: number;
  90340. /** Projection coordinates mode */
  90341. static readonly TEXTURE_PROJECTION_MODE: number;
  90342. /** Skybox coordinates mode */
  90343. static readonly TEXTURE_SKYBOX_MODE: number;
  90344. /** Inverse Cubic coordinates mode */
  90345. static readonly TEXTURE_INVCUBIC_MODE: number;
  90346. /** Equirectangular coordinates mode */
  90347. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90348. /** Equirectangular Fixed coordinates mode */
  90349. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90350. /** Equirectangular Fixed Mirrored coordinates mode */
  90351. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90352. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90353. static readonly SCALEMODE_FLOOR: number;
  90354. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90355. static readonly SCALEMODE_NEAREST: number;
  90356. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90357. static readonly SCALEMODE_CEILING: number;
  90358. /**
  90359. * Returns the current npm package of the sdk
  90360. */
  90361. static readonly NpmPackage: string;
  90362. /**
  90363. * Returns the current version of the framework
  90364. */
  90365. static readonly Version: string;
  90366. /**
  90367. * Returns a string describing the current engine
  90368. */
  90369. readonly description: string;
  90370. /**
  90371. * Gets or sets the epsilon value used by collision engine
  90372. */
  90373. static CollisionsEpsilon: number;
  90374. /**
  90375. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90376. */
  90377. static ShadersRepository: string;
  90378. /**
  90379. * Method called to create the default loading screen.
  90380. * This can be overriden in your own app.
  90381. * @param canvas The rendering canvas element
  90382. * @returns The loading screen
  90383. */
  90384. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90385. /**
  90386. * Method called to create the default rescale post process on each engine.
  90387. */
  90388. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90389. /** @hidden */
  90390. _shaderProcessor: IShaderProcessor;
  90391. /**
  90392. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90393. */
  90394. forcePOTTextures: boolean;
  90395. /**
  90396. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90397. */
  90398. isFullscreen: boolean;
  90399. /**
  90400. * Gets a boolean indicating if the pointer is currently locked
  90401. */
  90402. isPointerLock: boolean;
  90403. /**
  90404. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90405. */
  90406. cullBackFaces: boolean;
  90407. /**
  90408. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90409. */
  90410. renderEvenInBackground: boolean;
  90411. /**
  90412. * Gets or sets a boolean indicating that cache can be kept between frames
  90413. */
  90414. preventCacheWipeBetweenFrames: boolean;
  90415. /**
  90416. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90417. **/
  90418. enableOfflineSupport: boolean;
  90419. /**
  90420. * 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)
  90421. **/
  90422. disableManifestCheck: boolean;
  90423. /**
  90424. * Gets the list of created scenes
  90425. */
  90426. scenes: Scene[];
  90427. /**
  90428. * Event raised when a new scene is created
  90429. */
  90430. onNewSceneAddedObservable: Observable<Scene>;
  90431. /**
  90432. * Gets the list of created postprocesses
  90433. */
  90434. postProcesses: PostProcess[];
  90435. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90436. validateShaderPrograms: boolean;
  90437. /**
  90438. * Observable event triggered each time the rendering canvas is resized
  90439. */
  90440. onResizeObservable: Observable<Engine>;
  90441. /**
  90442. * Observable event triggered each time the canvas loses focus
  90443. */
  90444. onCanvasBlurObservable: Observable<Engine>;
  90445. /**
  90446. * Observable event triggered each time the canvas gains focus
  90447. */
  90448. onCanvasFocusObservable: Observable<Engine>;
  90449. /**
  90450. * Observable event triggered each time the canvas receives pointerout event
  90451. */
  90452. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90453. /**
  90454. * Observable event triggered before each texture is initialized
  90455. */
  90456. onBeforeTextureInitObservable: Observable<Texture>;
  90457. /**
  90458. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90459. */
  90460. disableUniformBuffers: boolean;
  90461. /** @hidden */
  90462. _uniformBuffers: UniformBuffer[];
  90463. /**
  90464. * Gets a boolean indicating that the engine supports uniform buffers
  90465. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90466. */
  90467. readonly supportsUniformBuffers: boolean;
  90468. /**
  90469. * Observable raised when the engine begins a new frame
  90470. */
  90471. onBeginFrameObservable: Observable<Engine>;
  90472. /**
  90473. * If set, will be used to request the next animation frame for the render loop
  90474. */
  90475. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90476. /**
  90477. * Observable raised when the engine ends the current frame
  90478. */
  90479. onEndFrameObservable: Observable<Engine>;
  90480. /**
  90481. * Observable raised when the engine is about to compile a shader
  90482. */
  90483. onBeforeShaderCompilationObservable: Observable<Engine>;
  90484. /**
  90485. * Observable raised when the engine has jsut compiled a shader
  90486. */
  90487. onAfterShaderCompilationObservable: Observable<Engine>;
  90488. /** @hidden */
  90489. _gl: WebGLRenderingContext;
  90490. private _renderingCanvas;
  90491. private _windowIsBackground;
  90492. private _webGLVersion;
  90493. protected _highPrecisionShadersAllowed: boolean;
  90494. /** @hidden */
  90495. readonly _shouldUseHighPrecisionShader: boolean;
  90496. /**
  90497. * Gets a boolean indicating that only power of 2 textures are supported
  90498. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90499. */
  90500. readonly needPOTTextures: boolean;
  90501. /** @hidden */
  90502. _badOS: boolean;
  90503. /** @hidden */
  90504. _badDesktopOS: boolean;
  90505. /**
  90506. * Gets the audio engine
  90507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90508. * @ignorenaming
  90509. */
  90510. static audioEngine: IAudioEngine;
  90511. /**
  90512. * Default AudioEngine factory responsible of creating the Audio Engine.
  90513. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90514. */
  90515. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90516. /**
  90517. * Default offline support factory responsible of creating a tool used to store data locally.
  90518. * By default, this will create a Database object if the workload has been embedded.
  90519. */
  90520. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90521. private _onFocus;
  90522. private _onBlur;
  90523. private _onCanvasPointerOut;
  90524. private _onCanvasBlur;
  90525. private _onCanvasFocus;
  90526. private _onFullscreenChange;
  90527. private _onPointerLockChange;
  90528. private _hardwareScalingLevel;
  90529. /** @hidden */
  90530. _caps: EngineCapabilities;
  90531. private _pointerLockRequested;
  90532. private _isStencilEnable;
  90533. private _colorWrite;
  90534. private _loadingScreen;
  90535. /** @hidden */
  90536. _drawCalls: PerfCounter;
  90537. private _glVersion;
  90538. private _glRenderer;
  90539. private _glVendor;
  90540. private _videoTextureSupported;
  90541. private _renderingQueueLaunched;
  90542. private _activeRenderLoops;
  90543. private _deterministicLockstep;
  90544. private _lockstepMaxSteps;
  90545. /**
  90546. * Observable signaled when a context lost event is raised
  90547. */
  90548. onContextLostObservable: Observable<Engine>;
  90549. /**
  90550. * Observable signaled when a context restored event is raised
  90551. */
  90552. onContextRestoredObservable: Observable<Engine>;
  90553. private _onContextLost;
  90554. private _onContextRestored;
  90555. private _contextWasLost;
  90556. /** @hidden */
  90557. _doNotHandleContextLost: boolean;
  90558. /**
  90559. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90561. */
  90562. doNotHandleContextLost: boolean;
  90563. private _performanceMonitor;
  90564. private _fps;
  90565. private _deltaTime;
  90566. /**
  90567. * Turn this value on if you want to pause FPS computation when in background
  90568. */
  90569. disablePerformanceMonitorInBackground: boolean;
  90570. /**
  90571. * Gets the performance monitor attached to this engine
  90572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90573. */
  90574. readonly performanceMonitor: PerformanceMonitor;
  90575. /**
  90576. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90577. */
  90578. disableVertexArrayObjects: boolean;
  90579. /** @hidden */
  90580. protected _depthCullingState: _DepthCullingState;
  90581. /** @hidden */
  90582. protected _stencilState: _StencilState;
  90583. /** @hidden */
  90584. protected _alphaState: _AlphaState;
  90585. /** @hidden */
  90586. protected _alphaMode: number;
  90587. /** @hidden */
  90588. _internalTexturesCache: InternalTexture[];
  90589. /** @hidden */
  90590. protected _activeChannel: number;
  90591. private _currentTextureChannel;
  90592. /** @hidden */
  90593. protected _boundTexturesCache: {
  90594. [key: string]: Nullable<InternalTexture>;
  90595. };
  90596. /** @hidden */
  90597. protected _currentEffect: Nullable<Effect>;
  90598. /** @hidden */
  90599. protected _currentProgram: Nullable<WebGLProgram>;
  90600. private _compiledEffects;
  90601. private _vertexAttribArraysEnabled;
  90602. /** @hidden */
  90603. protected _cachedViewport: Nullable<Viewport>;
  90604. private _cachedVertexArrayObject;
  90605. /** @hidden */
  90606. protected _cachedVertexBuffers: any;
  90607. /** @hidden */
  90608. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90609. /** @hidden */
  90610. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90611. /** @hidden */
  90612. _currentRenderTarget: Nullable<InternalTexture>;
  90613. private _uintIndicesCurrentlySet;
  90614. private _currentBoundBuffer;
  90615. /** @hidden */
  90616. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90617. private _currentBufferPointers;
  90618. private _currentInstanceLocations;
  90619. private _currentInstanceBuffers;
  90620. private _textureUnits;
  90621. /** @hidden */
  90622. _workingCanvas: Nullable<HTMLCanvasElement>;
  90623. /** @hidden */
  90624. _workingContext: Nullable<CanvasRenderingContext2D>;
  90625. private _rescalePostProcess;
  90626. private _dummyFramebuffer;
  90627. private _externalData;
  90628. /** @hidden */
  90629. _bindedRenderFunction: any;
  90630. private _vaoRecordInProgress;
  90631. private _mustWipeVertexAttributes;
  90632. private _emptyTexture;
  90633. private _emptyCubeTexture;
  90634. private _emptyTexture3D;
  90635. /** @hidden */
  90636. _frameHandler: number;
  90637. private _nextFreeTextureSlots;
  90638. private _maxSimultaneousTextures;
  90639. private _activeRequests;
  90640. private _texturesSupported;
  90641. /** @hidden */
  90642. _textureFormatInUse: Nullable<string>;
  90643. /**
  90644. * Gets the list of texture formats supported
  90645. */
  90646. readonly texturesSupported: Array<string>;
  90647. /**
  90648. * Gets the list of texture formats in use
  90649. */
  90650. readonly textureFormatInUse: Nullable<string>;
  90651. /**
  90652. * Gets the current viewport
  90653. */
  90654. readonly currentViewport: Nullable<Viewport>;
  90655. /**
  90656. * Gets the default empty texture
  90657. */
  90658. readonly emptyTexture: InternalTexture;
  90659. /**
  90660. * Gets the default empty 3D texture
  90661. */
  90662. readonly emptyTexture3D: InternalTexture;
  90663. /**
  90664. * Gets the default empty cube texture
  90665. */
  90666. readonly emptyCubeTexture: InternalTexture;
  90667. /**
  90668. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90669. */
  90670. readonly premultipliedAlpha: boolean;
  90671. /**
  90672. * Creates a new engine
  90673. * @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
  90674. * @param antialias defines enable antialiasing (default: false)
  90675. * @param options defines further options to be sent to the getContext() function
  90676. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90677. */
  90678. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90679. /**
  90680. * Initializes a webVR display and starts listening to display change events
  90681. * The onVRDisplayChangedObservable will be notified upon these changes
  90682. * @returns The onVRDisplayChangedObservable
  90683. */
  90684. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90685. /** @hidden */
  90686. _prepareVRComponent(): void;
  90687. /** @hidden */
  90688. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90689. /** @hidden */
  90690. _submitVRFrame(): void;
  90691. /**
  90692. * Call this function to leave webVR mode
  90693. * Will do nothing if webVR is not supported or if there is no webVR device
  90694. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90695. */
  90696. disableVR(): void;
  90697. /**
  90698. * Gets a boolean indicating that the system is in VR mode and is presenting
  90699. * @returns true if VR mode is engaged
  90700. */
  90701. isVRPresenting(): boolean;
  90702. /** @hidden */
  90703. _requestVRFrame(): void;
  90704. private _disableTouchAction;
  90705. private _rebuildInternalTextures;
  90706. private _rebuildEffects;
  90707. /**
  90708. * Gets a boolean indicating if all created effects are ready
  90709. * @returns true if all effects are ready
  90710. */
  90711. areAllEffectsReady(): boolean;
  90712. private _rebuildBuffers;
  90713. private _initGLContext;
  90714. /**
  90715. * Gets version of the current webGL context
  90716. */
  90717. readonly webGLVersion: number;
  90718. /**
  90719. * Gets a string idenfifying the name of the class
  90720. * @returns "Engine" string
  90721. */
  90722. getClassName(): string;
  90723. /**
  90724. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90725. */
  90726. readonly isStencilEnable: boolean;
  90727. /** @hidden */
  90728. _prepareWorkingCanvas(): void;
  90729. /**
  90730. * Reset the texture cache to empty state
  90731. */
  90732. resetTextureCache(): void;
  90733. /**
  90734. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90736. * @returns true if engine is in deterministic lock step mode
  90737. */
  90738. isDeterministicLockStep(): boolean;
  90739. /**
  90740. * Gets the max steps when engine is running in deterministic lock step
  90741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90742. * @returns the max steps
  90743. */
  90744. getLockstepMaxSteps(): number;
  90745. /**
  90746. * Gets an object containing information about the current webGL context
  90747. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90748. */
  90749. getGlInfo(): {
  90750. vendor: string;
  90751. renderer: string;
  90752. version: string;
  90753. };
  90754. /**
  90755. * Gets current aspect ratio
  90756. * @param camera defines the camera to use to get the aspect ratio
  90757. * @param useScreen defines if screen size must be used (or the current render target if any)
  90758. * @returns a number defining the aspect ratio
  90759. */
  90760. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90761. /**
  90762. * Gets current screen aspect ratio
  90763. * @returns a number defining the aspect ratio
  90764. */
  90765. getScreenAspectRatio(): number;
  90766. /**
  90767. * Gets the current render width
  90768. * @param useScreen defines if screen size must be used (or the current render target if any)
  90769. * @returns a number defining the current render width
  90770. */
  90771. getRenderWidth(useScreen?: boolean): number;
  90772. /**
  90773. * Gets the current render height
  90774. * @param useScreen defines if screen size must be used (or the current render target if any)
  90775. * @returns a number defining the current render height
  90776. */
  90777. getRenderHeight(useScreen?: boolean): number;
  90778. /**
  90779. * Gets the HTML canvas attached with the current webGL context
  90780. * @returns a HTML canvas
  90781. */
  90782. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90783. /**
  90784. * Gets the client rect of the HTML canvas attached with the current webGL context
  90785. * @returns a client rectanglee
  90786. */
  90787. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90788. /**
  90789. * Defines the hardware scaling level.
  90790. * By default the hardware scaling level is computed from the window device ratio.
  90791. * 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.
  90792. * @param level defines the level to use
  90793. */
  90794. setHardwareScalingLevel(level: number): void;
  90795. /**
  90796. * Gets the current hardware scaling level.
  90797. * By default the hardware scaling level is computed from the window device ratio.
  90798. * 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.
  90799. * @returns a number indicating the current hardware scaling level
  90800. */
  90801. getHardwareScalingLevel(): number;
  90802. /**
  90803. * Gets the list of loaded textures
  90804. * @returns an array containing all loaded textures
  90805. */
  90806. getLoadedTexturesCache(): InternalTexture[];
  90807. /**
  90808. * Gets the object containing all engine capabilities
  90809. * @returns the EngineCapabilities object
  90810. */
  90811. getCaps(): EngineCapabilities;
  90812. /**
  90813. * Gets the current depth function
  90814. * @returns a number defining the depth function
  90815. */
  90816. getDepthFunction(): Nullable<number>;
  90817. /**
  90818. * Sets the current depth function
  90819. * @param depthFunc defines the function to use
  90820. */
  90821. setDepthFunction(depthFunc: number): void;
  90822. /**
  90823. * Sets the current depth function to GREATER
  90824. */
  90825. setDepthFunctionToGreater(): void;
  90826. /**
  90827. * Sets the current depth function to GEQUAL
  90828. */
  90829. setDepthFunctionToGreaterOrEqual(): void;
  90830. /**
  90831. * Sets the current depth function to LESS
  90832. */
  90833. setDepthFunctionToLess(): void;
  90834. private _cachedStencilBuffer;
  90835. private _cachedStencilFunction;
  90836. private _cachedStencilMask;
  90837. private _cachedStencilOperationPass;
  90838. private _cachedStencilOperationFail;
  90839. private _cachedStencilOperationDepthFail;
  90840. private _cachedStencilReference;
  90841. /**
  90842. * Caches the the state of the stencil buffer
  90843. */
  90844. cacheStencilState(): void;
  90845. /**
  90846. * Restores the state of the stencil buffer
  90847. */
  90848. restoreStencilState(): void;
  90849. /**
  90850. * Sets the current depth function to LEQUAL
  90851. */
  90852. setDepthFunctionToLessOrEqual(): void;
  90853. /**
  90854. * Gets a boolean indicating if stencil buffer is enabled
  90855. * @returns the current stencil buffer state
  90856. */
  90857. getStencilBuffer(): boolean;
  90858. /**
  90859. * Enable or disable the stencil buffer
  90860. * @param enable defines if the stencil buffer must be enabled or disabled
  90861. */
  90862. setStencilBuffer(enable: boolean): void;
  90863. /**
  90864. * Gets the current stencil mask
  90865. * @returns a number defining the new stencil mask to use
  90866. */
  90867. getStencilMask(): number;
  90868. /**
  90869. * Sets the current stencil mask
  90870. * @param mask defines the new stencil mask to use
  90871. */
  90872. setStencilMask(mask: number): void;
  90873. /**
  90874. * Gets the current stencil function
  90875. * @returns a number defining the stencil function to use
  90876. */
  90877. getStencilFunction(): number;
  90878. /**
  90879. * Gets the current stencil reference value
  90880. * @returns a number defining the stencil reference value to use
  90881. */
  90882. getStencilFunctionReference(): number;
  90883. /**
  90884. * Gets the current stencil mask
  90885. * @returns a number defining the stencil mask to use
  90886. */
  90887. getStencilFunctionMask(): number;
  90888. /**
  90889. * Sets the current stencil function
  90890. * @param stencilFunc defines the new stencil function to use
  90891. */
  90892. setStencilFunction(stencilFunc: number): void;
  90893. /**
  90894. * Sets the current stencil reference
  90895. * @param reference defines the new stencil reference to use
  90896. */
  90897. setStencilFunctionReference(reference: number): void;
  90898. /**
  90899. * Sets the current stencil mask
  90900. * @param mask defines the new stencil mask to use
  90901. */
  90902. setStencilFunctionMask(mask: number): void;
  90903. /**
  90904. * Gets the current stencil operation when stencil fails
  90905. * @returns a number defining stencil operation to use when stencil fails
  90906. */
  90907. getStencilOperationFail(): number;
  90908. /**
  90909. * Gets the current stencil operation when depth fails
  90910. * @returns a number defining stencil operation to use when depth fails
  90911. */
  90912. getStencilOperationDepthFail(): number;
  90913. /**
  90914. * Gets the current stencil operation when stencil passes
  90915. * @returns a number defining stencil operation to use when stencil passes
  90916. */
  90917. getStencilOperationPass(): number;
  90918. /**
  90919. * Sets the stencil operation to use when stencil fails
  90920. * @param operation defines the stencil operation to use when stencil fails
  90921. */
  90922. setStencilOperationFail(operation: number): void;
  90923. /**
  90924. * Sets the stencil operation to use when depth fails
  90925. * @param operation defines the stencil operation to use when depth fails
  90926. */
  90927. setStencilOperationDepthFail(operation: number): void;
  90928. /**
  90929. * Sets the stencil operation to use when stencil passes
  90930. * @param operation defines the stencil operation to use when stencil passes
  90931. */
  90932. setStencilOperationPass(operation: number): void;
  90933. /**
  90934. * Sets a boolean indicating if the dithering state is enabled or disabled
  90935. * @param value defines the dithering state
  90936. */
  90937. setDitheringState(value: boolean): void;
  90938. /**
  90939. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90940. * @param value defines the rasterizer state
  90941. */
  90942. setRasterizerState(value: boolean): void;
  90943. /**
  90944. * stop executing a render loop function and remove it from the execution array
  90945. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90946. */
  90947. stopRenderLoop(renderFunction?: () => void): void;
  90948. /** @hidden */
  90949. _renderLoop(): void;
  90950. /**
  90951. * Register and execute a render loop. The engine can have more than one render function
  90952. * @param renderFunction defines the function to continuously execute
  90953. */
  90954. runRenderLoop(renderFunction: () => void): void;
  90955. /**
  90956. * Toggle full screen mode
  90957. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90958. */
  90959. switchFullscreen(requestPointerLock: boolean): void;
  90960. /**
  90961. * Enters full screen mode
  90962. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90963. */
  90964. enterFullscreen(requestPointerLock: boolean): void;
  90965. /**
  90966. * Exits full screen mode
  90967. */
  90968. exitFullscreen(): void;
  90969. /**
  90970. * Enters Pointerlock mode
  90971. */
  90972. enterPointerlock(): void;
  90973. /**
  90974. * Exits Pointerlock mode
  90975. */
  90976. exitPointerlock(): void;
  90977. /**
  90978. * Clear the current render buffer or the current render target (if any is set up)
  90979. * @param color defines the color to use
  90980. * @param backBuffer defines if the back buffer must be cleared
  90981. * @param depth defines if the depth buffer must be cleared
  90982. * @param stencil defines if the stencil buffer must be cleared
  90983. */
  90984. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90985. /**
  90986. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90987. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90988. * @param y defines the y-coordinate of the corner of the clear rectangle
  90989. * @param width defines the width of the clear rectangle
  90990. * @param height defines the height of the clear rectangle
  90991. * @param clearColor defines the clear color
  90992. */
  90993. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90994. /**
  90995. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90996. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90997. * @param y defines the y-coordinate of the corner of the clear rectangle
  90998. * @param width defines the width of the clear rectangle
  90999. * @param height defines the height of the clear rectangle
  91000. */
  91001. enableScissor(x: number, y: number, width: number, height: number): void;
  91002. /**
  91003. * Disable previously set scissor test rectangle
  91004. */
  91005. disableScissor(): void;
  91006. private _viewportCached;
  91007. /** @hidden */
  91008. _viewport(x: number, y: number, width: number, height: number): void;
  91009. /**
  91010. * Set the WebGL's viewport
  91011. * @param viewport defines the viewport element to be used
  91012. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  91013. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  91014. */
  91015. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  91016. /**
  91017. * Directly set the WebGL Viewport
  91018. * @param x defines the x coordinate of the viewport (in screen space)
  91019. * @param y defines the y coordinate of the viewport (in screen space)
  91020. * @param width defines the width of the viewport (in screen space)
  91021. * @param height defines the height of the viewport (in screen space)
  91022. * @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
  91023. */
  91024. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  91025. /**
  91026. * Begin a new frame
  91027. */
  91028. beginFrame(): void;
  91029. /**
  91030. * Enf the current frame
  91031. */
  91032. endFrame(): void;
  91033. /**
  91034. * Resize the view according to the canvas' size
  91035. */
  91036. resize(): void;
  91037. /**
  91038. * Force a specific size of the canvas
  91039. * @param width defines the new canvas' width
  91040. * @param height defines the new canvas' height
  91041. */
  91042. setSize(width: number, height: number): void;
  91043. /**
  91044. * Binds the frame buffer to the specified texture.
  91045. * @param texture The texture to render to or null for the default canvas
  91046. * @param faceIndex The face of the texture to render to in case of cube texture
  91047. * @param requiredWidth The width of the target to render to
  91048. * @param requiredHeight The height of the target to render to
  91049. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91050. * @param depthStencilTexture The depth stencil texture to use to render
  91051. * @param lodLevel defines le lod level to bind to the frame buffer
  91052. */
  91053. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91054. /** @hidden */
  91055. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91056. /**
  91057. * Unbind the current render target texture from the webGL context
  91058. * @param texture defines the render target texture to unbind
  91059. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91060. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91061. */
  91062. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91063. /**
  91064. * Force the mipmap generation for the given render target texture
  91065. * @param texture defines the render target texture to use
  91066. */
  91067. generateMipMapsForCubemap(texture: InternalTexture): void;
  91068. /**
  91069. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91070. */
  91071. flushFramebuffer(): void;
  91072. /**
  91073. * Unbind the current render target and bind the default framebuffer
  91074. */
  91075. restoreDefaultFramebuffer(): void;
  91076. /**
  91077. * Create an uniform buffer
  91078. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91079. * @param elements defines the content of the uniform buffer
  91080. * @returns the webGL uniform buffer
  91081. */
  91082. createUniformBuffer(elements: FloatArray): DataBuffer;
  91083. /**
  91084. * Create a dynamic uniform buffer
  91085. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91086. * @param elements defines the content of the uniform buffer
  91087. * @returns the webGL uniform buffer
  91088. */
  91089. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91090. /**
  91091. * Update an existing uniform buffer
  91092. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91093. * @param uniformBuffer defines the target uniform buffer
  91094. * @param elements defines the content to update
  91095. * @param offset defines the offset in the uniform buffer where update should start
  91096. * @param count defines the size of the data to update
  91097. */
  91098. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91099. private _resetVertexBufferBinding;
  91100. /**
  91101. * Creates a vertex buffer
  91102. * @param data the data for the vertex buffer
  91103. * @returns the new WebGL static buffer
  91104. */
  91105. createVertexBuffer(data: DataArray): DataBuffer;
  91106. /**
  91107. * Creates a dynamic vertex buffer
  91108. * @param data the data for the dynamic vertex buffer
  91109. * @returns the new WebGL dynamic buffer
  91110. */
  91111. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91112. /**
  91113. * Update a dynamic index buffer
  91114. * @param indexBuffer defines the target index buffer
  91115. * @param indices defines the data to update
  91116. * @param offset defines the offset in the target index buffer where update should start
  91117. */
  91118. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91119. /**
  91120. * Updates a dynamic vertex buffer.
  91121. * @param vertexBuffer the vertex buffer to update
  91122. * @param data the data used to update the vertex buffer
  91123. * @param byteOffset the byte offset of the data
  91124. * @param byteLength the byte length of the data
  91125. */
  91126. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91127. private _resetIndexBufferBinding;
  91128. /**
  91129. * Creates a new index buffer
  91130. * @param indices defines the content of the index buffer
  91131. * @param updatable defines if the index buffer must be updatable
  91132. * @returns a new webGL buffer
  91133. */
  91134. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91135. /**
  91136. * Bind a webGL buffer to the webGL context
  91137. * @param buffer defines the buffer to bind
  91138. */
  91139. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91140. /**
  91141. * Bind an uniform buffer to the current webGL context
  91142. * @param buffer defines the buffer to bind
  91143. */
  91144. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91145. /**
  91146. * Bind a buffer to the current webGL context at a given location
  91147. * @param buffer defines the buffer to bind
  91148. * @param location defines the index where to bind the buffer
  91149. */
  91150. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91151. /**
  91152. * Bind a specific block at a given index in a specific shader program
  91153. * @param pipelineContext defines the pipeline context to use
  91154. * @param blockName defines the block name
  91155. * @param index defines the index where to bind the block
  91156. */
  91157. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91158. private bindIndexBuffer;
  91159. private bindBuffer;
  91160. /**
  91161. * update the bound buffer with the given data
  91162. * @param data defines the data to update
  91163. */
  91164. updateArrayBuffer(data: Float32Array): void;
  91165. private _vertexAttribPointer;
  91166. private _bindIndexBufferWithCache;
  91167. private _bindVertexBuffersAttributes;
  91168. /**
  91169. * Records a vertex array object
  91170. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91171. * @param vertexBuffers defines the list of vertex buffers to store
  91172. * @param indexBuffer defines the index buffer to store
  91173. * @param effect defines the effect to store
  91174. * @returns the new vertex array object
  91175. */
  91176. recordVertexArrayObject(vertexBuffers: {
  91177. [key: string]: VertexBuffer;
  91178. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91179. /**
  91180. * Bind a specific vertex array object
  91181. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91182. * @param vertexArrayObject defines the vertex array object to bind
  91183. * @param indexBuffer defines the index buffer to bind
  91184. */
  91185. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91186. /**
  91187. * Bind webGl buffers directly to the webGL context
  91188. * @param vertexBuffer defines the vertex buffer to bind
  91189. * @param indexBuffer defines the index buffer to bind
  91190. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91191. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91192. * @param effect defines the effect associated with the vertex buffer
  91193. */
  91194. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91195. private _unbindVertexArrayObject;
  91196. /**
  91197. * Bind a list of vertex buffers to the webGL context
  91198. * @param vertexBuffers defines the list of vertex buffers to bind
  91199. * @param indexBuffer defines the index buffer to bind
  91200. * @param effect defines the effect associated with the vertex buffers
  91201. */
  91202. bindBuffers(vertexBuffers: {
  91203. [key: string]: Nullable<VertexBuffer>;
  91204. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91205. /**
  91206. * Unbind all instance attributes
  91207. */
  91208. unbindInstanceAttributes(): void;
  91209. /**
  91210. * Release and free the memory of a vertex array object
  91211. * @param vao defines the vertex array object to delete
  91212. */
  91213. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91214. /** @hidden */
  91215. _releaseBuffer(buffer: DataBuffer): boolean;
  91216. /**
  91217. * Creates a webGL buffer to use with instanciation
  91218. * @param capacity defines the size of the buffer
  91219. * @returns the webGL buffer
  91220. */
  91221. createInstancesBuffer(capacity: number): DataBuffer;
  91222. /**
  91223. * Delete a webGL buffer used with instanciation
  91224. * @param buffer defines the webGL buffer to delete
  91225. */
  91226. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91227. /**
  91228. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91229. * @param instancesBuffer defines the webGL buffer to update and bind
  91230. * @param data defines the data to store in the buffer
  91231. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91232. */
  91233. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91234. /**
  91235. * Apply all cached states (depth, culling, stencil and alpha)
  91236. */
  91237. applyStates(): void;
  91238. /**
  91239. * Send a draw order
  91240. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91241. * @param indexStart defines the starting index
  91242. * @param indexCount defines the number of index to draw
  91243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91244. */
  91245. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91246. /**
  91247. * Draw a list of points
  91248. * @param verticesStart defines the index of first vertex to draw
  91249. * @param verticesCount defines the count of vertices to draw
  91250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91251. */
  91252. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91253. /**
  91254. * Draw a list of unindexed primitives
  91255. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91256. * @param verticesStart defines the index of first vertex to draw
  91257. * @param verticesCount defines the count of vertices to draw
  91258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91259. */
  91260. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91261. /**
  91262. * Draw a list of indexed primitives
  91263. * @param fillMode defines the primitive to use
  91264. * @param indexStart defines the starting index
  91265. * @param indexCount defines the number of index to draw
  91266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91267. */
  91268. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91269. /**
  91270. * Draw a list of unindexed primitives
  91271. * @param fillMode defines the primitive to use
  91272. * @param verticesStart defines the index of first vertex to draw
  91273. * @param verticesCount defines the count of vertices to draw
  91274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91275. */
  91276. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91277. private _drawMode;
  91278. /** @hidden */
  91279. _releaseEffect(effect: Effect): void;
  91280. /** @hidden */
  91281. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91282. /**
  91283. * Create a new effect (used to store vertex/fragment shaders)
  91284. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91285. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91286. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91287. * @param samplers defines an array of string used to represent textures
  91288. * @param defines defines the string containing the defines to use to compile the shaders
  91289. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91290. * @param onCompiled defines a function to call when the effect creation is successful
  91291. * @param onError defines a function to call when the effect creation has failed
  91292. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91293. * @returns the new Effect
  91294. */
  91295. 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;
  91296. private _compileShader;
  91297. private _compileRawShader;
  91298. /**
  91299. * Directly creates a webGL program
  91300. * @param pipelineContext defines the pipeline context to attach to
  91301. * @param vertexCode defines the vertex shader code to use
  91302. * @param fragmentCode defines the fragment shader code to use
  91303. * @param context defines the webGL context to use (if not set, the current one will be used)
  91304. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91305. * @returns the new webGL program
  91306. */
  91307. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91308. /**
  91309. * Creates a webGL program
  91310. * @param pipelineContext defines the pipeline context to attach to
  91311. * @param vertexCode defines the vertex shader code to use
  91312. * @param fragmentCode defines the fragment shader code to use
  91313. * @param defines defines the string containing the defines to use to compile the shaders
  91314. * @param context defines the webGL context to use (if not set, the current one will be used)
  91315. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91316. * @returns the new webGL program
  91317. */
  91318. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91319. /**
  91320. * Creates a new pipeline context
  91321. * @returns the new pipeline
  91322. */
  91323. createPipelineContext(): WebGLPipelineContext;
  91324. private _createShaderProgram;
  91325. private _finalizePipelineContext;
  91326. /** @hidden */
  91327. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91328. /** @hidden */
  91329. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91330. /** @hidden */
  91331. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91332. /**
  91333. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91334. * @param pipelineContext defines the pipeline context to use
  91335. * @param uniformsNames defines the list of uniform names
  91336. * @returns an array of webGL uniform locations
  91337. */
  91338. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91339. /**
  91340. * Gets the lsit of active attributes for a given webGL program
  91341. * @param pipelineContext defines the pipeline context to use
  91342. * @param attributesNames defines the list of attribute names to get
  91343. * @returns an array of indices indicating the offset of each attribute
  91344. */
  91345. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91346. /**
  91347. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91348. * @param effect defines the effect to activate
  91349. */
  91350. enableEffect(effect: Nullable<Effect>): void;
  91351. /**
  91352. * Set the value of an uniform to an array of int32
  91353. * @param uniform defines the webGL uniform location where to store the value
  91354. * @param array defines the array of int32 to store
  91355. */
  91356. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91357. /**
  91358. * Set the value of an uniform to an array of int32 (stored as vec2)
  91359. * @param uniform defines the webGL uniform location where to store the value
  91360. * @param array defines the array of int32 to store
  91361. */
  91362. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91363. /**
  91364. * Set the value of an uniform to an array of int32 (stored as vec3)
  91365. * @param uniform defines the webGL uniform location where to store the value
  91366. * @param array defines the array of int32 to store
  91367. */
  91368. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91369. /**
  91370. * Set the value of an uniform to an array of int32 (stored as vec4)
  91371. * @param uniform defines the webGL uniform location where to store the value
  91372. * @param array defines the array of int32 to store
  91373. */
  91374. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91375. /**
  91376. * Set the value of an uniform to an array of float32
  91377. * @param uniform defines the webGL uniform location where to store the value
  91378. * @param array defines the array of float32 to store
  91379. */
  91380. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91381. /**
  91382. * Set the value of an uniform to an array of float32 (stored as vec2)
  91383. * @param uniform defines the webGL uniform location where to store the value
  91384. * @param array defines the array of float32 to store
  91385. */
  91386. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91387. /**
  91388. * Set the value of an uniform to an array of float32 (stored as vec3)
  91389. * @param uniform defines the webGL uniform location where to store the value
  91390. * @param array defines the array of float32 to store
  91391. */
  91392. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91393. /**
  91394. * Set the value of an uniform to an array of float32 (stored as vec4)
  91395. * @param uniform defines the webGL uniform location where to store the value
  91396. * @param array defines the array of float32 to store
  91397. */
  91398. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91399. /**
  91400. * Set the value of an uniform to an array of number
  91401. * @param uniform defines the webGL uniform location where to store the value
  91402. * @param array defines the array of number to store
  91403. */
  91404. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91405. /**
  91406. * Set the value of an uniform to an array of number (stored as vec2)
  91407. * @param uniform defines the webGL uniform location where to store the value
  91408. * @param array defines the array of number to store
  91409. */
  91410. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91411. /**
  91412. * Set the value of an uniform to an array of number (stored as vec3)
  91413. * @param uniform defines the webGL uniform location where to store the value
  91414. * @param array defines the array of number to store
  91415. */
  91416. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91417. /**
  91418. * Set the value of an uniform to an array of number (stored as vec4)
  91419. * @param uniform defines the webGL uniform location where to store the value
  91420. * @param array defines the array of number to store
  91421. */
  91422. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91423. /**
  91424. * Set the value of an uniform to an array of float32 (stored as matrices)
  91425. * @param uniform defines the webGL uniform location where to store the value
  91426. * @param matrices defines the array of float32 to store
  91427. */
  91428. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91429. /**
  91430. * Set the value of an uniform to a matrix
  91431. * @param uniform defines the webGL uniform location where to store the value
  91432. * @param matrix defines the matrix to store
  91433. */
  91434. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91435. /**
  91436. * Set the value of an uniform to a matrix (3x3)
  91437. * @param uniform defines the webGL uniform location where to store the value
  91438. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91439. */
  91440. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91441. /**
  91442. * Set the value of an uniform to a matrix (2x2)
  91443. * @param uniform defines the webGL uniform location where to store the value
  91444. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91445. */
  91446. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91447. /**
  91448. * Set the value of an uniform to a number (int)
  91449. * @param uniform defines the webGL uniform location where to store the value
  91450. * @param value defines the int number to store
  91451. */
  91452. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91453. /**
  91454. * Set the value of an uniform to a number (float)
  91455. * @param uniform defines the webGL uniform location where to store the value
  91456. * @param value defines the float number to store
  91457. */
  91458. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91459. /**
  91460. * Set the value of an uniform to a vec2
  91461. * @param uniform defines the webGL uniform location where to store the value
  91462. * @param x defines the 1st component of the value
  91463. * @param y defines the 2nd component of the value
  91464. */
  91465. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91466. /**
  91467. * Set the value of an uniform to a vec3
  91468. * @param uniform defines the webGL uniform location where to store the value
  91469. * @param x defines the 1st component of the value
  91470. * @param y defines the 2nd component of the value
  91471. * @param z defines the 3rd component of the value
  91472. */
  91473. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91474. /**
  91475. * Set the value of an uniform to a boolean
  91476. * @param uniform defines the webGL uniform location where to store the value
  91477. * @param bool defines the boolean to store
  91478. */
  91479. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91480. /**
  91481. * Set the value of an uniform to a vec4
  91482. * @param uniform defines the webGL uniform location where to store the value
  91483. * @param x defines the 1st component of the value
  91484. * @param y defines the 2nd component of the value
  91485. * @param z defines the 3rd component of the value
  91486. * @param w defines the 4th component of the value
  91487. */
  91488. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91489. /**
  91490. * Set the value of an uniform to a Color3
  91491. * @param uniform defines the webGL uniform location where to store the value
  91492. * @param color3 defines the color to store
  91493. */
  91494. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91495. /**
  91496. * Set the value of an uniform to a Color3 and an alpha value
  91497. * @param uniform defines the webGL uniform location where to store the value
  91498. * @param color3 defines the color to store
  91499. * @param alpha defines the alpha component to store
  91500. */
  91501. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91502. /**
  91503. * Sets a Color4 on a uniform variable
  91504. * @param uniform defines the uniform location
  91505. * @param color4 defines the value to be set
  91506. */
  91507. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91508. /**
  91509. * Set various states to the webGL context
  91510. * @param culling defines backface culling state
  91511. * @param zOffset defines the value to apply to zOffset (0 by default)
  91512. * @param force defines if states must be applied even if cache is up to date
  91513. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91514. */
  91515. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91516. /**
  91517. * Set the z offset to apply to current rendering
  91518. * @param value defines the offset to apply
  91519. */
  91520. setZOffset(value: number): void;
  91521. /**
  91522. * Gets the current value of the zOffset
  91523. * @returns the current zOffset state
  91524. */
  91525. getZOffset(): number;
  91526. /**
  91527. * Enable or disable depth buffering
  91528. * @param enable defines the state to set
  91529. */
  91530. setDepthBuffer(enable: boolean): void;
  91531. /**
  91532. * Gets a boolean indicating if depth writing is enabled
  91533. * @returns the current depth writing state
  91534. */
  91535. getDepthWrite(): boolean;
  91536. /**
  91537. * Enable or disable depth writing
  91538. * @param enable defines the state to set
  91539. */
  91540. setDepthWrite(enable: boolean): void;
  91541. /**
  91542. * Enable or disable color writing
  91543. * @param enable defines the state to set
  91544. */
  91545. setColorWrite(enable: boolean): void;
  91546. /**
  91547. * Gets a boolean indicating if color writing is enabled
  91548. * @returns the current color writing state
  91549. */
  91550. getColorWrite(): boolean;
  91551. /**
  91552. * Sets alpha constants used by some alpha blending modes
  91553. * @param r defines the red component
  91554. * @param g defines the green component
  91555. * @param b defines the blue component
  91556. * @param a defines the alpha component
  91557. */
  91558. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91559. /**
  91560. * Sets the current alpha mode
  91561. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91562. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91563. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91564. */
  91565. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91566. /**
  91567. * Gets the current alpha mode
  91568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91569. * @returns the current alpha mode
  91570. */
  91571. getAlphaMode(): number;
  91572. /**
  91573. * Clears the list of texture accessible through engine.
  91574. * This can help preventing texture load conflict due to name collision.
  91575. */
  91576. clearInternalTexturesCache(): void;
  91577. /**
  91578. * Force the entire cache to be cleared
  91579. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91580. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91581. */
  91582. wipeCaches(bruteForce?: boolean): void;
  91583. /**
  91584. * Set the compressed texture format to use, based on the formats you have, and the formats
  91585. * supported by the hardware / browser.
  91586. *
  91587. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91588. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91589. * to API arguments needed to compressed textures. This puts the burden on the container
  91590. * generator to house the arcane code for determining these for current & future formats.
  91591. *
  91592. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91593. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91594. *
  91595. * Note: The result of this call is not taken into account when a texture is base64.
  91596. *
  91597. * @param formatsAvailable defines the list of those format families you have created
  91598. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91599. *
  91600. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91601. * @returns The extension selected.
  91602. */
  91603. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91604. /** @hidden */
  91605. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91606. min: number;
  91607. mag: number;
  91608. };
  91609. /** @hidden */
  91610. _createTexture(): WebGLTexture;
  91611. /**
  91612. * Usually called from Texture.ts.
  91613. * Passed information to create a WebGLTexture
  91614. * @param urlArg defines a value which contains one of the following:
  91615. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91616. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91617. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91618. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91619. * @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)
  91620. * @param scene needed for loading to the correct scene
  91621. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91622. * @param onLoad optional callback to be called upon successful completion
  91623. * @param onError optional callback to be called upon failure
  91624. * @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
  91625. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91626. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91627. * @param forcedExtension defines the extension to use to pick the right loader
  91628. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91629. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91630. */
  91631. 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;
  91632. /**
  91633. * @hidden
  91634. * Rescales a texture
  91635. * @param source input texutre
  91636. * @param destination destination texture
  91637. * @param scene scene to use to render the resize
  91638. * @param internalFormat format to use when resizing
  91639. * @param onComplete callback to be called when resize has completed
  91640. */
  91641. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91642. private _unpackFlipYCached;
  91643. /**
  91644. * In case you are sharing the context with other applications, it might
  91645. * be interested to not cache the unpack flip y state to ensure a consistent
  91646. * value would be set.
  91647. */
  91648. enableUnpackFlipYCached: boolean;
  91649. /** @hidden */
  91650. _unpackFlipY(value: boolean): void;
  91651. /** @hidden */
  91652. _getUnpackAlignement(): number;
  91653. /**
  91654. * Creates a dynamic texture
  91655. * @param width defines the width of the texture
  91656. * @param height defines the height of the texture
  91657. * @param generateMipMaps defines if the engine should generate the mip levels
  91658. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91659. * @returns the dynamic texture inside an InternalTexture
  91660. */
  91661. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91662. /**
  91663. * Update the sampling mode of a given texture
  91664. * @param samplingMode defines the required sampling mode
  91665. * @param texture defines the texture to update
  91666. */
  91667. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91668. /**
  91669. * Update the content of a dynamic texture
  91670. * @param texture defines the texture to update
  91671. * @param canvas defines the canvas containing the source
  91672. * @param invertY defines if data must be stored with Y axis inverted
  91673. * @param premulAlpha defines if alpha is stored as premultiplied
  91674. * @param format defines the format of the data
  91675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91676. */
  91677. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91678. /**
  91679. * Update a video texture
  91680. * @param texture defines the texture to update
  91681. * @param video defines the video element to use
  91682. * @param invertY defines if data must be stored with Y axis inverted
  91683. */
  91684. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91685. /**
  91686. * Updates a depth texture Comparison Mode and Function.
  91687. * If the comparison Function is equal to 0, the mode will be set to none.
  91688. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91689. * @param texture The texture to set the comparison function for
  91690. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91691. */
  91692. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91693. /** @hidden */
  91694. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91695. width: number;
  91696. height: number;
  91697. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91698. /**
  91699. * Creates a depth stencil texture.
  91700. * This is only available in WebGL 2 or with the depth texture extension available.
  91701. * @param size The size of face edge in the texture.
  91702. * @param options The options defining the texture.
  91703. * @returns The texture
  91704. */
  91705. createDepthStencilTexture(size: number | {
  91706. width: number;
  91707. height: number;
  91708. }, options: DepthTextureCreationOptions): InternalTexture;
  91709. /**
  91710. * Creates a depth stencil texture.
  91711. * This is only available in WebGL 2 or with the depth texture extension available.
  91712. * @param size The size of face edge in the texture.
  91713. * @param options The options defining the texture.
  91714. * @returns The texture
  91715. */
  91716. private _createDepthStencilTexture;
  91717. /**
  91718. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91719. * @param renderTarget The render target to set the frame buffer for
  91720. */
  91721. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91722. /**
  91723. * Creates a new render target texture
  91724. * @param size defines the size of the texture
  91725. * @param options defines the options used to create the texture
  91726. * @returns a new render target texture stored in an InternalTexture
  91727. */
  91728. createRenderTargetTexture(size: number | {
  91729. width: number;
  91730. height: number;
  91731. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91732. /** @hidden */
  91733. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91734. /**
  91735. * Updates the sample count of a render target texture
  91736. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91737. * @param texture defines the texture to update
  91738. * @param samples defines the sample count to set
  91739. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91740. */
  91741. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91742. /** @hidden */
  91743. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91744. /** @hidden */
  91745. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91746. /** @hidden */
  91747. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91748. /** @hidden */
  91749. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91750. /**
  91751. * @hidden
  91752. */
  91753. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91754. private _prepareWebGLTextureContinuation;
  91755. private _prepareWebGLTexture;
  91756. /** @hidden */
  91757. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91758. /** @hidden */
  91759. _releaseFramebufferObjects(texture: InternalTexture): void;
  91760. /** @hidden */
  91761. _releaseTexture(texture: InternalTexture): void;
  91762. private setProgram;
  91763. private _boundUniforms;
  91764. /**
  91765. * Binds an effect to the webGL context
  91766. * @param effect defines the effect to bind
  91767. */
  91768. bindSamplers(effect: Effect): void;
  91769. private _activateCurrentTexture;
  91770. /** @hidden */
  91771. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91772. /** @hidden */
  91773. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91774. /**
  91775. * Sets a texture to the webGL context from a postprocess
  91776. * @param channel defines the channel to use
  91777. * @param postProcess defines the source postprocess
  91778. */
  91779. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91780. /**
  91781. * Binds the output of the passed in post process to the texture channel specified
  91782. * @param channel The channel the texture should be bound to
  91783. * @param postProcess The post process which's output should be bound
  91784. */
  91785. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91786. /**
  91787. * Unbind all textures from the webGL context
  91788. */
  91789. unbindAllTextures(): void;
  91790. /**
  91791. * Sets a texture to the according uniform.
  91792. * @param channel The texture channel
  91793. * @param uniform The uniform to set
  91794. * @param texture The texture to apply
  91795. */
  91796. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91797. /**
  91798. * Sets a depth stencil texture from a render target to the according uniform.
  91799. * @param channel The texture channel
  91800. * @param uniform The uniform to set
  91801. * @param texture The render target texture containing the depth stencil texture to apply
  91802. */
  91803. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91804. private _bindSamplerUniformToChannel;
  91805. private _getTextureWrapMode;
  91806. private _setTexture;
  91807. /**
  91808. * Sets an array of texture to the webGL context
  91809. * @param channel defines the channel where the texture array must be set
  91810. * @param uniform defines the associated uniform location
  91811. * @param textures defines the array of textures to bind
  91812. */
  91813. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91814. /** @hidden */
  91815. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91816. private _setTextureParameterFloat;
  91817. private _setTextureParameterInteger;
  91818. /**
  91819. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91820. * @param x defines the x coordinate of the rectangle where pixels must be read
  91821. * @param y defines the y coordinate of the rectangle where pixels must be read
  91822. * @param width defines the width of the rectangle where pixels must be read
  91823. * @param height defines the height of the rectangle where pixels must be read
  91824. * @returns a Uint8Array containing RGBA colors
  91825. */
  91826. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91827. /**
  91828. * Add an externaly attached data from its key.
  91829. * This method call will fail and return false, if such key already exists.
  91830. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91831. * @param key the unique key that identifies the data
  91832. * @param data the data object to associate to the key for this Engine instance
  91833. * @return true if no such key were already present and the data was added successfully, false otherwise
  91834. */
  91835. addExternalData<T>(key: string, data: T): boolean;
  91836. /**
  91837. * Get an externaly attached data from its key
  91838. * @param key the unique key that identifies the data
  91839. * @return the associated data, if present (can be null), or undefined if not present
  91840. */
  91841. getExternalData<T>(key: string): T;
  91842. /**
  91843. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91844. * @param key the unique key that identifies the data
  91845. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91846. * @return the associated data, can be null if the factory returned null.
  91847. */
  91848. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91849. /**
  91850. * Remove an externaly attached data from the Engine instance
  91851. * @param key the unique key that identifies the data
  91852. * @return true if the data was successfully removed, false if it doesn't exist
  91853. */
  91854. removeExternalData(key: string): boolean;
  91855. /**
  91856. * Unbind all vertex attributes from the webGL context
  91857. */
  91858. unbindAllAttributes(): void;
  91859. /**
  91860. * 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
  91861. */
  91862. releaseEffects(): void;
  91863. /**
  91864. * Dispose and release all associated resources
  91865. */
  91866. dispose(): void;
  91867. /**
  91868. * Display the loading screen
  91869. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91870. */
  91871. displayLoadingUI(): void;
  91872. /**
  91873. * Hide the loading screen
  91874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91875. */
  91876. hideLoadingUI(): void;
  91877. /**
  91878. * Gets the current loading screen object
  91879. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91880. */
  91881. /**
  91882. * Sets the current loading screen object
  91883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91884. */
  91885. loadingScreen: ILoadingScreen;
  91886. /**
  91887. * Sets the current loading screen text
  91888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91889. */
  91890. loadingUIText: string;
  91891. /**
  91892. * Sets the current loading screen background color
  91893. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91894. */
  91895. loadingUIBackgroundColor: string;
  91896. /**
  91897. * Attach a new callback raised when context lost event is fired
  91898. * @param callback defines the callback to call
  91899. */
  91900. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91901. /**
  91902. * Attach a new callback raised when context restored event is fired
  91903. * @param callback defines the callback to call
  91904. */
  91905. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91906. /**
  91907. * Gets the source code of the vertex shader associated with a specific webGL program
  91908. * @param program defines the program to use
  91909. * @returns a string containing the source code of the vertex shader associated with the program
  91910. */
  91911. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91912. /**
  91913. * Gets the source code of the fragment shader associated with a specific webGL program
  91914. * @param program defines the program to use
  91915. * @returns a string containing the source code of the fragment shader associated with the program
  91916. */
  91917. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91918. /**
  91919. * Get the current error code of the webGL context
  91920. * @returns the error code
  91921. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91922. */
  91923. getError(): number;
  91924. /**
  91925. * Gets the current framerate
  91926. * @returns a number representing the framerate
  91927. */
  91928. getFps(): number;
  91929. /**
  91930. * Gets the time spent between current and previous frame
  91931. * @returns a number representing the delta time in ms
  91932. */
  91933. getDeltaTime(): number;
  91934. private _measureFps;
  91935. /** @hidden */
  91936. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91937. private _canRenderToFloatFramebuffer;
  91938. private _canRenderToHalfFloatFramebuffer;
  91939. private _canRenderToFramebuffer;
  91940. /** @hidden */
  91941. _getWebGLTextureType(type: number): number;
  91942. /** @hidden */
  91943. _getInternalFormat(format: number): number;
  91944. /** @hidden */
  91945. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91946. /** @hidden */
  91947. _getRGBAMultiSampleBufferFormat(type: number): number;
  91948. /** @hidden */
  91949. _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;
  91950. /** @hidden */
  91951. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91952. /**
  91953. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91954. * @returns true if the engine can be created
  91955. * @ignorenaming
  91956. */
  91957. static isSupported(): boolean;
  91958. }
  91959. }
  91960. declare module BABYLON {
  91961. /**
  91962. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91963. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91964. */
  91965. export class EffectFallbacks {
  91966. private _defines;
  91967. private _currentRank;
  91968. private _maxRank;
  91969. private _mesh;
  91970. /**
  91971. * Removes the fallback from the bound mesh.
  91972. */
  91973. unBindMesh(): void;
  91974. /**
  91975. * Adds a fallback on the specified property.
  91976. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91977. * @param define The name of the define in the shader
  91978. */
  91979. addFallback(rank: number, define: string): void;
  91980. /**
  91981. * Sets the mesh to use CPU skinning when needing to fallback.
  91982. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91983. * @param mesh The mesh to use the fallbacks.
  91984. */
  91985. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91986. /**
  91987. * Checks to see if more fallbacks are still availible.
  91988. */
  91989. readonly isMoreFallbacks: boolean;
  91990. /**
  91991. * Removes the defines that should be removed when falling back.
  91992. * @param currentDefines defines the current define statements for the shader.
  91993. * @param effect defines the current effect we try to compile
  91994. * @returns The resulting defines with defines of the current rank removed.
  91995. */
  91996. reduce(currentDefines: string, effect: Effect): string;
  91997. }
  91998. /**
  91999. * Options to be used when creating an effect.
  92000. */
  92001. export class EffectCreationOptions {
  92002. /**
  92003. * Atrributes that will be used in the shader.
  92004. */
  92005. attributes: string[];
  92006. /**
  92007. * Uniform varible names that will be set in the shader.
  92008. */
  92009. uniformsNames: string[];
  92010. /**
  92011. * Uniform buffer varible names that will be set in the shader.
  92012. */
  92013. uniformBuffersNames: string[];
  92014. /**
  92015. * Sampler texture variable names that will be set in the shader.
  92016. */
  92017. samplers: string[];
  92018. /**
  92019. * Define statements that will be set in the shader.
  92020. */
  92021. defines: any;
  92022. /**
  92023. * Possible fallbacks for this effect to improve performance when needed.
  92024. */
  92025. fallbacks: Nullable<EffectFallbacks>;
  92026. /**
  92027. * Callback that will be called when the shader is compiled.
  92028. */
  92029. onCompiled: Nullable<(effect: Effect) => void>;
  92030. /**
  92031. * Callback that will be called if an error occurs during shader compilation.
  92032. */
  92033. onError: Nullable<(effect: Effect, errors: string) => void>;
  92034. /**
  92035. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92036. */
  92037. indexParameters: any;
  92038. /**
  92039. * Max number of lights that can be used in the shader.
  92040. */
  92041. maxSimultaneousLights: number;
  92042. /**
  92043. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92044. */
  92045. transformFeedbackVaryings: Nullable<string[]>;
  92046. }
  92047. /**
  92048. * Effect containing vertex and fragment shader that can be executed on an object.
  92049. */
  92050. export class Effect implements IDisposable {
  92051. /**
  92052. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92053. */
  92054. static ShadersRepository: string;
  92055. /**
  92056. * Name of the effect.
  92057. */
  92058. name: any;
  92059. /**
  92060. * String container all the define statements that should be set on the shader.
  92061. */
  92062. defines: string;
  92063. /**
  92064. * Callback that will be called when the shader is compiled.
  92065. */
  92066. onCompiled: Nullable<(effect: Effect) => void>;
  92067. /**
  92068. * Callback that will be called if an error occurs during shader compilation.
  92069. */
  92070. onError: Nullable<(effect: Effect, errors: string) => void>;
  92071. /**
  92072. * Callback that will be called when effect is bound.
  92073. */
  92074. onBind: Nullable<(effect: Effect) => void>;
  92075. /**
  92076. * Unique ID of the effect.
  92077. */
  92078. uniqueId: number;
  92079. /**
  92080. * Observable that will be called when the shader is compiled.
  92081. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92082. */
  92083. onCompileObservable: Observable<Effect>;
  92084. /**
  92085. * Observable that will be called if an error occurs during shader compilation.
  92086. */
  92087. onErrorObservable: Observable<Effect>;
  92088. /** @hidden */
  92089. _onBindObservable: Nullable<Observable<Effect>>;
  92090. /**
  92091. * Observable that will be called when effect is bound.
  92092. */
  92093. readonly onBindObservable: Observable<Effect>;
  92094. /** @hidden */
  92095. _bonesComputationForcedToCPU: boolean;
  92096. private static _uniqueIdSeed;
  92097. private _engine;
  92098. private _uniformBuffersNames;
  92099. private _uniformsNames;
  92100. private _samplerList;
  92101. private _samplers;
  92102. private _isReady;
  92103. private _compilationError;
  92104. private _attributesNames;
  92105. private _attributes;
  92106. private _uniforms;
  92107. /**
  92108. * Key for the effect.
  92109. * @hidden
  92110. */
  92111. _key: string;
  92112. private _indexParameters;
  92113. private _fallbacks;
  92114. private _vertexSourceCode;
  92115. private _fragmentSourceCode;
  92116. private _vertexSourceCodeOverride;
  92117. private _fragmentSourceCodeOverride;
  92118. private _transformFeedbackVaryings;
  92119. /**
  92120. * Compiled shader to webGL program.
  92121. * @hidden
  92122. */
  92123. _pipelineContext: Nullable<IPipelineContext>;
  92124. private _valueCache;
  92125. private static _baseCache;
  92126. /**
  92127. * Instantiates an effect.
  92128. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92129. * @param baseName Name of the effect.
  92130. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92131. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92132. * @param samplers List of sampler variables that will be passed to the shader.
  92133. * @param engine Engine to be used to render the effect
  92134. * @param defines Define statements to be added to the shader.
  92135. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92136. * @param onCompiled Callback that will be called when the shader is compiled.
  92137. * @param onError Callback that will be called if an error occurs during shader compilation.
  92138. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92139. */
  92140. 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);
  92141. private _useFinalCode;
  92142. /**
  92143. * Unique key for this effect
  92144. */
  92145. readonly key: string;
  92146. /**
  92147. * If the effect has been compiled and prepared.
  92148. * @returns if the effect is compiled and prepared.
  92149. */
  92150. isReady(): boolean;
  92151. /**
  92152. * The engine the effect was initialized with.
  92153. * @returns the engine.
  92154. */
  92155. getEngine(): Engine;
  92156. /**
  92157. * The pipeline context for this effect
  92158. * @returns the associated pipeline context
  92159. */
  92160. getPipelineContext(): Nullable<IPipelineContext>;
  92161. /**
  92162. * The set of names of attribute variables for the shader.
  92163. * @returns An array of attribute names.
  92164. */
  92165. getAttributesNames(): string[];
  92166. /**
  92167. * Returns the attribute at the given index.
  92168. * @param index The index of the attribute.
  92169. * @returns The location of the attribute.
  92170. */
  92171. getAttributeLocation(index: number): number;
  92172. /**
  92173. * Returns the attribute based on the name of the variable.
  92174. * @param name of the attribute to look up.
  92175. * @returns the attribute location.
  92176. */
  92177. getAttributeLocationByName(name: string): number;
  92178. /**
  92179. * The number of attributes.
  92180. * @returns the numnber of attributes.
  92181. */
  92182. getAttributesCount(): number;
  92183. /**
  92184. * Gets the index of a uniform variable.
  92185. * @param uniformName of the uniform to look up.
  92186. * @returns the index.
  92187. */
  92188. getUniformIndex(uniformName: string): number;
  92189. /**
  92190. * Returns the attribute based on the name of the variable.
  92191. * @param uniformName of the uniform to look up.
  92192. * @returns the location of the uniform.
  92193. */
  92194. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92195. /**
  92196. * Returns an array of sampler variable names
  92197. * @returns The array of sampler variable neames.
  92198. */
  92199. getSamplers(): string[];
  92200. /**
  92201. * The error from the last compilation.
  92202. * @returns the error string.
  92203. */
  92204. getCompilationError(): string;
  92205. /**
  92206. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92207. * @param func The callback to be used.
  92208. */
  92209. executeWhenCompiled(func: (effect: Effect) => void): void;
  92210. private _checkIsReady;
  92211. /** @hidden */
  92212. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92213. /** @hidden */
  92214. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92215. /** @hidden */
  92216. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92217. /**
  92218. * Recompiles the webGL program
  92219. * @param vertexSourceCode The source code for the vertex shader.
  92220. * @param fragmentSourceCode The source code for the fragment shader.
  92221. * @param onCompiled Callback called when completed.
  92222. * @param onError Callback called on error.
  92223. * @hidden
  92224. */
  92225. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92226. /**
  92227. * Prepares the effect
  92228. * @hidden
  92229. */
  92230. _prepareEffect(): void;
  92231. /**
  92232. * Checks if the effect is supported. (Must be called after compilation)
  92233. */
  92234. readonly isSupported: boolean;
  92235. /**
  92236. * Binds a texture to the engine to be used as output of the shader.
  92237. * @param channel Name of the output variable.
  92238. * @param texture Texture to bind.
  92239. * @hidden
  92240. */
  92241. _bindTexture(channel: string, texture: InternalTexture): void;
  92242. /**
  92243. * Sets a texture on the engine to be used in the shader.
  92244. * @param channel Name of the sampler variable.
  92245. * @param texture Texture to set.
  92246. */
  92247. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92248. /**
  92249. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92250. * @param channel Name of the sampler variable.
  92251. * @param texture Texture to set.
  92252. */
  92253. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92254. /**
  92255. * Sets an array of textures on the engine to be used in the shader.
  92256. * @param channel Name of the variable.
  92257. * @param textures Textures to set.
  92258. */
  92259. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92260. /**
  92261. * 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)
  92262. * @param channel Name of the sampler variable.
  92263. * @param postProcess Post process to get the input texture from.
  92264. */
  92265. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92266. /**
  92267. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92268. * 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)
  92269. * @param channel Name of the sampler variable.
  92270. * @param postProcess Post process to get the output texture from.
  92271. */
  92272. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92273. /** @hidden */
  92274. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92275. /** @hidden */
  92276. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92277. /** @hidden */
  92278. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92279. /** @hidden */
  92280. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92281. /**
  92282. * Binds a buffer to a uniform.
  92283. * @param buffer Buffer to bind.
  92284. * @param name Name of the uniform variable to bind to.
  92285. */
  92286. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92287. /**
  92288. * Binds block to a uniform.
  92289. * @param blockName Name of the block to bind.
  92290. * @param index Index to bind.
  92291. */
  92292. bindUniformBlock(blockName: string, index: number): void;
  92293. /**
  92294. * Sets an interger value on a uniform variable.
  92295. * @param uniformName Name of the variable.
  92296. * @param value Value to be set.
  92297. * @returns this effect.
  92298. */
  92299. setInt(uniformName: string, value: number): Effect;
  92300. /**
  92301. * Sets an int array on a uniform variable.
  92302. * @param uniformName Name of the variable.
  92303. * @param array array to be set.
  92304. * @returns this effect.
  92305. */
  92306. setIntArray(uniformName: string, array: Int32Array): Effect;
  92307. /**
  92308. * 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)
  92309. * @param uniformName Name of the variable.
  92310. * @param array array to be set.
  92311. * @returns this effect.
  92312. */
  92313. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92314. /**
  92315. * 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)
  92316. * @param uniformName Name of the variable.
  92317. * @param array array to be set.
  92318. * @returns this effect.
  92319. */
  92320. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92321. /**
  92322. * 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)
  92323. * @param uniformName Name of the variable.
  92324. * @param array array to be set.
  92325. * @returns this effect.
  92326. */
  92327. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92328. /**
  92329. * Sets an float array on a uniform variable.
  92330. * @param uniformName Name of the variable.
  92331. * @param array array to be set.
  92332. * @returns this effect.
  92333. */
  92334. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92335. /**
  92336. * 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)
  92337. * @param uniformName Name of the variable.
  92338. * @param array array to be set.
  92339. * @returns this effect.
  92340. */
  92341. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92342. /**
  92343. * 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)
  92344. * @param uniformName Name of the variable.
  92345. * @param array array to be set.
  92346. * @returns this effect.
  92347. */
  92348. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92349. /**
  92350. * 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)
  92351. * @param uniformName Name of the variable.
  92352. * @param array array to be set.
  92353. * @returns this effect.
  92354. */
  92355. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92356. /**
  92357. * Sets an array on a uniform variable.
  92358. * @param uniformName Name of the variable.
  92359. * @param array array to be set.
  92360. * @returns this effect.
  92361. */
  92362. setArray(uniformName: string, array: number[]): Effect;
  92363. /**
  92364. * 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)
  92365. * @param uniformName Name of the variable.
  92366. * @param array array to be set.
  92367. * @returns this effect.
  92368. */
  92369. setArray2(uniformName: string, array: number[]): Effect;
  92370. /**
  92371. * 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)
  92372. * @param uniformName Name of the variable.
  92373. * @param array array to be set.
  92374. * @returns this effect.
  92375. */
  92376. setArray3(uniformName: string, array: number[]): Effect;
  92377. /**
  92378. * 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)
  92379. * @param uniformName Name of the variable.
  92380. * @param array array to be set.
  92381. * @returns this effect.
  92382. */
  92383. setArray4(uniformName: string, array: number[]): Effect;
  92384. /**
  92385. * Sets matrices on a uniform variable.
  92386. * @param uniformName Name of the variable.
  92387. * @param matrices matrices to be set.
  92388. * @returns this effect.
  92389. */
  92390. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92391. /**
  92392. * Sets matrix on a uniform variable.
  92393. * @param uniformName Name of the variable.
  92394. * @param matrix matrix to be set.
  92395. * @returns this effect.
  92396. */
  92397. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92398. /**
  92399. * 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)
  92400. * @param uniformName Name of the variable.
  92401. * @param matrix matrix to be set.
  92402. * @returns this effect.
  92403. */
  92404. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92405. /**
  92406. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92407. * @param uniformName Name of the variable.
  92408. * @param matrix matrix to be set.
  92409. * @returns this effect.
  92410. */
  92411. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92412. /**
  92413. * Sets a float on a uniform variable.
  92414. * @param uniformName Name of the variable.
  92415. * @param value value to be set.
  92416. * @returns this effect.
  92417. */
  92418. setFloat(uniformName: string, value: number): Effect;
  92419. /**
  92420. * Sets a boolean on a uniform variable.
  92421. * @param uniformName Name of the variable.
  92422. * @param bool value to be set.
  92423. * @returns this effect.
  92424. */
  92425. setBool(uniformName: string, bool: boolean): Effect;
  92426. /**
  92427. * Sets a Vector2 on a uniform variable.
  92428. * @param uniformName Name of the variable.
  92429. * @param vector2 vector2 to be set.
  92430. * @returns this effect.
  92431. */
  92432. setVector2(uniformName: string, vector2: Vector2): Effect;
  92433. /**
  92434. * Sets a float2 on a uniform variable.
  92435. * @param uniformName Name of the variable.
  92436. * @param x First float in float2.
  92437. * @param y Second float in float2.
  92438. * @returns this effect.
  92439. */
  92440. setFloat2(uniformName: string, x: number, y: number): Effect;
  92441. /**
  92442. * Sets a Vector3 on a uniform variable.
  92443. * @param uniformName Name of the variable.
  92444. * @param vector3 Value to be set.
  92445. * @returns this effect.
  92446. */
  92447. setVector3(uniformName: string, vector3: Vector3): Effect;
  92448. /**
  92449. * Sets a float3 on a uniform variable.
  92450. * @param uniformName Name of the variable.
  92451. * @param x First float in float3.
  92452. * @param y Second float in float3.
  92453. * @param z Third float in float3.
  92454. * @returns this effect.
  92455. */
  92456. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92457. /**
  92458. * Sets a Vector4 on a uniform variable.
  92459. * @param uniformName Name of the variable.
  92460. * @param vector4 Value to be set.
  92461. * @returns this effect.
  92462. */
  92463. setVector4(uniformName: string, vector4: Vector4): Effect;
  92464. /**
  92465. * Sets a float4 on a uniform variable.
  92466. * @param uniformName Name of the variable.
  92467. * @param x First float in float4.
  92468. * @param y Second float in float4.
  92469. * @param z Third float in float4.
  92470. * @param w Fourth float in float4.
  92471. * @returns this effect.
  92472. */
  92473. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92474. /**
  92475. * Sets a Color3 on a uniform variable.
  92476. * @param uniformName Name of the variable.
  92477. * @param color3 Value to be set.
  92478. * @returns this effect.
  92479. */
  92480. setColor3(uniformName: string, color3: Color3): Effect;
  92481. /**
  92482. * Sets a Color4 on a uniform variable.
  92483. * @param uniformName Name of the variable.
  92484. * @param color3 Value to be set.
  92485. * @param alpha Alpha value to be set.
  92486. * @returns this effect.
  92487. */
  92488. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92489. /**
  92490. * Sets a Color4 on a uniform variable
  92491. * @param uniformName defines the name of the variable
  92492. * @param color4 defines the value to be set
  92493. * @returns this effect.
  92494. */
  92495. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92496. /** Release all associated resources */
  92497. dispose(): void;
  92498. /**
  92499. * This function will add a new shader to the shader store
  92500. * @param name the name of the shader
  92501. * @param pixelShader optional pixel shader content
  92502. * @param vertexShader optional vertex shader content
  92503. */
  92504. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92505. /**
  92506. * Store of each shader (The can be looked up using effect.key)
  92507. */
  92508. static ShadersStore: {
  92509. [key: string]: string;
  92510. };
  92511. /**
  92512. * Store of each included file for a shader (The can be looked up using effect.key)
  92513. */
  92514. static IncludesShadersStore: {
  92515. [key: string]: string;
  92516. };
  92517. /**
  92518. * Resets the cache of effects.
  92519. */
  92520. static ResetCache(): void;
  92521. }
  92522. }
  92523. declare module BABYLON {
  92524. /**
  92525. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92526. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92527. * 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;
  92528. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92529. */
  92530. export class ColorCurves {
  92531. private _dirty;
  92532. private _tempColor;
  92533. private _globalCurve;
  92534. private _highlightsCurve;
  92535. private _midtonesCurve;
  92536. private _shadowsCurve;
  92537. private _positiveCurve;
  92538. private _negativeCurve;
  92539. private _globalHue;
  92540. private _globalDensity;
  92541. private _globalSaturation;
  92542. private _globalExposure;
  92543. /**
  92544. * Gets the global Hue value.
  92545. * 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).
  92546. */
  92547. /**
  92548. * Sets the global Hue value.
  92549. * 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).
  92550. */
  92551. globalHue: number;
  92552. /**
  92553. * Gets the global Density value.
  92554. * 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.
  92555. * Values less than zero provide a filter of opposite hue.
  92556. */
  92557. /**
  92558. * Sets the global Density value.
  92559. * 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.
  92560. * Values less than zero provide a filter of opposite hue.
  92561. */
  92562. globalDensity: number;
  92563. /**
  92564. * Gets the global Saturation value.
  92565. * 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.
  92566. */
  92567. /**
  92568. * Sets the global Saturation value.
  92569. * 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.
  92570. */
  92571. globalSaturation: number;
  92572. /**
  92573. * Gets the global Exposure value.
  92574. * 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.
  92575. */
  92576. /**
  92577. * Sets the global Exposure value.
  92578. * 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.
  92579. */
  92580. globalExposure: number;
  92581. private _highlightsHue;
  92582. private _highlightsDensity;
  92583. private _highlightsSaturation;
  92584. private _highlightsExposure;
  92585. /**
  92586. * Gets the highlights Hue value.
  92587. * 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).
  92588. */
  92589. /**
  92590. * Sets the highlights Hue value.
  92591. * 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).
  92592. */
  92593. highlightsHue: number;
  92594. /**
  92595. * Gets the highlights Density value.
  92596. * 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.
  92597. * Values less than zero provide a filter of opposite hue.
  92598. */
  92599. /**
  92600. * Sets the highlights Density value.
  92601. * 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.
  92602. * Values less than zero provide a filter of opposite hue.
  92603. */
  92604. highlightsDensity: number;
  92605. /**
  92606. * Gets the highlights Saturation value.
  92607. * 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.
  92608. */
  92609. /**
  92610. * Sets the highlights Saturation value.
  92611. * 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.
  92612. */
  92613. highlightsSaturation: number;
  92614. /**
  92615. * Gets the highlights Exposure value.
  92616. * 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.
  92617. */
  92618. /**
  92619. * Sets the highlights Exposure value.
  92620. * 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.
  92621. */
  92622. highlightsExposure: number;
  92623. private _midtonesHue;
  92624. private _midtonesDensity;
  92625. private _midtonesSaturation;
  92626. private _midtonesExposure;
  92627. /**
  92628. * Gets the midtones Hue value.
  92629. * 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).
  92630. */
  92631. /**
  92632. * Sets the midtones Hue value.
  92633. * 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).
  92634. */
  92635. midtonesHue: number;
  92636. /**
  92637. * Gets the midtones Density value.
  92638. * 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.
  92639. * Values less than zero provide a filter of opposite hue.
  92640. */
  92641. /**
  92642. * Sets the midtones Density value.
  92643. * 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.
  92644. * Values less than zero provide a filter of opposite hue.
  92645. */
  92646. midtonesDensity: number;
  92647. /**
  92648. * Gets the midtones Saturation value.
  92649. * 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.
  92650. */
  92651. /**
  92652. * Sets the midtones Saturation value.
  92653. * 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.
  92654. */
  92655. midtonesSaturation: number;
  92656. /**
  92657. * Gets the midtones Exposure value.
  92658. * 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.
  92659. */
  92660. /**
  92661. * Sets the midtones Exposure value.
  92662. * 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.
  92663. */
  92664. midtonesExposure: number;
  92665. private _shadowsHue;
  92666. private _shadowsDensity;
  92667. private _shadowsSaturation;
  92668. private _shadowsExposure;
  92669. /**
  92670. * Gets the shadows Hue value.
  92671. * 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).
  92672. */
  92673. /**
  92674. * Sets the shadows Hue value.
  92675. * 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).
  92676. */
  92677. shadowsHue: number;
  92678. /**
  92679. * Gets the shadows Density value.
  92680. * 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.
  92681. * Values less than zero provide a filter of opposite hue.
  92682. */
  92683. /**
  92684. * Sets the shadows Density value.
  92685. * 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.
  92686. * Values less than zero provide a filter of opposite hue.
  92687. */
  92688. shadowsDensity: number;
  92689. /**
  92690. * Gets the shadows Saturation value.
  92691. * 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.
  92692. */
  92693. /**
  92694. * Sets the shadows Saturation value.
  92695. * 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.
  92696. */
  92697. shadowsSaturation: number;
  92698. /**
  92699. * Gets the shadows Exposure value.
  92700. * 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.
  92701. */
  92702. /**
  92703. * Sets the shadows Exposure value.
  92704. * 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.
  92705. */
  92706. shadowsExposure: number;
  92707. /**
  92708. * Returns the class name
  92709. * @returns The class name
  92710. */
  92711. getClassName(): string;
  92712. /**
  92713. * Binds the color curves to the shader.
  92714. * @param colorCurves The color curve to bind
  92715. * @param effect The effect to bind to
  92716. * @param positiveUniform The positive uniform shader parameter
  92717. * @param neutralUniform The neutral uniform shader parameter
  92718. * @param negativeUniform The negative uniform shader parameter
  92719. */
  92720. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92721. /**
  92722. * Prepare the list of uniforms associated with the ColorCurves effects.
  92723. * @param uniformsList The list of uniforms used in the effect
  92724. */
  92725. static PrepareUniforms(uniformsList: string[]): void;
  92726. /**
  92727. * Returns color grading data based on a hue, density, saturation and exposure value.
  92728. * @param filterHue The hue of the color filter.
  92729. * @param filterDensity The density of the color filter.
  92730. * @param saturation The saturation.
  92731. * @param exposure The exposure.
  92732. * @param result The result data container.
  92733. */
  92734. private getColorGradingDataToRef;
  92735. /**
  92736. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92737. * @param value The input slider value in range [-100,100].
  92738. * @returns Adjusted value.
  92739. */
  92740. private static applyColorGradingSliderNonlinear;
  92741. /**
  92742. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92743. * @param hue The hue (H) input.
  92744. * @param saturation The saturation (S) input.
  92745. * @param brightness The brightness (B) input.
  92746. * @result An RGBA color represented as Vector4.
  92747. */
  92748. private static fromHSBToRef;
  92749. /**
  92750. * Returns a value clamped between min and max
  92751. * @param value The value to clamp
  92752. * @param min The minimum of value
  92753. * @param max The maximum of value
  92754. * @returns The clamped value.
  92755. */
  92756. private static clamp;
  92757. /**
  92758. * Clones the current color curve instance.
  92759. * @return The cloned curves
  92760. */
  92761. clone(): ColorCurves;
  92762. /**
  92763. * Serializes the current color curve instance to a json representation.
  92764. * @return a JSON representation
  92765. */
  92766. serialize(): any;
  92767. /**
  92768. * Parses the color curve from a json representation.
  92769. * @param source the JSON source to parse
  92770. * @return The parsed curves
  92771. */
  92772. static Parse(source: any): ColorCurves;
  92773. }
  92774. }
  92775. declare module BABYLON {
  92776. /**
  92777. * Interface to follow in your material defines to integrate easily the
  92778. * Image proccessing functions.
  92779. * @hidden
  92780. */
  92781. export interface IImageProcessingConfigurationDefines {
  92782. IMAGEPROCESSING: boolean;
  92783. VIGNETTE: boolean;
  92784. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92785. VIGNETTEBLENDMODEOPAQUE: boolean;
  92786. TONEMAPPING: boolean;
  92787. TONEMAPPING_ACES: boolean;
  92788. CONTRAST: boolean;
  92789. EXPOSURE: boolean;
  92790. COLORCURVES: boolean;
  92791. COLORGRADING: boolean;
  92792. COLORGRADING3D: boolean;
  92793. SAMPLER3DGREENDEPTH: boolean;
  92794. SAMPLER3DBGRMAP: boolean;
  92795. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92796. }
  92797. /**
  92798. * @hidden
  92799. */
  92800. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92801. IMAGEPROCESSING: boolean;
  92802. VIGNETTE: boolean;
  92803. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92804. VIGNETTEBLENDMODEOPAQUE: boolean;
  92805. TONEMAPPING: boolean;
  92806. TONEMAPPING_ACES: boolean;
  92807. CONTRAST: boolean;
  92808. COLORCURVES: boolean;
  92809. COLORGRADING: boolean;
  92810. COLORGRADING3D: boolean;
  92811. SAMPLER3DGREENDEPTH: boolean;
  92812. SAMPLER3DBGRMAP: boolean;
  92813. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92814. EXPOSURE: boolean;
  92815. constructor();
  92816. }
  92817. /**
  92818. * This groups together the common properties used for image processing either in direct forward pass
  92819. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92820. * or not.
  92821. */
  92822. export class ImageProcessingConfiguration {
  92823. /**
  92824. * Default tone mapping applied in BabylonJS.
  92825. */
  92826. static readonly TONEMAPPING_STANDARD: number;
  92827. /**
  92828. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92829. * to other engines rendering to increase portability.
  92830. */
  92831. static readonly TONEMAPPING_ACES: number;
  92832. /**
  92833. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92834. */
  92835. colorCurves: Nullable<ColorCurves>;
  92836. private _colorCurvesEnabled;
  92837. /**
  92838. * Gets wether the color curves effect is enabled.
  92839. */
  92840. /**
  92841. * Sets wether the color curves effect is enabled.
  92842. */
  92843. colorCurvesEnabled: boolean;
  92844. private _colorGradingTexture;
  92845. /**
  92846. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92847. */
  92848. /**
  92849. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92850. */
  92851. colorGradingTexture: Nullable<BaseTexture>;
  92852. private _colorGradingEnabled;
  92853. /**
  92854. * Gets wether the color grading effect is enabled.
  92855. */
  92856. /**
  92857. * Sets wether the color grading effect is enabled.
  92858. */
  92859. colorGradingEnabled: boolean;
  92860. private _colorGradingWithGreenDepth;
  92861. /**
  92862. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92863. */
  92864. /**
  92865. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92866. */
  92867. colorGradingWithGreenDepth: boolean;
  92868. private _colorGradingBGR;
  92869. /**
  92870. * Gets wether the color grading texture contains BGR values.
  92871. */
  92872. /**
  92873. * Sets wether the color grading texture contains BGR values.
  92874. */
  92875. colorGradingBGR: boolean;
  92876. /** @hidden */
  92877. _exposure: number;
  92878. /**
  92879. * Gets the Exposure used in the effect.
  92880. */
  92881. /**
  92882. * Sets the Exposure used in the effect.
  92883. */
  92884. exposure: number;
  92885. private _toneMappingEnabled;
  92886. /**
  92887. * Gets wether the tone mapping effect is enabled.
  92888. */
  92889. /**
  92890. * Sets wether the tone mapping effect is enabled.
  92891. */
  92892. toneMappingEnabled: boolean;
  92893. private _toneMappingType;
  92894. /**
  92895. * Gets the type of tone mapping effect.
  92896. */
  92897. /**
  92898. * Sets the type of tone mapping effect used in BabylonJS.
  92899. */
  92900. toneMappingType: number;
  92901. protected _contrast: number;
  92902. /**
  92903. * Gets the contrast used in the effect.
  92904. */
  92905. /**
  92906. * Sets the contrast used in the effect.
  92907. */
  92908. contrast: number;
  92909. /**
  92910. * Vignette stretch size.
  92911. */
  92912. vignetteStretch: number;
  92913. /**
  92914. * Vignette centre X Offset.
  92915. */
  92916. vignetteCentreX: number;
  92917. /**
  92918. * Vignette centre Y Offset.
  92919. */
  92920. vignetteCentreY: number;
  92921. /**
  92922. * Vignette weight or intensity of the vignette effect.
  92923. */
  92924. vignetteWeight: number;
  92925. /**
  92926. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92927. * if vignetteEnabled is set to true.
  92928. */
  92929. vignetteColor: Color4;
  92930. /**
  92931. * Camera field of view used by the Vignette effect.
  92932. */
  92933. vignetteCameraFov: number;
  92934. private _vignetteBlendMode;
  92935. /**
  92936. * Gets the vignette blend mode allowing different kind of effect.
  92937. */
  92938. /**
  92939. * Sets the vignette blend mode allowing different kind of effect.
  92940. */
  92941. vignetteBlendMode: number;
  92942. private _vignetteEnabled;
  92943. /**
  92944. * Gets wether the vignette effect is enabled.
  92945. */
  92946. /**
  92947. * Sets wether the vignette effect is enabled.
  92948. */
  92949. vignetteEnabled: boolean;
  92950. private _applyByPostProcess;
  92951. /**
  92952. * Gets wether the image processing is applied through a post process or not.
  92953. */
  92954. /**
  92955. * Sets wether the image processing is applied through a post process or not.
  92956. */
  92957. applyByPostProcess: boolean;
  92958. private _isEnabled;
  92959. /**
  92960. * Gets wether the image processing is enabled or not.
  92961. */
  92962. /**
  92963. * Sets wether the image processing is enabled or not.
  92964. */
  92965. isEnabled: boolean;
  92966. /**
  92967. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92968. */
  92969. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92970. /**
  92971. * Method called each time the image processing information changes requires to recompile the effect.
  92972. */
  92973. protected _updateParameters(): void;
  92974. /**
  92975. * Gets the current class name.
  92976. * @return "ImageProcessingConfiguration"
  92977. */
  92978. getClassName(): string;
  92979. /**
  92980. * Prepare the list of uniforms associated with the Image Processing effects.
  92981. * @param uniforms The list of uniforms used in the effect
  92982. * @param defines the list of defines currently in use
  92983. */
  92984. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92985. /**
  92986. * Prepare the list of samplers associated with the Image Processing effects.
  92987. * @param samplersList The list of uniforms used in the effect
  92988. * @param defines the list of defines currently in use
  92989. */
  92990. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92991. /**
  92992. * Prepare the list of defines associated to the shader.
  92993. * @param defines the list of defines to complete
  92994. * @param forPostProcess Define if we are currently in post process mode or not
  92995. */
  92996. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92997. /**
  92998. * Returns true if all the image processing information are ready.
  92999. * @returns True if ready, otherwise, false
  93000. */
  93001. isReady(): boolean;
  93002. /**
  93003. * Binds the image processing to the shader.
  93004. * @param effect The effect to bind to
  93005. * @param aspectRatio Define the current aspect ratio of the effect
  93006. */
  93007. bind(effect: Effect, aspectRatio?: number): void;
  93008. /**
  93009. * Clones the current image processing instance.
  93010. * @return The cloned image processing
  93011. */
  93012. clone(): ImageProcessingConfiguration;
  93013. /**
  93014. * Serializes the current image processing instance to a json representation.
  93015. * @return a JSON representation
  93016. */
  93017. serialize(): any;
  93018. /**
  93019. * Parses the image processing from a json representation.
  93020. * @param source the JSON source to parse
  93021. * @return The parsed image processing
  93022. */
  93023. static Parse(source: any): ImageProcessingConfiguration;
  93024. private static _VIGNETTEMODE_MULTIPLY;
  93025. private static _VIGNETTEMODE_OPAQUE;
  93026. /**
  93027. * Used to apply the vignette as a mix with the pixel color.
  93028. */
  93029. static readonly VIGNETTEMODE_MULTIPLY: number;
  93030. /**
  93031. * Used to apply the vignette as a replacement of the pixel color.
  93032. */
  93033. static readonly VIGNETTEMODE_OPAQUE: number;
  93034. }
  93035. }
  93036. declare module BABYLON {
  93037. /**
  93038. * This represents all the required information to add a fresnel effect on a material:
  93039. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93040. */
  93041. export class FresnelParameters {
  93042. private _isEnabled;
  93043. /**
  93044. * Define if the fresnel effect is enable or not.
  93045. */
  93046. isEnabled: boolean;
  93047. /**
  93048. * Define the color used on edges (grazing angle)
  93049. */
  93050. leftColor: Color3;
  93051. /**
  93052. * Define the color used on center
  93053. */
  93054. rightColor: Color3;
  93055. /**
  93056. * Define bias applied to computed fresnel term
  93057. */
  93058. bias: number;
  93059. /**
  93060. * Defined the power exponent applied to fresnel term
  93061. */
  93062. power: number;
  93063. /**
  93064. * Clones the current fresnel and its valuues
  93065. * @returns a clone fresnel configuration
  93066. */
  93067. clone(): FresnelParameters;
  93068. /**
  93069. * Serializes the current fresnel parameters to a JSON representation.
  93070. * @return the JSON serialization
  93071. */
  93072. serialize(): any;
  93073. /**
  93074. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93075. * @param parsedFresnelParameters Define the JSON representation
  93076. * @returns the parsed parameters
  93077. */
  93078. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93079. }
  93080. }
  93081. declare module BABYLON {
  93082. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93083. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93084. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93085. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93086. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93087. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93088. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93089. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93090. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93091. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93092. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93093. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93094. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93095. /**
  93096. * Decorator used to define property that can be serialized as reference to a camera
  93097. * @param sourceName defines the name of the property to decorate
  93098. */
  93099. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93100. /**
  93101. * Class used to help serialization objects
  93102. */
  93103. export class SerializationHelper {
  93104. /** @hidden */
  93105. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93106. /** @hidden */
  93107. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93108. /** @hidden */
  93109. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93110. /** @hidden */
  93111. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93112. /**
  93113. * Appends the serialized animations from the source animations
  93114. * @param source Source containing the animations
  93115. * @param destination Target to store the animations
  93116. */
  93117. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93118. /**
  93119. * Static function used to serialized a specific entity
  93120. * @param entity defines the entity to serialize
  93121. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93122. * @returns a JSON compatible object representing the serialization of the entity
  93123. */
  93124. static Serialize<T>(entity: T, serializationObject?: any): any;
  93125. /**
  93126. * Creates a new entity from a serialization data object
  93127. * @param creationFunction defines a function used to instanciated the new entity
  93128. * @param source defines the source serialization data
  93129. * @param scene defines the hosting scene
  93130. * @param rootUrl defines the root url for resources
  93131. * @returns a new entity
  93132. */
  93133. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93134. /**
  93135. * Clones an object
  93136. * @param creationFunction defines the function used to instanciate the new object
  93137. * @param source defines the source object
  93138. * @returns the cloned object
  93139. */
  93140. static Clone<T>(creationFunction: () => T, source: T): T;
  93141. /**
  93142. * Instanciates a new object based on a source one (some data will be shared between both object)
  93143. * @param creationFunction defines the function used to instanciate the new object
  93144. * @param source defines the source object
  93145. * @returns the new object
  93146. */
  93147. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93148. }
  93149. }
  93150. declare module BABYLON {
  93151. /**
  93152. * This is the base class of all the camera used in the application.
  93153. * @see http://doc.babylonjs.com/features/cameras
  93154. */
  93155. export class Camera extends Node {
  93156. /** @hidden */
  93157. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93158. /**
  93159. * This is the default projection mode used by the cameras.
  93160. * It helps recreating a feeling of perspective and better appreciate depth.
  93161. * This is the best way to simulate real life cameras.
  93162. */
  93163. static readonly PERSPECTIVE_CAMERA: number;
  93164. /**
  93165. * This helps creating camera with an orthographic mode.
  93166. * 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.
  93167. */
  93168. static readonly ORTHOGRAPHIC_CAMERA: number;
  93169. /**
  93170. * This is the default FOV mode for perspective cameras.
  93171. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93172. */
  93173. static readonly FOVMODE_VERTICAL_FIXED: number;
  93174. /**
  93175. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93176. */
  93177. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93178. /**
  93179. * This specifies ther is no need for a camera rig.
  93180. * Basically only one eye is rendered corresponding to the camera.
  93181. */
  93182. static readonly RIG_MODE_NONE: number;
  93183. /**
  93184. * Simulates a camera Rig with one blue eye and one red eye.
  93185. * This can be use with 3d blue and red glasses.
  93186. */
  93187. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93188. /**
  93189. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93190. */
  93191. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93192. /**
  93193. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93194. */
  93195. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93196. /**
  93197. * Defines that both eyes of the camera will be rendered over under each other.
  93198. */
  93199. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93200. /**
  93201. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93202. */
  93203. static readonly RIG_MODE_VR: number;
  93204. /**
  93205. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93206. */
  93207. static readonly RIG_MODE_WEBVR: number;
  93208. /**
  93209. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93210. */
  93211. static readonly RIG_MODE_CUSTOM: number;
  93212. /**
  93213. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93214. */
  93215. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93216. /**
  93217. * Define the input manager associated with the camera.
  93218. */
  93219. inputs: CameraInputsManager<Camera>;
  93220. /** @hidden */
  93221. _position: Vector3;
  93222. /**
  93223. * Define the current local position of the camera in the scene
  93224. */
  93225. position: Vector3;
  93226. /**
  93227. * The vector the camera should consider as up.
  93228. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93229. */
  93230. upVector: Vector3;
  93231. /**
  93232. * Define the current limit on the left side for an orthographic camera
  93233. * In scene unit
  93234. */
  93235. orthoLeft: Nullable<number>;
  93236. /**
  93237. * Define the current limit on the right side for an orthographic camera
  93238. * In scene unit
  93239. */
  93240. orthoRight: Nullable<number>;
  93241. /**
  93242. * Define the current limit on the bottom side for an orthographic camera
  93243. * In scene unit
  93244. */
  93245. orthoBottom: Nullable<number>;
  93246. /**
  93247. * Define the current limit on the top side for an orthographic camera
  93248. * In scene unit
  93249. */
  93250. orthoTop: Nullable<number>;
  93251. /**
  93252. * Field Of View is set in Radians. (default is 0.8)
  93253. */
  93254. fov: number;
  93255. /**
  93256. * Define the minimum distance the camera can see from.
  93257. * This is important to note that the depth buffer are not infinite and the closer it starts
  93258. * the more your scene might encounter depth fighting issue.
  93259. */
  93260. minZ: number;
  93261. /**
  93262. * Define the maximum distance the camera can see to.
  93263. * This is important to note that the depth buffer are not infinite and the further it end
  93264. * the more your scene might encounter depth fighting issue.
  93265. */
  93266. maxZ: number;
  93267. /**
  93268. * Define the default inertia of the camera.
  93269. * This helps giving a smooth feeling to the camera movement.
  93270. */
  93271. inertia: number;
  93272. /**
  93273. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93274. */
  93275. mode: number;
  93276. /**
  93277. * Define wether the camera is intermediate.
  93278. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93279. */
  93280. isIntermediate: boolean;
  93281. /**
  93282. * Define the viewport of the camera.
  93283. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93284. */
  93285. viewport: Viewport;
  93286. /**
  93287. * Restricts the camera to viewing objects with the same layerMask.
  93288. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93289. */
  93290. layerMask: number;
  93291. /**
  93292. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93293. */
  93294. fovMode: number;
  93295. /**
  93296. * Rig mode of the camera.
  93297. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93298. * This is normally controlled byt the camera themselves as internal use.
  93299. */
  93300. cameraRigMode: number;
  93301. /**
  93302. * Defines the distance between both "eyes" in case of a RIG
  93303. */
  93304. interaxialDistance: number;
  93305. /**
  93306. * Defines if stereoscopic rendering is done side by side or over under.
  93307. */
  93308. isStereoscopicSideBySide: boolean;
  93309. /**
  93310. * 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
  93311. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93312. * else in the scene.
  93313. */
  93314. customRenderTargets: RenderTargetTexture[];
  93315. /**
  93316. * When set, the camera will render to this render target instead of the default canvas
  93317. */
  93318. outputRenderTarget: Nullable<RenderTargetTexture>;
  93319. /**
  93320. * Observable triggered when the camera view matrix has changed.
  93321. */
  93322. onViewMatrixChangedObservable: Observable<Camera>;
  93323. /**
  93324. * Observable triggered when the camera Projection matrix has changed.
  93325. */
  93326. onProjectionMatrixChangedObservable: Observable<Camera>;
  93327. /**
  93328. * Observable triggered when the inputs have been processed.
  93329. */
  93330. onAfterCheckInputsObservable: Observable<Camera>;
  93331. /**
  93332. * Observable triggered when reset has been called and applied to the camera.
  93333. */
  93334. onRestoreStateObservable: Observable<Camera>;
  93335. /** @hidden */
  93336. _cameraRigParams: any;
  93337. /** @hidden */
  93338. _rigCameras: Camera[];
  93339. /** @hidden */
  93340. _rigPostProcess: Nullable<PostProcess>;
  93341. protected _webvrViewMatrix: Matrix;
  93342. /** @hidden */
  93343. _skipRendering: boolean;
  93344. /** @hidden */
  93345. _projectionMatrix: Matrix;
  93346. /** @hidden */
  93347. _postProcesses: Nullable<PostProcess>[];
  93348. /** @hidden */
  93349. _activeMeshes: SmartArray<AbstractMesh>;
  93350. protected _globalPosition: Vector3;
  93351. /** @hidden */
  93352. _computedViewMatrix: Matrix;
  93353. private _doNotComputeProjectionMatrix;
  93354. private _transformMatrix;
  93355. private _frustumPlanes;
  93356. private _refreshFrustumPlanes;
  93357. private _storedFov;
  93358. private _stateStored;
  93359. /**
  93360. * Instantiates a new camera object.
  93361. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93362. * @see http://doc.babylonjs.com/features/cameras
  93363. * @param name Defines the name of the camera in the scene
  93364. * @param position Defines the position of the camera
  93365. * @param scene Defines the scene the camera belongs too
  93366. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93367. */
  93368. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93369. /**
  93370. * Store current camera state (fov, position, etc..)
  93371. * @returns the camera
  93372. */
  93373. storeState(): Camera;
  93374. /**
  93375. * Restores the camera state values if it has been stored. You must call storeState() first
  93376. */
  93377. protected _restoreStateValues(): boolean;
  93378. /**
  93379. * Restored camera state. You must call storeState() first.
  93380. * @returns true if restored and false otherwise
  93381. */
  93382. restoreState(): boolean;
  93383. /**
  93384. * Gets the class name of the camera.
  93385. * @returns the class name
  93386. */
  93387. getClassName(): string;
  93388. /** @hidden */
  93389. readonly _isCamera: boolean;
  93390. /**
  93391. * Gets a string representation of the camera useful for debug purpose.
  93392. * @param fullDetails Defines that a more verboe level of logging is required
  93393. * @returns the string representation
  93394. */
  93395. toString(fullDetails?: boolean): string;
  93396. /**
  93397. * Gets the current world space position of the camera.
  93398. */
  93399. readonly globalPosition: Vector3;
  93400. /**
  93401. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93402. * @returns the active meshe list
  93403. */
  93404. getActiveMeshes(): SmartArray<AbstractMesh>;
  93405. /**
  93406. * Check wether a mesh is part of the current active mesh list of the camera
  93407. * @param mesh Defines the mesh to check
  93408. * @returns true if active, false otherwise
  93409. */
  93410. isActiveMesh(mesh: Mesh): boolean;
  93411. /**
  93412. * Is this camera ready to be used/rendered
  93413. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93414. * @return true if the camera is ready
  93415. */
  93416. isReady(completeCheck?: boolean): boolean;
  93417. /** @hidden */
  93418. _initCache(): void;
  93419. /** @hidden */
  93420. _updateCache(ignoreParentClass?: boolean): void;
  93421. /** @hidden */
  93422. _isSynchronized(): boolean;
  93423. /** @hidden */
  93424. _isSynchronizedViewMatrix(): boolean;
  93425. /** @hidden */
  93426. _isSynchronizedProjectionMatrix(): boolean;
  93427. /**
  93428. * Attach the input controls to a specific dom element to get the input from.
  93429. * @param element Defines the element the controls should be listened from
  93430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93431. */
  93432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93433. /**
  93434. * Detach the current controls from the specified dom element.
  93435. * @param element Defines the element to stop listening the inputs from
  93436. */
  93437. detachControl(element: HTMLElement): void;
  93438. /**
  93439. * Update the camera state according to the different inputs gathered during the frame.
  93440. */
  93441. update(): void;
  93442. /** @hidden */
  93443. _checkInputs(): void;
  93444. /** @hidden */
  93445. readonly rigCameras: Camera[];
  93446. /**
  93447. * Gets the post process used by the rig cameras
  93448. */
  93449. readonly rigPostProcess: Nullable<PostProcess>;
  93450. /**
  93451. * Internal, gets the first post proces.
  93452. * @returns the first post process to be run on this camera.
  93453. */
  93454. _getFirstPostProcess(): Nullable<PostProcess>;
  93455. private _cascadePostProcessesToRigCams;
  93456. /**
  93457. * Attach a post process to the camera.
  93458. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93459. * @param postProcess The post process to attach to the camera
  93460. * @param insertAt The position of the post process in case several of them are in use in the scene
  93461. * @returns the position the post process has been inserted at
  93462. */
  93463. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93464. /**
  93465. * Detach a post process to the camera.
  93466. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93467. * @param postProcess The post process to detach from the camera
  93468. */
  93469. detachPostProcess(postProcess: PostProcess): void;
  93470. /**
  93471. * Gets the current world matrix of the camera
  93472. */
  93473. getWorldMatrix(): Matrix;
  93474. /** @hidden */
  93475. _getViewMatrix(): Matrix;
  93476. /**
  93477. * Gets the current view matrix of the camera.
  93478. * @param force forces the camera to recompute the matrix without looking at the cached state
  93479. * @returns the view matrix
  93480. */
  93481. getViewMatrix(force?: boolean): Matrix;
  93482. /**
  93483. * Freeze the projection matrix.
  93484. * It will prevent the cache check of the camera projection compute and can speed up perf
  93485. * if no parameter of the camera are meant to change
  93486. * @param projection Defines manually a projection if necessary
  93487. */
  93488. freezeProjectionMatrix(projection?: Matrix): void;
  93489. /**
  93490. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93491. */
  93492. unfreezeProjectionMatrix(): void;
  93493. /**
  93494. * Gets the current projection matrix of the camera.
  93495. * @param force forces the camera to recompute the matrix without looking at the cached state
  93496. * @returns the projection matrix
  93497. */
  93498. getProjectionMatrix(force?: boolean): Matrix;
  93499. /**
  93500. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93501. * @returns a Matrix
  93502. */
  93503. getTransformationMatrix(): Matrix;
  93504. private _updateFrustumPlanes;
  93505. /**
  93506. * Checks if a cullable object (mesh...) is in the camera frustum
  93507. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93508. * @param target The object to check
  93509. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93510. * @returns true if the object is in frustum otherwise false
  93511. */
  93512. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93513. /**
  93514. * Checks if a cullable object (mesh...) is in the camera frustum
  93515. * Unlike isInFrustum this cheks the full bounding box
  93516. * @param target The object to check
  93517. * @returns true if the object is in frustum otherwise false
  93518. */
  93519. isCompletelyInFrustum(target: ICullable): boolean;
  93520. /**
  93521. * Gets a ray in the forward direction from the camera.
  93522. * @param length Defines the length of the ray to create
  93523. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93524. * @param origin Defines the start point of the ray which defaults to the camera position
  93525. * @returns the forward ray
  93526. */
  93527. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93528. /**
  93529. * Releases resources associated with this node.
  93530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93532. */
  93533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93534. /** @hidden */
  93535. _isLeftCamera: boolean;
  93536. /**
  93537. * Gets the left camera of a rig setup in case of Rigged Camera
  93538. */
  93539. readonly isLeftCamera: boolean;
  93540. /** @hidden */
  93541. _isRightCamera: boolean;
  93542. /**
  93543. * Gets the right camera of a rig setup in case of Rigged Camera
  93544. */
  93545. readonly isRightCamera: boolean;
  93546. /**
  93547. * Gets the left camera of a rig setup in case of Rigged Camera
  93548. */
  93549. readonly leftCamera: Nullable<FreeCamera>;
  93550. /**
  93551. * Gets the right camera of a rig setup in case of Rigged Camera
  93552. */
  93553. readonly rightCamera: Nullable<FreeCamera>;
  93554. /**
  93555. * Gets the left camera target of a rig setup in case of Rigged Camera
  93556. * @returns the target position
  93557. */
  93558. getLeftTarget(): Nullable<Vector3>;
  93559. /**
  93560. * Gets the right camera target of a rig setup in case of Rigged Camera
  93561. * @returns the target position
  93562. */
  93563. getRightTarget(): Nullable<Vector3>;
  93564. /**
  93565. * @hidden
  93566. */
  93567. setCameraRigMode(mode: number, rigParams: any): void;
  93568. /** @hidden */
  93569. static _setStereoscopicRigMode(camera: Camera): void;
  93570. /** @hidden */
  93571. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93572. /** @hidden */
  93573. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93574. /** @hidden */
  93575. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93576. /** @hidden */
  93577. _getVRProjectionMatrix(): Matrix;
  93578. protected _updateCameraRotationMatrix(): void;
  93579. protected _updateWebVRCameraRotationMatrix(): void;
  93580. /**
  93581. * This function MUST be overwritten by the different WebVR cameras available.
  93582. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93583. * @hidden
  93584. */
  93585. _getWebVRProjectionMatrix(): Matrix;
  93586. /**
  93587. * This function MUST be overwritten by the different WebVR cameras available.
  93588. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93589. * @hidden
  93590. */
  93591. _getWebVRViewMatrix(): Matrix;
  93592. /** @hidden */
  93593. setCameraRigParameter(name: string, value: any): void;
  93594. /**
  93595. * needs to be overridden by children so sub has required properties to be copied
  93596. * @hidden
  93597. */
  93598. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93599. /**
  93600. * May need to be overridden by children
  93601. * @hidden
  93602. */
  93603. _updateRigCameras(): void;
  93604. /** @hidden */
  93605. _setupInputs(): void;
  93606. /**
  93607. * Serialiaze the camera setup to a json represention
  93608. * @returns the JSON representation
  93609. */
  93610. serialize(): any;
  93611. /**
  93612. * Clones the current camera.
  93613. * @param name The cloned camera name
  93614. * @returns the cloned camera
  93615. */
  93616. clone(name: string): Camera;
  93617. /**
  93618. * Gets the direction of the camera relative to a given local axis.
  93619. * @param localAxis Defines the reference axis to provide a relative direction.
  93620. * @return the direction
  93621. */
  93622. getDirection(localAxis: Vector3): Vector3;
  93623. /**
  93624. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93625. * @param localAxis Defines the reference axis to provide a relative direction.
  93626. * @param result Defines the vector to store the result in
  93627. */
  93628. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93629. /**
  93630. * Gets a camera constructor for a given camera type
  93631. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93632. * @param name The name of the camera the result will be able to instantiate
  93633. * @param scene The scene the result will construct the camera in
  93634. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93635. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93636. * @returns a factory method to construc the camera
  93637. */
  93638. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93639. /**
  93640. * Compute the world matrix of the camera.
  93641. * @returns the camera workd matrix
  93642. */
  93643. computeWorldMatrix(): Matrix;
  93644. /**
  93645. * Parse a JSON and creates the camera from the parsed information
  93646. * @param parsedCamera The JSON to parse
  93647. * @param scene The scene to instantiate the camera in
  93648. * @returns the newly constructed camera
  93649. */
  93650. static Parse(parsedCamera: any, scene: Scene): Camera;
  93651. }
  93652. }
  93653. declare module BABYLON {
  93654. /**
  93655. * Interface for any object that can request an animation frame
  93656. */
  93657. export interface ICustomAnimationFrameRequester {
  93658. /**
  93659. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93660. */
  93661. renderFunction?: Function;
  93662. /**
  93663. * Called to request the next frame to render to
  93664. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93665. */
  93666. requestAnimationFrame: Function;
  93667. /**
  93668. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93669. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93670. */
  93671. requestID?: number;
  93672. }
  93673. /**
  93674. * Interface containing an array of animations
  93675. */
  93676. export interface IAnimatable {
  93677. /**
  93678. * Array of animations
  93679. */
  93680. animations: Nullable<Array<Animation>>;
  93681. }
  93682. /** Interface used by value gradients (color, factor, ...) */
  93683. export interface IValueGradient {
  93684. /**
  93685. * Gets or sets the gradient value (between 0 and 1)
  93686. */
  93687. gradient: number;
  93688. }
  93689. /** Class used to store color4 gradient */
  93690. export class ColorGradient implements IValueGradient {
  93691. /**
  93692. * Gets or sets the gradient value (between 0 and 1)
  93693. */
  93694. gradient: number;
  93695. /**
  93696. * Gets or sets first associated color
  93697. */
  93698. color1: Color4;
  93699. /**
  93700. * Gets or sets second associated color
  93701. */
  93702. color2?: Color4;
  93703. /**
  93704. * Will get a color picked randomly between color1 and color2.
  93705. * If color2 is undefined then color1 will be used
  93706. * @param result defines the target Color4 to store the result in
  93707. */
  93708. getColorToRef(result: Color4): void;
  93709. }
  93710. /** Class used to store color 3 gradient */
  93711. export class Color3Gradient implements IValueGradient {
  93712. /**
  93713. * Gets or sets the gradient value (between 0 and 1)
  93714. */
  93715. gradient: number;
  93716. /**
  93717. * Gets or sets the associated color
  93718. */
  93719. color: Color3;
  93720. }
  93721. /** Class used to store factor gradient */
  93722. export class FactorGradient implements IValueGradient {
  93723. /**
  93724. * Gets or sets the gradient value (between 0 and 1)
  93725. */
  93726. gradient: number;
  93727. /**
  93728. * Gets or sets first associated factor
  93729. */
  93730. factor1: number;
  93731. /**
  93732. * Gets or sets second associated factor
  93733. */
  93734. factor2?: number;
  93735. /**
  93736. * Will get a number picked randomly between factor1 and factor2.
  93737. * If factor2 is undefined then factor1 will be used
  93738. * @returns the picked number
  93739. */
  93740. getFactor(): number;
  93741. }
  93742. /**
  93743. * @ignore
  93744. * Application error to support additional information when loading a file
  93745. */
  93746. export class LoadFileError extends Error {
  93747. /** defines the optional web request */
  93748. request?: WebRequest | undefined;
  93749. private static _setPrototypeOf;
  93750. /**
  93751. * Creates a new LoadFileError
  93752. * @param message defines the message of the error
  93753. * @param request defines the optional web request
  93754. */
  93755. constructor(message: string,
  93756. /** defines the optional web request */
  93757. request?: WebRequest | undefined);
  93758. }
  93759. /**
  93760. * Class used to define a retry strategy when error happens while loading assets
  93761. */
  93762. export class RetryStrategy {
  93763. /**
  93764. * Function used to defines an exponential back off strategy
  93765. * @param maxRetries defines the maximum number of retries (3 by default)
  93766. * @param baseInterval defines the interval between retries
  93767. * @returns the strategy function to use
  93768. */
  93769. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93770. }
  93771. /**
  93772. * File request interface
  93773. */
  93774. export interface IFileRequest {
  93775. /**
  93776. * Raised when the request is complete (success or error).
  93777. */
  93778. onCompleteObservable: Observable<IFileRequest>;
  93779. /**
  93780. * Aborts the request for a file.
  93781. */
  93782. abort: () => void;
  93783. }
  93784. /**
  93785. * Class containing a set of static utilities functions
  93786. */
  93787. export class Tools {
  93788. /**
  93789. * Gets or sets the base URL to use to load assets
  93790. */
  93791. static BaseUrl: string;
  93792. /**
  93793. * Enable/Disable Custom HTTP Request Headers globally.
  93794. * default = false
  93795. * @see CustomRequestHeaders
  93796. */
  93797. static UseCustomRequestHeaders: boolean;
  93798. /**
  93799. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93800. * i.e. when loading files, where the server/service expects an Authorization header
  93801. */
  93802. static CustomRequestHeaders: {
  93803. [key: string]: string;
  93804. };
  93805. /**
  93806. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93807. */
  93808. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93809. /**
  93810. * Default behaviour for cors in the application.
  93811. * It can be a string if the expected behavior is identical in the entire app.
  93812. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93813. */
  93814. static CorsBehavior: string | ((url: string | string[]) => string);
  93815. /**
  93816. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93817. * @ignorenaming
  93818. */
  93819. static UseFallbackTexture: boolean;
  93820. /**
  93821. * Use this object to register external classes like custom textures or material
  93822. * to allow the laoders to instantiate them
  93823. */
  93824. static RegisteredExternalClasses: {
  93825. [key: string]: Object;
  93826. };
  93827. /**
  93828. * Texture content used if a texture cannot loaded
  93829. * @ignorenaming
  93830. */
  93831. static fallbackTexture: string;
  93832. /**
  93833. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93834. * @param u defines the coordinate on X axis
  93835. * @param v defines the coordinate on Y axis
  93836. * @param width defines the width of the source data
  93837. * @param height defines the height of the source data
  93838. * @param pixels defines the source byte array
  93839. * @param color defines the output color
  93840. */
  93841. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93842. /**
  93843. * Interpolates between a and b via alpha
  93844. * @param a The lower value (returned when alpha = 0)
  93845. * @param b The upper value (returned when alpha = 1)
  93846. * @param alpha The interpolation-factor
  93847. * @return The mixed value
  93848. */
  93849. static Mix(a: number, b: number, alpha: number): number;
  93850. /**
  93851. * Tries to instantiate a new object from a given class name
  93852. * @param className defines the class name to instantiate
  93853. * @returns the new object or null if the system was not able to do the instantiation
  93854. */
  93855. static Instantiate(className: string): any;
  93856. /**
  93857. * Provides a slice function that will work even on IE
  93858. * @param data defines the array to slice
  93859. * @param start defines the start of the data (optional)
  93860. * @param end defines the end of the data (optional)
  93861. * @returns the new sliced array
  93862. */
  93863. static Slice<T>(data: T, start?: number, end?: number): T;
  93864. /**
  93865. * Polyfill for setImmediate
  93866. * @param action defines the action to execute after the current execution block
  93867. */
  93868. static SetImmediate(action: () => void): void;
  93869. /**
  93870. * Function indicating if a number is an exponent of 2
  93871. * @param value defines the value to test
  93872. * @returns true if the value is an exponent of 2
  93873. */
  93874. static IsExponentOfTwo(value: number): boolean;
  93875. private static _tmpFloatArray;
  93876. /**
  93877. * Returns the nearest 32-bit single precision float representation of a Number
  93878. * @param value A Number. If the parameter is of a different type, it will get converted
  93879. * to a number or to NaN if it cannot be converted
  93880. * @returns number
  93881. */
  93882. static FloatRound(value: number): number;
  93883. /**
  93884. * Find the next highest power of two.
  93885. * @param x Number to start search from.
  93886. * @return Next highest power of two.
  93887. */
  93888. static CeilingPOT(x: number): number;
  93889. /**
  93890. * Find the next lowest power of two.
  93891. * @param x Number to start search from.
  93892. * @return Next lowest power of two.
  93893. */
  93894. static FloorPOT(x: number): number;
  93895. /**
  93896. * Find the nearest power of two.
  93897. * @param x Number to start search from.
  93898. * @return Next nearest power of two.
  93899. */
  93900. static NearestPOT(x: number): number;
  93901. /**
  93902. * Get the closest exponent of two
  93903. * @param value defines the value to approximate
  93904. * @param max defines the maximum value to return
  93905. * @param mode defines how to define the closest value
  93906. * @returns closest exponent of two of the given value
  93907. */
  93908. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93909. /**
  93910. * Extracts the filename from a path
  93911. * @param path defines the path to use
  93912. * @returns the filename
  93913. */
  93914. static GetFilename(path: string): string;
  93915. /**
  93916. * Extracts the "folder" part of a path (everything before the filename).
  93917. * @param uri The URI to extract the info from
  93918. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93919. * @returns The "folder" part of the path
  93920. */
  93921. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93922. /**
  93923. * Extracts text content from a DOM element hierarchy
  93924. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93925. */
  93926. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93927. /**
  93928. * Convert an angle in radians to degrees
  93929. * @param angle defines the angle to convert
  93930. * @returns the angle in degrees
  93931. */
  93932. static ToDegrees(angle: number): number;
  93933. /**
  93934. * Convert an angle in degrees to radians
  93935. * @param angle defines the angle to convert
  93936. * @returns the angle in radians
  93937. */
  93938. static ToRadians(angle: number): number;
  93939. /**
  93940. * Encode a buffer to a base64 string
  93941. * @param buffer defines the buffer to encode
  93942. * @returns the encoded string
  93943. */
  93944. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93945. /**
  93946. * Extracts minimum and maximum values from a list of indexed positions
  93947. * @param positions defines the positions to use
  93948. * @param indices defines the indices to the positions
  93949. * @param indexStart defines the start index
  93950. * @param indexCount defines the end index
  93951. * @param bias defines bias value to add to the result
  93952. * @return minimum and maximum values
  93953. */
  93954. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93955. minimum: Vector3;
  93956. maximum: Vector3;
  93957. };
  93958. /**
  93959. * Extracts minimum and maximum values from a list of positions
  93960. * @param positions defines the positions to use
  93961. * @param start defines the start index in the positions array
  93962. * @param count defines the number of positions to handle
  93963. * @param bias defines bias value to add to the result
  93964. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93965. * @return minimum and maximum values
  93966. */
  93967. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93968. minimum: Vector3;
  93969. maximum: Vector3;
  93970. };
  93971. /**
  93972. * Returns an array if obj is not an array
  93973. * @param obj defines the object to evaluate as an array
  93974. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93975. * @returns either obj directly if obj is an array or a new array containing obj
  93976. */
  93977. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93978. /**
  93979. * Gets the pointer prefix to use
  93980. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93981. */
  93982. static GetPointerPrefix(): string;
  93983. /**
  93984. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93985. * @param func - the function to be called
  93986. * @param requester - the object that will request the next frame. Falls back to window.
  93987. * @returns frame number
  93988. */
  93989. static QueueNewFrame(func: () => void, requester?: any): number;
  93990. /**
  93991. * Ask the browser to promote the current element to fullscreen rendering mode
  93992. * @param element defines the DOM element to promote
  93993. */
  93994. static RequestFullscreen(element: HTMLElement): void;
  93995. /**
  93996. * Asks the browser to exit fullscreen mode
  93997. */
  93998. static ExitFullscreen(): void;
  93999. /**
  94000. * Ask the browser to promote the current element to pointerlock mode
  94001. * @param element defines the DOM element to promote
  94002. */
  94003. static RequestPointerlock(element: HTMLElement): void;
  94004. /**
  94005. * Asks the browser to exit pointerlock mode
  94006. */
  94007. static ExitPointerlock(): void;
  94008. /**
  94009. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94010. * @param url define the url we are trying
  94011. * @param element define the dom element where to configure the cors policy
  94012. */
  94013. static SetCorsBehavior(url: string | string[], element: {
  94014. crossOrigin: string | null;
  94015. }): void;
  94016. /**
  94017. * Removes unwanted characters from an url
  94018. * @param url defines the url to clean
  94019. * @returns the cleaned url
  94020. */
  94021. static CleanUrl(url: string): string;
  94022. /**
  94023. * Gets or sets a function used to pre-process url before using them to load assets
  94024. */
  94025. static PreprocessUrl: (url: string) => string;
  94026. /**
  94027. * Loads an image as an HTMLImageElement.
  94028. * @param input url string, ArrayBuffer, or Blob to load
  94029. * @param onLoad callback called when the image successfully loads
  94030. * @param onError callback called when the image fails to load
  94031. * @param offlineProvider offline provider for caching
  94032. * @returns the HTMLImageElement of the loaded image
  94033. */
  94034. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94035. /**
  94036. * Loads a file
  94037. * @param url url string, ArrayBuffer, or Blob to load
  94038. * @param onSuccess callback called when the file successfully loads
  94039. * @param onProgress callback called while file is loading (if the server supports this mode)
  94040. * @param offlineProvider defines the offline provider for caching
  94041. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94042. * @param onError callback called when the file fails to load
  94043. * @returns a file request object
  94044. */
  94045. 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;
  94046. /**
  94047. * Loads a file from a url
  94048. * @param url the file url to load
  94049. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94050. */
  94051. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94052. /**
  94053. * Load a script (identified by an url). When the url returns, the
  94054. * content of this file is added into a new script element, attached to the DOM (body element)
  94055. * @param scriptUrl defines the url of the script to laod
  94056. * @param onSuccess defines the callback called when the script is loaded
  94057. * @param onError defines the callback to call if an error occurs
  94058. * @param scriptId defines the id of the script element
  94059. */
  94060. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94061. /**
  94062. * Load an asynchronous script (identified by an url). When the url returns, the
  94063. * content of this file is added into a new script element, attached to the DOM (body element)
  94064. * @param scriptUrl defines the url of the script to laod
  94065. * @param scriptId defines the id of the script element
  94066. * @returns a promise request object
  94067. */
  94068. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94069. /**
  94070. * Loads a file from a blob
  94071. * @param fileToLoad defines the blob to use
  94072. * @param callback defines the callback to call when data is loaded
  94073. * @param progressCallback defines the callback to call during loading process
  94074. * @returns a file request object
  94075. */
  94076. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94077. /**
  94078. * Loads a file
  94079. * @param fileToLoad defines the file to load
  94080. * @param callback defines the callback to call when data is loaded
  94081. * @param progressCallBack defines the callback to call during loading process
  94082. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94083. * @returns a file request object
  94084. */
  94085. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94086. /**
  94087. * Creates a data url from a given string content
  94088. * @param content defines the content to convert
  94089. * @returns the new data url link
  94090. */
  94091. static FileAsURL(content: string): string;
  94092. /**
  94093. * Format the given number to a specific decimal format
  94094. * @param value defines the number to format
  94095. * @param decimals defines the number of decimals to use
  94096. * @returns the formatted string
  94097. */
  94098. static Format(value: number, decimals?: number): string;
  94099. /**
  94100. * Checks if a given vector is inside a specific range
  94101. * @param v defines the vector to test
  94102. * @param min defines the minimum range
  94103. * @param max defines the maximum range
  94104. */
  94105. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94106. /**
  94107. * Tries to copy an object by duplicating every property
  94108. * @param source defines the source object
  94109. * @param destination defines the target object
  94110. * @param doNotCopyList defines a list of properties to avoid
  94111. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94112. */
  94113. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94114. /**
  94115. * Gets a boolean indicating if the given object has no own property
  94116. * @param obj defines the object to test
  94117. * @returns true if object has no own property
  94118. */
  94119. static IsEmpty(obj: any): boolean;
  94120. /**
  94121. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94122. * @param str Source string
  94123. * @param suffix Suffix to search for in the source string
  94124. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94125. */
  94126. static EndsWith(str: string, suffix: string): boolean;
  94127. /**
  94128. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94129. * @param str Source string
  94130. * @param suffix Suffix to search for in the source string
  94131. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94132. */
  94133. static StartsWith(str: string, suffix: string): boolean;
  94134. /**
  94135. * Function used to register events at window level
  94136. * @param events defines the events to register
  94137. */
  94138. static RegisterTopRootEvents(events: {
  94139. name: string;
  94140. handler: Nullable<(e: FocusEvent) => any>;
  94141. }[]): void;
  94142. /**
  94143. * Function used to unregister events from window level
  94144. * @param events defines the events to unregister
  94145. */
  94146. static UnregisterTopRootEvents(events: {
  94147. name: string;
  94148. handler: Nullable<(e: FocusEvent) => any>;
  94149. }[]): void;
  94150. /**
  94151. * @ignore
  94152. */
  94153. static _ScreenshotCanvas: HTMLCanvasElement;
  94154. /**
  94155. * Dumps the current bound framebuffer
  94156. * @param width defines the rendering width
  94157. * @param height defines the rendering height
  94158. * @param engine defines the hosting engine
  94159. * @param successCallback defines the callback triggered once the data are available
  94160. * @param mimeType defines the mime type of the result
  94161. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94162. */
  94163. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94164. /**
  94165. * Converts the canvas data to blob.
  94166. * This acts as a polyfill for browsers not supporting the to blob function.
  94167. * @param canvas Defines the canvas to extract the data from
  94168. * @param successCallback Defines the callback triggered once the data are available
  94169. * @param mimeType Defines the mime type of the result
  94170. */
  94171. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94172. /**
  94173. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94174. * @param successCallback defines the callback triggered once the data are available
  94175. * @param mimeType defines the mime type of the result
  94176. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94177. */
  94178. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94179. /**
  94180. * Downloads a blob in the browser
  94181. * @param blob defines the blob to download
  94182. * @param fileName defines the name of the downloaded file
  94183. */
  94184. static Download(blob: Blob, fileName: string): void;
  94185. /**
  94186. * Captures a screenshot of the current rendering
  94187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94188. * @param engine defines the rendering engine
  94189. * @param camera defines the source camera
  94190. * @param size This parameter can be set to a single number or to an object with the
  94191. * following (optional) properties: precision, width, height. If a single number is passed,
  94192. * it will be used for both width and height. If an object is passed, the screenshot size
  94193. * will be derived from the parameters. The precision property is a multiplier allowing
  94194. * rendering at a higher or lower resolution
  94195. * @param successCallback defines the callback receives a single parameter which contains the
  94196. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94197. * src parameter of an <img> to display it
  94198. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94199. * Check your browser for supported MIME types
  94200. */
  94201. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94202. /**
  94203. * Generates an image screenshot from the specified camera.
  94204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94205. * @param engine The engine to use for rendering
  94206. * @param camera The camera to use for rendering
  94207. * @param size This parameter can be set to a single number or to an object with the
  94208. * following (optional) properties: precision, width, height. If a single number is passed,
  94209. * it will be used for both width and height. If an object is passed, the screenshot size
  94210. * will be derived from the parameters. The precision property is a multiplier allowing
  94211. * rendering at a higher or lower resolution
  94212. * @param successCallback The callback receives a single parameter which contains the
  94213. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94214. * src parameter of an <img> to display it
  94215. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94216. * Check your browser for supported MIME types
  94217. * @param samples Texture samples (default: 1)
  94218. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94219. * @param fileName A name for for the downloaded file.
  94220. */
  94221. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94222. /**
  94223. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94224. * Be aware Math.random() could cause collisions, but:
  94225. * "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"
  94226. * @returns a pseudo random id
  94227. */
  94228. static RandomId(): string;
  94229. /**
  94230. * Test if the given uri is a base64 string
  94231. * @param uri The uri to test
  94232. * @return True if the uri is a base64 string or false otherwise
  94233. */
  94234. static IsBase64(uri: string): boolean;
  94235. /**
  94236. * Decode the given base64 uri.
  94237. * @param uri The uri to decode
  94238. * @return The decoded base64 data.
  94239. */
  94240. static DecodeBase64(uri: string): ArrayBuffer;
  94241. /**
  94242. * Gets the absolute url.
  94243. * @param url the input url
  94244. * @return the absolute url
  94245. */
  94246. static GetAbsoluteUrl(url: string): string;
  94247. /**
  94248. * No log
  94249. */
  94250. static readonly NoneLogLevel: number;
  94251. /**
  94252. * Only message logs
  94253. */
  94254. static readonly MessageLogLevel: number;
  94255. /**
  94256. * Only warning logs
  94257. */
  94258. static readonly WarningLogLevel: number;
  94259. /**
  94260. * Only error logs
  94261. */
  94262. static readonly ErrorLogLevel: number;
  94263. /**
  94264. * All logs
  94265. */
  94266. static readonly AllLogLevel: number;
  94267. /**
  94268. * Gets a value indicating the number of loading errors
  94269. * @ignorenaming
  94270. */
  94271. static readonly errorsCount: number;
  94272. /**
  94273. * Callback called when a new log is added
  94274. */
  94275. static OnNewCacheEntry: (entry: string) => void;
  94276. /**
  94277. * Log a message to the console
  94278. * @param message defines the message to log
  94279. */
  94280. static Log(message: string): void;
  94281. /**
  94282. * Write a warning message to the console
  94283. * @param message defines the message to log
  94284. */
  94285. static Warn(message: string): void;
  94286. /**
  94287. * Write an error message to the console
  94288. * @param message defines the message to log
  94289. */
  94290. static Error(message: string): void;
  94291. /**
  94292. * Gets current log cache (list of logs)
  94293. */
  94294. static readonly LogCache: string;
  94295. /**
  94296. * Clears the log cache
  94297. */
  94298. static ClearLogCache(): void;
  94299. /**
  94300. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94301. */
  94302. static LogLevels: number;
  94303. /**
  94304. * Checks if the loaded document was accessed via `file:`-Protocol.
  94305. * @returns boolean
  94306. */
  94307. static IsFileURL(): boolean;
  94308. /**
  94309. * Checks if the window object exists
  94310. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94311. */
  94312. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94313. /**
  94314. * No performance log
  94315. */
  94316. static readonly PerformanceNoneLogLevel: number;
  94317. /**
  94318. * Use user marks to log performance
  94319. */
  94320. static readonly PerformanceUserMarkLogLevel: number;
  94321. /**
  94322. * Log performance to the console
  94323. */
  94324. static readonly PerformanceConsoleLogLevel: number;
  94325. private static _performance;
  94326. /**
  94327. * Sets the current performance log level
  94328. */
  94329. static PerformanceLogLevel: number;
  94330. private static _StartPerformanceCounterDisabled;
  94331. private static _EndPerformanceCounterDisabled;
  94332. private static _StartUserMark;
  94333. private static _EndUserMark;
  94334. private static _StartPerformanceConsole;
  94335. private static _EndPerformanceConsole;
  94336. /**
  94337. * Starts a performance counter
  94338. */
  94339. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94340. /**
  94341. * Ends a specific performance coutner
  94342. */
  94343. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94344. /**
  94345. * Gets either window.performance.now() if supported or Date.now() else
  94346. */
  94347. static readonly Now: number;
  94348. /**
  94349. * This method will return the name of the class used to create the instance of the given object.
  94350. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94351. * @param object the object to get the class name from
  94352. * @param isType defines if the object is actually a type
  94353. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94354. */
  94355. static GetClassName(object: any, isType?: boolean): string;
  94356. /**
  94357. * Gets the first element of an array satisfying a given predicate
  94358. * @param array defines the array to browse
  94359. * @param predicate defines the predicate to use
  94360. * @returns null if not found or the element
  94361. */
  94362. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94363. /**
  94364. * This method will return the name of the full name of the class, including its owning module (if any).
  94365. * 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).
  94366. * @param object the object to get the class name from
  94367. * @param isType defines if the object is actually a type
  94368. * @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.
  94369. * @ignorenaming
  94370. */
  94371. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94372. /**
  94373. * Returns a promise that resolves after the given amount of time.
  94374. * @param delay Number of milliseconds to delay
  94375. * @returns Promise that resolves after the given amount of time
  94376. */
  94377. static DelayAsync(delay: number): Promise<void>;
  94378. /**
  94379. * Gets the current gradient from an array of IValueGradient
  94380. * @param ratio defines the current ratio to get
  94381. * @param gradients defines the array of IValueGradient
  94382. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94383. */
  94384. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94385. }
  94386. /**
  94387. * This class is used to track a performance counter which is number based.
  94388. * The user has access to many properties which give statistics of different nature.
  94389. *
  94390. * The implementer can track two kinds of Performance Counter: time and count.
  94391. * 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.
  94392. * 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.
  94393. */
  94394. export class PerfCounter {
  94395. /**
  94396. * Gets or sets a global boolean to turn on and off all the counters
  94397. */
  94398. static Enabled: boolean;
  94399. /**
  94400. * Returns the smallest value ever
  94401. */
  94402. readonly min: number;
  94403. /**
  94404. * Returns the biggest value ever
  94405. */
  94406. readonly max: number;
  94407. /**
  94408. * Returns the average value since the performance counter is running
  94409. */
  94410. readonly average: number;
  94411. /**
  94412. * Returns the average value of the last second the counter was monitored
  94413. */
  94414. readonly lastSecAverage: number;
  94415. /**
  94416. * Returns the current value
  94417. */
  94418. readonly current: number;
  94419. /**
  94420. * Gets the accumulated total
  94421. */
  94422. readonly total: number;
  94423. /**
  94424. * Gets the total value count
  94425. */
  94426. readonly count: number;
  94427. /**
  94428. * Creates a new counter
  94429. */
  94430. constructor();
  94431. /**
  94432. * Call this method to start monitoring a new frame.
  94433. * 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.
  94434. */
  94435. fetchNewFrame(): void;
  94436. /**
  94437. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94438. * @param newCount the count value to add to the monitored count
  94439. * @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.
  94440. */
  94441. addCount(newCount: number, fetchResult: boolean): void;
  94442. /**
  94443. * Start monitoring this performance counter
  94444. */
  94445. beginMonitoring(): void;
  94446. /**
  94447. * Compute the time lapsed since the previous beginMonitoring() call.
  94448. * @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
  94449. */
  94450. endMonitoring(newFrame?: boolean): void;
  94451. private _fetchResult;
  94452. private _startMonitoringTime;
  94453. private _min;
  94454. private _max;
  94455. private _average;
  94456. private _current;
  94457. private _totalValueCount;
  94458. private _totalAccumulated;
  94459. private _lastSecAverage;
  94460. private _lastSecAccumulated;
  94461. private _lastSecTime;
  94462. private _lastSecValueCount;
  94463. }
  94464. /**
  94465. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94466. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94467. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94468. * @param name The name of the class, case should be preserved
  94469. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94470. */
  94471. export function className(name: string, module?: string): (target: Object) => void;
  94472. /**
  94473. * An implementation of a loop for asynchronous functions.
  94474. */
  94475. export class AsyncLoop {
  94476. /**
  94477. * Defines the number of iterations for the loop
  94478. */
  94479. iterations: number;
  94480. /**
  94481. * Defines the current index of the loop.
  94482. */
  94483. index: number;
  94484. private _done;
  94485. private _fn;
  94486. private _successCallback;
  94487. /**
  94488. * Constructor.
  94489. * @param iterations the number of iterations.
  94490. * @param func the function to run each iteration
  94491. * @param successCallback the callback that will be called upon succesful execution
  94492. * @param offset starting offset.
  94493. */
  94494. constructor(
  94495. /**
  94496. * Defines the number of iterations for the loop
  94497. */
  94498. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94499. /**
  94500. * Execute the next iteration. Must be called after the last iteration was finished.
  94501. */
  94502. executeNext(): void;
  94503. /**
  94504. * Break the loop and run the success callback.
  94505. */
  94506. breakLoop(): void;
  94507. /**
  94508. * Create and run an async loop.
  94509. * @param iterations the number of iterations.
  94510. * @param fn the function to run each iteration
  94511. * @param successCallback the callback that will be called upon succesful execution
  94512. * @param offset starting offset.
  94513. * @returns the created async loop object
  94514. */
  94515. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94516. /**
  94517. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94518. * @param iterations total number of iterations
  94519. * @param syncedIterations number of synchronous iterations in each async iteration.
  94520. * @param fn the function to call each iteration.
  94521. * @param callback a success call back that will be called when iterating stops.
  94522. * @param breakFunction a break condition (optional)
  94523. * @param timeout timeout settings for the setTimeout function. default - 0.
  94524. * @returns the created async loop object
  94525. */
  94526. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /** @hidden */
  94531. export interface ICollisionCoordinator {
  94532. createCollider(): Collider;
  94533. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94534. init(scene: Scene): void;
  94535. }
  94536. /** @hidden */
  94537. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94538. private _scene;
  94539. private _scaledPosition;
  94540. private _scaledVelocity;
  94541. private _finalPosition;
  94542. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94543. createCollider(): Collider;
  94544. init(scene: Scene): void;
  94545. private _collideWithWorld;
  94546. }
  94547. }
  94548. declare module BABYLON {
  94549. /**
  94550. * Class used to manage all inputs for the scene.
  94551. */
  94552. export class InputManager {
  94553. /** The distance in pixel that you have to move to prevent some events */
  94554. static DragMovementThreshold: number;
  94555. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94556. static LongPressDelay: number;
  94557. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94558. static DoubleClickDelay: number;
  94559. /** If you need to check double click without raising a single click at first click, enable this flag */
  94560. static ExclusiveDoubleClickMode: boolean;
  94561. private _wheelEventName;
  94562. private _onPointerMove;
  94563. private _onPointerDown;
  94564. private _onPointerUp;
  94565. private _initClickEvent;
  94566. private _initActionManager;
  94567. private _delayedSimpleClick;
  94568. private _delayedSimpleClickTimeout;
  94569. private _previousDelayedSimpleClickTimeout;
  94570. private _meshPickProceed;
  94571. private _previousButtonPressed;
  94572. private _currentPickResult;
  94573. private _previousPickResult;
  94574. private _totalPointersPressed;
  94575. private _doubleClickOccured;
  94576. private _pointerOverMesh;
  94577. private _pickedDownMesh;
  94578. private _pickedUpMesh;
  94579. private _pointerX;
  94580. private _pointerY;
  94581. private _unTranslatedPointerX;
  94582. private _unTranslatedPointerY;
  94583. private _startingPointerPosition;
  94584. private _previousStartingPointerPosition;
  94585. private _startingPointerTime;
  94586. private _previousStartingPointerTime;
  94587. private _pointerCaptures;
  94588. private _onKeyDown;
  94589. private _onKeyUp;
  94590. private _onCanvasFocusObserver;
  94591. private _onCanvasBlurObserver;
  94592. private _scene;
  94593. /**
  94594. * Creates a new InputManager
  94595. * @param scene defines the hosting scene
  94596. */
  94597. constructor(scene: Scene);
  94598. /**
  94599. * Gets the mesh that is currently under the pointer
  94600. */
  94601. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94602. /**
  94603. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94604. */
  94605. readonly unTranslatedPointer: Vector2;
  94606. /**
  94607. * Gets or sets the current on-screen X position of the pointer
  94608. */
  94609. pointerX: number;
  94610. /**
  94611. * Gets or sets the current on-screen Y position of the pointer
  94612. */
  94613. pointerY: number;
  94614. private _updatePointerPosition;
  94615. private _processPointerMove;
  94616. private _setRayOnPointerInfo;
  94617. private _checkPrePointerObservable;
  94618. /**
  94619. * Use this method to simulate a pointer move on a mesh
  94620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94623. */
  94624. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94625. /**
  94626. * Use this method to simulate a pointer down on a mesh
  94627. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94628. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94629. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94630. */
  94631. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94632. private _processPointerDown;
  94633. /** @hidden */
  94634. _isPointerSwiping(): boolean;
  94635. /**
  94636. * Use this method to simulate a pointer up on a mesh
  94637. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94638. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94639. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94640. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94641. */
  94642. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94643. private _processPointerUp;
  94644. /**
  94645. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94646. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94647. * @returns true if the pointer was captured
  94648. */
  94649. isPointerCaptured(pointerId?: number): boolean;
  94650. /**
  94651. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94652. * @param attachUp defines if you want to attach events to pointerup
  94653. * @param attachDown defines if you want to attach events to pointerdown
  94654. * @param attachMove defines if you want to attach events to pointermove
  94655. */
  94656. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94657. /**
  94658. * Detaches all event handlers
  94659. */
  94660. detachControl(): void;
  94661. /**
  94662. * Force the value of meshUnderPointer
  94663. * @param mesh defines the mesh to use
  94664. */
  94665. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94666. /**
  94667. * Gets the mesh under the pointer
  94668. * @returns a Mesh or null if no mesh is under the pointer
  94669. */
  94670. getPointerOverMesh(): Nullable<AbstractMesh>;
  94671. }
  94672. }
  94673. declare module BABYLON {
  94674. /**
  94675. * This class defines the direct association between an animation and a target
  94676. */
  94677. export class TargetedAnimation {
  94678. /**
  94679. * Animation to perform
  94680. */
  94681. animation: Animation;
  94682. /**
  94683. * Target to animate
  94684. */
  94685. target: any;
  94686. /**
  94687. * Serialize the object
  94688. * @returns the JSON object representing the current entity
  94689. */
  94690. serialize(): any;
  94691. }
  94692. /**
  94693. * Use this class to create coordinated animations on multiple targets
  94694. */
  94695. export class AnimationGroup implements IDisposable {
  94696. /** The name of the animation group */
  94697. name: string;
  94698. private _scene;
  94699. private _targetedAnimations;
  94700. private _animatables;
  94701. private _from;
  94702. private _to;
  94703. private _isStarted;
  94704. private _isPaused;
  94705. private _speedRatio;
  94706. private _loopAnimation;
  94707. /**
  94708. * Gets or sets the unique id of the node
  94709. */
  94710. uniqueId: number;
  94711. /**
  94712. * This observable will notify when one animation have ended
  94713. */
  94714. onAnimationEndObservable: Observable<TargetedAnimation>;
  94715. /**
  94716. * Observer raised when one animation loops
  94717. */
  94718. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94719. /**
  94720. * This observable will notify when all animations have ended.
  94721. */
  94722. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94723. /**
  94724. * This observable will notify when all animations have paused.
  94725. */
  94726. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94727. /**
  94728. * This observable will notify when all animations are playing.
  94729. */
  94730. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94731. /**
  94732. * Gets the first frame
  94733. */
  94734. readonly from: number;
  94735. /**
  94736. * Gets the last frame
  94737. */
  94738. readonly to: number;
  94739. /**
  94740. * Define if the animations are started
  94741. */
  94742. readonly isStarted: boolean;
  94743. /**
  94744. * Gets a value indicating that the current group is playing
  94745. */
  94746. readonly isPlaying: boolean;
  94747. /**
  94748. * Gets or sets the speed ratio to use for all animations
  94749. */
  94750. /**
  94751. * Gets or sets the speed ratio to use for all animations
  94752. */
  94753. speedRatio: number;
  94754. /**
  94755. * Gets or sets if all animations should loop or not
  94756. */
  94757. loopAnimation: boolean;
  94758. /**
  94759. * Gets the targeted animations for this animation group
  94760. */
  94761. readonly targetedAnimations: Array<TargetedAnimation>;
  94762. /**
  94763. * returning the list of animatables controlled by this animation group.
  94764. */
  94765. readonly animatables: Array<Animatable>;
  94766. /**
  94767. * Instantiates a new Animation Group.
  94768. * This helps managing several animations at once.
  94769. * @see http://doc.babylonjs.com/how_to/group
  94770. * @param name Defines the name of the group
  94771. * @param scene Defines the scene the group belongs to
  94772. */
  94773. constructor(
  94774. /** The name of the animation group */
  94775. name: string, scene?: Nullable<Scene>);
  94776. /**
  94777. * Add an animation (with its target) in the group
  94778. * @param animation defines the animation we want to add
  94779. * @param target defines the target of the animation
  94780. * @returns the TargetedAnimation object
  94781. */
  94782. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94783. /**
  94784. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94785. * It can add constant keys at begin or end
  94786. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94787. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94788. * @returns the animation group
  94789. */
  94790. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94791. /**
  94792. * Start all animations on given targets
  94793. * @param loop defines if animations must loop
  94794. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94795. * @param from defines the from key (optional)
  94796. * @param to defines the to key (optional)
  94797. * @returns the current animation group
  94798. */
  94799. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94800. /**
  94801. * Pause all animations
  94802. * @returns the animation group
  94803. */
  94804. pause(): AnimationGroup;
  94805. /**
  94806. * Play all animations to initial state
  94807. * This function will start() the animations if they were not started or will restart() them if they were paused
  94808. * @param loop defines if animations must loop
  94809. * @returns the animation group
  94810. */
  94811. play(loop?: boolean): AnimationGroup;
  94812. /**
  94813. * Reset all animations to initial state
  94814. * @returns the animation group
  94815. */
  94816. reset(): AnimationGroup;
  94817. /**
  94818. * Restart animations from key 0
  94819. * @returns the animation group
  94820. */
  94821. restart(): AnimationGroup;
  94822. /**
  94823. * Stop all animations
  94824. * @returns the animation group
  94825. */
  94826. stop(): AnimationGroup;
  94827. /**
  94828. * Set animation weight for all animatables
  94829. * @param weight defines the weight to use
  94830. * @return the animationGroup
  94831. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94832. */
  94833. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94834. /**
  94835. * Synchronize and normalize all animatables with a source animatable
  94836. * @param root defines the root animatable to synchronize with
  94837. * @return the animationGroup
  94838. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94839. */
  94840. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94841. /**
  94842. * Goes to a specific frame in this animation group
  94843. * @param frame the frame number to go to
  94844. * @return the animationGroup
  94845. */
  94846. goToFrame(frame: number): AnimationGroup;
  94847. /**
  94848. * Dispose all associated resources
  94849. */
  94850. dispose(): void;
  94851. private _checkAnimationGroupEnded;
  94852. /**
  94853. * Clone the current animation group and returns a copy
  94854. * @param newName defines the name of the new group
  94855. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94856. * @returns the new aniamtion group
  94857. */
  94858. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94859. /**
  94860. * Serializes the animationGroup to an object
  94861. * @returns Serialized object
  94862. */
  94863. serialize(): any;
  94864. /**
  94865. * Returns a new AnimationGroup object parsed from the source provided.
  94866. * @param parsedAnimationGroup defines the source
  94867. * @param scene defines the scene that will receive the animationGroup
  94868. * @returns a new AnimationGroup
  94869. */
  94870. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94871. /**
  94872. * Returns the string "AnimationGroup"
  94873. * @returns "AnimationGroup"
  94874. */
  94875. getClassName(): string;
  94876. /**
  94877. * Creates a detailled string about the object
  94878. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94879. * @returns a string representing the object
  94880. */
  94881. toString(fullDetails?: boolean): string;
  94882. }
  94883. }
  94884. declare module BABYLON {
  94885. /**
  94886. * Define an interface for all classes that will hold resources
  94887. */
  94888. export interface IDisposable {
  94889. /**
  94890. * Releases all held resources
  94891. */
  94892. dispose(): void;
  94893. }
  94894. /** Interface defining initialization parameters for Scene class */
  94895. export interface SceneOptions {
  94896. /**
  94897. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94898. * It will improve performance when the number of geometries becomes important.
  94899. */
  94900. useGeometryUniqueIdsMap?: boolean;
  94901. /**
  94902. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94903. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94904. */
  94905. useMaterialMeshMap?: boolean;
  94906. /**
  94907. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94908. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94909. */
  94910. useClonedMeshhMap?: boolean;
  94911. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94912. virtual?: boolean;
  94913. }
  94914. /**
  94915. * Represents a scene to be rendered by the engine.
  94916. * @see http://doc.babylonjs.com/features/scene
  94917. */
  94918. export class Scene extends AbstractScene implements IAnimatable {
  94919. private static _uniqueIdCounter;
  94920. /** The fog is deactivated */
  94921. static readonly FOGMODE_NONE: number;
  94922. /** The fog density is following an exponential function */
  94923. static readonly FOGMODE_EXP: number;
  94924. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94925. static readonly FOGMODE_EXP2: number;
  94926. /** The fog density is following a linear function. */
  94927. static readonly FOGMODE_LINEAR: number;
  94928. /**
  94929. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94931. */
  94932. static MinDeltaTime: number;
  94933. /**
  94934. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94935. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94936. */
  94937. static MaxDeltaTime: number;
  94938. /**
  94939. * Factory used to create the default material.
  94940. * @param name The name of the material to create
  94941. * @param scene The scene to create the material for
  94942. * @returns The default material
  94943. */
  94944. static DefaultMaterialFactory(scene: Scene): Material;
  94945. /**
  94946. * Factory used to create the a collision coordinator.
  94947. * @returns The collision coordinator
  94948. */
  94949. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94950. /** @hidden */
  94951. _inputManager: InputManager;
  94952. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94953. cameraToUseForPointers: Nullable<Camera>;
  94954. /** @hidden */
  94955. readonly _isScene: boolean;
  94956. /**
  94957. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94958. */
  94959. autoClear: boolean;
  94960. /**
  94961. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94962. */
  94963. autoClearDepthAndStencil: boolean;
  94964. /**
  94965. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94966. */
  94967. clearColor: Color4;
  94968. /**
  94969. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94970. */
  94971. ambientColor: Color3;
  94972. /**
  94973. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94974. * It should only be one of the following (if not the default embedded one):
  94975. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94976. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94977. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94978. * The material properties need to be setup according to the type of texture in use.
  94979. */
  94980. environmentBRDFTexture: BaseTexture;
  94981. /** @hidden */
  94982. protected _environmentTexture: Nullable<BaseTexture>;
  94983. /**
  94984. * Texture used in all pbr material as the reflection texture.
  94985. * As in the majority of the scene they are the same (exception for multi room and so on),
  94986. * this is easier to reference from here than from all the materials.
  94987. */
  94988. /**
  94989. * Texture used in all pbr material as the reflection texture.
  94990. * As in the majority of the scene they are the same (exception for multi room and so on),
  94991. * this is easier to set here than in all the materials.
  94992. */
  94993. environmentTexture: Nullable<BaseTexture>;
  94994. /** @hidden */
  94995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94996. /**
  94997. * Default image processing configuration used either in the rendering
  94998. * Forward main pass or through the imageProcessingPostProcess if present.
  94999. * As in the majority of the scene they are the same (exception for multi camera),
  95000. * this is easier to reference from here than from all the materials and post process.
  95001. *
  95002. * No setter as we it is a shared configuration, you can set the values instead.
  95003. */
  95004. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95005. private _forceWireframe;
  95006. /**
  95007. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95008. */
  95009. forceWireframe: boolean;
  95010. private _forcePointsCloud;
  95011. /**
  95012. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95013. */
  95014. forcePointsCloud: boolean;
  95015. /**
  95016. * Gets or sets the active clipplane 1
  95017. */
  95018. clipPlane: Nullable<Plane>;
  95019. /**
  95020. * Gets or sets the active clipplane 2
  95021. */
  95022. clipPlane2: Nullable<Plane>;
  95023. /**
  95024. * Gets or sets the active clipplane 3
  95025. */
  95026. clipPlane3: Nullable<Plane>;
  95027. /**
  95028. * Gets or sets the active clipplane 4
  95029. */
  95030. clipPlane4: Nullable<Plane>;
  95031. /**
  95032. * Gets or sets a boolean indicating if animations are enabled
  95033. */
  95034. animationsEnabled: boolean;
  95035. private _animationPropertiesOverride;
  95036. /**
  95037. * Gets or sets the animation properties override
  95038. */
  95039. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95040. /**
  95041. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95042. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95043. */
  95044. useConstantAnimationDeltaTime: boolean;
  95045. /**
  95046. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95047. * Please note that it requires to run a ray cast through the scene on every frame
  95048. */
  95049. constantlyUpdateMeshUnderPointer: boolean;
  95050. /**
  95051. * Defines the HTML cursor to use when hovering over interactive elements
  95052. */
  95053. hoverCursor: string;
  95054. /**
  95055. * Defines the HTML default cursor to use (empty by default)
  95056. */
  95057. defaultCursor: string;
  95058. /**
  95059. * This is used to call preventDefault() on pointer down
  95060. * in order to block unwanted artifacts like system double clicks
  95061. */
  95062. preventDefaultOnPointerDown: boolean;
  95063. /**
  95064. * This is used to call preventDefault() on pointer up
  95065. * in order to block unwanted artifacts like system double clicks
  95066. */
  95067. preventDefaultOnPointerUp: boolean;
  95068. /**
  95069. * Gets or sets user defined metadata
  95070. */
  95071. metadata: any;
  95072. /**
  95073. * For internal use only. Please do not use.
  95074. */
  95075. reservedDataStore: any;
  95076. /**
  95077. * Gets the name of the plugin used to load this scene (null by default)
  95078. */
  95079. loadingPluginName: string;
  95080. /**
  95081. * Use this array to add regular expressions used to disable offline support for specific urls
  95082. */
  95083. disableOfflineSupportExceptionRules: RegExp[];
  95084. /**
  95085. * An event triggered when the scene is disposed.
  95086. */
  95087. onDisposeObservable: Observable<Scene>;
  95088. private _onDisposeObserver;
  95089. /** Sets a function to be executed when this scene is disposed. */
  95090. onDispose: () => void;
  95091. /**
  95092. * An event triggered before rendering the scene (right after animations and physics)
  95093. */
  95094. onBeforeRenderObservable: Observable<Scene>;
  95095. private _onBeforeRenderObserver;
  95096. /** Sets a function to be executed before rendering this scene */
  95097. beforeRender: Nullable<() => void>;
  95098. /**
  95099. * An event triggered after rendering the scene
  95100. */
  95101. onAfterRenderObservable: Observable<Scene>;
  95102. /**
  95103. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95104. */
  95105. onAfterRenderCameraObservable: Observable<Camera>;
  95106. private _onAfterRenderObserver;
  95107. /** Sets a function to be executed after rendering this scene */
  95108. afterRender: Nullable<() => void>;
  95109. /**
  95110. * An event triggered before animating the scene
  95111. */
  95112. onBeforeAnimationsObservable: Observable<Scene>;
  95113. /**
  95114. * An event triggered after animations processing
  95115. */
  95116. onAfterAnimationsObservable: Observable<Scene>;
  95117. /**
  95118. * An event triggered before draw calls are ready to be sent
  95119. */
  95120. onBeforeDrawPhaseObservable: Observable<Scene>;
  95121. /**
  95122. * An event triggered after draw calls have been sent
  95123. */
  95124. onAfterDrawPhaseObservable: Observable<Scene>;
  95125. /**
  95126. * An event triggered when the scene is ready
  95127. */
  95128. onReadyObservable: Observable<Scene>;
  95129. /**
  95130. * An event triggered before rendering a camera
  95131. */
  95132. onBeforeCameraRenderObservable: Observable<Camera>;
  95133. private _onBeforeCameraRenderObserver;
  95134. /** Sets a function to be executed before rendering a camera*/
  95135. beforeCameraRender: () => void;
  95136. /**
  95137. * An event triggered after rendering a camera
  95138. */
  95139. onAfterCameraRenderObservable: Observable<Camera>;
  95140. private _onAfterCameraRenderObserver;
  95141. /** Sets a function to be executed after rendering a camera*/
  95142. afterCameraRender: () => void;
  95143. /**
  95144. * An event triggered when active meshes evaluation is about to start
  95145. */
  95146. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95147. /**
  95148. * An event triggered when active meshes evaluation is done
  95149. */
  95150. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95151. /**
  95152. * An event triggered when particles rendering is about to start
  95153. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95154. */
  95155. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95156. /**
  95157. * An event triggered when particles rendering is done
  95158. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95159. */
  95160. onAfterParticlesRenderingObservable: Observable<Scene>;
  95161. /**
  95162. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95163. */
  95164. onDataLoadedObservable: Observable<Scene>;
  95165. /**
  95166. * An event triggered when a camera is created
  95167. */
  95168. onNewCameraAddedObservable: Observable<Camera>;
  95169. /**
  95170. * An event triggered when a camera is removed
  95171. */
  95172. onCameraRemovedObservable: Observable<Camera>;
  95173. /**
  95174. * An event triggered when a light is created
  95175. */
  95176. onNewLightAddedObservable: Observable<Light>;
  95177. /**
  95178. * An event triggered when a light is removed
  95179. */
  95180. onLightRemovedObservable: Observable<Light>;
  95181. /**
  95182. * An event triggered when a geometry is created
  95183. */
  95184. onNewGeometryAddedObservable: Observable<Geometry>;
  95185. /**
  95186. * An event triggered when a geometry is removed
  95187. */
  95188. onGeometryRemovedObservable: Observable<Geometry>;
  95189. /**
  95190. * An event triggered when a transform node is created
  95191. */
  95192. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95193. /**
  95194. * An event triggered when a transform node is removed
  95195. */
  95196. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95197. /**
  95198. * An event triggered when a mesh is created
  95199. */
  95200. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95201. /**
  95202. * An event triggered when a mesh is removed
  95203. */
  95204. onMeshRemovedObservable: Observable<AbstractMesh>;
  95205. /**
  95206. * An event triggered when a skeleton is created
  95207. */
  95208. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95209. /**
  95210. * An event triggered when a skeleton is removed
  95211. */
  95212. onSkeletonRemovedObservable: Observable<Skeleton>;
  95213. /**
  95214. * An event triggered when a material is created
  95215. */
  95216. onNewMaterialAddedObservable: Observable<Material>;
  95217. /**
  95218. * An event triggered when a material is removed
  95219. */
  95220. onMaterialRemovedObservable: Observable<Material>;
  95221. /**
  95222. * An event triggered when a texture is created
  95223. */
  95224. onNewTextureAddedObservable: Observable<BaseTexture>;
  95225. /**
  95226. * An event triggered when a texture is removed
  95227. */
  95228. onTextureRemovedObservable: Observable<BaseTexture>;
  95229. /**
  95230. * An event triggered when render targets are about to be rendered
  95231. * Can happen multiple times per frame.
  95232. */
  95233. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95234. /**
  95235. * An event triggered when render targets were rendered.
  95236. * Can happen multiple times per frame.
  95237. */
  95238. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95239. /**
  95240. * An event triggered before calculating deterministic simulation step
  95241. */
  95242. onBeforeStepObservable: Observable<Scene>;
  95243. /**
  95244. * An event triggered after calculating deterministic simulation step
  95245. */
  95246. onAfterStepObservable: Observable<Scene>;
  95247. /**
  95248. * An event triggered when the activeCamera property is updated
  95249. */
  95250. onActiveCameraChanged: Observable<Scene>;
  95251. /**
  95252. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95253. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95254. * 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)
  95255. */
  95256. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95257. /**
  95258. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95259. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95260. * 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)
  95261. */
  95262. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95263. /**
  95264. * This Observable will when a mesh has been imported into the scene.
  95265. */
  95266. onMeshImportedObservable: Observable<AbstractMesh>;
  95267. /**
  95268. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95269. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95270. */
  95271. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95272. /** @hidden */
  95273. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95274. /**
  95275. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95276. */
  95277. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95278. /**
  95279. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95280. */
  95281. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95282. /**
  95283. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95284. */
  95285. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95286. /** Callback called when a pointer move is detected */
  95287. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95288. /** Callback called when a pointer down is detected */
  95289. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95290. /** Callback called when a pointer up is detected */
  95291. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95292. /** Callback called when a pointer pick is detected */
  95293. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95294. /**
  95295. * 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).
  95296. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95297. */
  95298. onPrePointerObservable: Observable<PointerInfoPre>;
  95299. /**
  95300. * Observable event triggered each time an input event is received from the rendering canvas
  95301. */
  95302. onPointerObservable: Observable<PointerInfo>;
  95303. /**
  95304. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95305. */
  95306. readonly unTranslatedPointer: Vector2;
  95307. /**
  95308. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95309. */
  95310. static DragMovementThreshold: number;
  95311. /**
  95312. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95313. */
  95314. static LongPressDelay: number;
  95315. /**
  95316. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95317. */
  95318. static DoubleClickDelay: number;
  95319. /** If you need to check double click without raising a single click at first click, enable this flag */
  95320. static ExclusiveDoubleClickMode: boolean;
  95321. /** @hidden */
  95322. _mirroredCameraPosition: Nullable<Vector3>;
  95323. /**
  95324. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95325. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95326. */
  95327. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95328. /**
  95329. * Observable event triggered each time an keyboard event is received from the hosting window
  95330. */
  95331. onKeyboardObservable: Observable<KeyboardInfo>;
  95332. private _useRightHandedSystem;
  95333. /**
  95334. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95335. */
  95336. useRightHandedSystem: boolean;
  95337. private _timeAccumulator;
  95338. private _currentStepId;
  95339. private _currentInternalStep;
  95340. /**
  95341. * Sets the step Id used by deterministic lock step
  95342. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95343. * @param newStepId defines the step Id
  95344. */
  95345. setStepId(newStepId: number): void;
  95346. /**
  95347. * Gets the step Id used by deterministic lock step
  95348. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95349. * @returns the step Id
  95350. */
  95351. getStepId(): number;
  95352. /**
  95353. * Gets the internal step used by deterministic lock step
  95354. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95355. * @returns the internal step
  95356. */
  95357. getInternalStep(): number;
  95358. private _fogEnabled;
  95359. /**
  95360. * Gets or sets a boolean indicating if fog is enabled on this scene
  95361. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95362. * (Default is true)
  95363. */
  95364. fogEnabled: boolean;
  95365. private _fogMode;
  95366. /**
  95367. * Gets or sets the fog mode to use
  95368. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95369. * | mode | value |
  95370. * | --- | --- |
  95371. * | FOGMODE_NONE | 0 |
  95372. * | FOGMODE_EXP | 1 |
  95373. * | FOGMODE_EXP2 | 2 |
  95374. * | FOGMODE_LINEAR | 3 |
  95375. */
  95376. fogMode: number;
  95377. /**
  95378. * Gets or sets the fog color to use
  95379. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95380. * (Default is Color3(0.2, 0.2, 0.3))
  95381. */
  95382. fogColor: Color3;
  95383. /**
  95384. * Gets or sets the fog density to use
  95385. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95386. * (Default is 0.1)
  95387. */
  95388. fogDensity: number;
  95389. /**
  95390. * Gets or sets the fog start distance to use
  95391. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95392. * (Default is 0)
  95393. */
  95394. fogStart: number;
  95395. /**
  95396. * Gets or sets the fog end distance to use
  95397. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95398. * (Default is 1000)
  95399. */
  95400. fogEnd: number;
  95401. private _shadowsEnabled;
  95402. /**
  95403. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95404. */
  95405. shadowsEnabled: boolean;
  95406. private _lightsEnabled;
  95407. /**
  95408. * Gets or sets a boolean indicating if lights are enabled on this scene
  95409. */
  95410. lightsEnabled: boolean;
  95411. /** All of the active cameras added to this scene. */
  95412. activeCameras: Camera[];
  95413. /** @hidden */
  95414. _activeCamera: Nullable<Camera>;
  95415. /** Gets or sets the current active camera */
  95416. activeCamera: Nullable<Camera>;
  95417. private _defaultMaterial;
  95418. /** The default material used on meshes when no material is affected */
  95419. /** The default material used on meshes when no material is affected */
  95420. defaultMaterial: Material;
  95421. private _texturesEnabled;
  95422. /**
  95423. * Gets or sets a boolean indicating if textures are enabled on this scene
  95424. */
  95425. texturesEnabled: boolean;
  95426. /**
  95427. * Gets or sets a boolean indicating if particles are enabled on this scene
  95428. */
  95429. particlesEnabled: boolean;
  95430. /**
  95431. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95432. */
  95433. spritesEnabled: boolean;
  95434. private _skeletonsEnabled;
  95435. /**
  95436. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95437. */
  95438. skeletonsEnabled: boolean;
  95439. /**
  95440. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95441. */
  95442. lensFlaresEnabled: boolean;
  95443. /**
  95444. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95446. */
  95447. collisionsEnabled: boolean;
  95448. private _collisionCoordinator;
  95449. /** @hidden */
  95450. readonly collisionCoordinator: ICollisionCoordinator;
  95451. /**
  95452. * Defines the gravity applied to this scene (used only for collisions)
  95453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95454. */
  95455. gravity: Vector3;
  95456. /**
  95457. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95458. */
  95459. postProcessesEnabled: boolean;
  95460. /**
  95461. * The list of postprocesses added to the scene
  95462. */
  95463. postProcesses: PostProcess[];
  95464. /**
  95465. * Gets the current postprocess manager
  95466. */
  95467. postProcessManager: PostProcessManager;
  95468. /**
  95469. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95470. */
  95471. renderTargetsEnabled: boolean;
  95472. /**
  95473. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95474. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95475. */
  95476. dumpNextRenderTargets: boolean;
  95477. /**
  95478. * The list of user defined render targets added to the scene
  95479. */
  95480. customRenderTargets: RenderTargetTexture[];
  95481. /**
  95482. * Defines if texture loading must be delayed
  95483. * If true, textures will only be loaded when they need to be rendered
  95484. */
  95485. useDelayedTextureLoading: boolean;
  95486. /**
  95487. * Gets the list of meshes imported to the scene through SceneLoader
  95488. */
  95489. importedMeshesFiles: String[];
  95490. /**
  95491. * Gets or sets a boolean indicating if probes are enabled on this scene
  95492. */
  95493. probesEnabled: boolean;
  95494. /**
  95495. * Gets or sets the current offline provider to use to store scene data
  95496. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95497. */
  95498. offlineProvider: IOfflineProvider;
  95499. /**
  95500. * Gets or sets the action manager associated with the scene
  95501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95502. */
  95503. actionManager: AbstractActionManager;
  95504. private _meshesForIntersections;
  95505. /**
  95506. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95507. */
  95508. proceduralTexturesEnabled: boolean;
  95509. private _engine;
  95510. private _totalVertices;
  95511. /** @hidden */
  95512. _activeIndices: PerfCounter;
  95513. /** @hidden */
  95514. _activeParticles: PerfCounter;
  95515. /** @hidden */
  95516. _activeBones: PerfCounter;
  95517. private _animationRatio;
  95518. /** @hidden */
  95519. _animationTimeLast: number;
  95520. /** @hidden */
  95521. _animationTime: number;
  95522. /**
  95523. * Gets or sets a general scale for animation speed
  95524. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95525. */
  95526. animationTimeScale: number;
  95527. /** @hidden */
  95528. _cachedMaterial: Nullable<Material>;
  95529. /** @hidden */
  95530. _cachedEffect: Nullable<Effect>;
  95531. /** @hidden */
  95532. _cachedVisibility: Nullable<number>;
  95533. private _renderId;
  95534. private _frameId;
  95535. private _executeWhenReadyTimeoutId;
  95536. private _intermediateRendering;
  95537. private _viewUpdateFlag;
  95538. private _projectionUpdateFlag;
  95539. /** @hidden */
  95540. _toBeDisposed: Nullable<IDisposable>[];
  95541. private _activeRequests;
  95542. /** @hidden */
  95543. _pendingData: any[];
  95544. private _isDisposed;
  95545. /**
  95546. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95547. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95548. */
  95549. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95550. private _activeMeshes;
  95551. private _processedMaterials;
  95552. private _renderTargets;
  95553. /** @hidden */
  95554. _activeParticleSystems: SmartArray<IParticleSystem>;
  95555. private _activeSkeletons;
  95556. private _softwareSkinnedMeshes;
  95557. private _renderingManager;
  95558. /** @hidden */
  95559. _activeAnimatables: Animatable[];
  95560. private _transformMatrix;
  95561. private _sceneUbo;
  95562. /** @hidden */
  95563. _viewMatrix: Matrix;
  95564. private _projectionMatrix;
  95565. /** @hidden */
  95566. _forcedViewPosition: Nullable<Vector3>;
  95567. /** @hidden */
  95568. _frustumPlanes: Plane[];
  95569. /**
  95570. * Gets the list of frustum planes (built from the active camera)
  95571. */
  95572. readonly frustumPlanes: Plane[];
  95573. /**
  95574. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95575. * This is useful if there are more lights that the maximum simulteanous authorized
  95576. */
  95577. requireLightSorting: boolean;
  95578. /** @hidden */
  95579. readonly useMaterialMeshMap: boolean;
  95580. /** @hidden */
  95581. readonly useClonedMeshhMap: boolean;
  95582. private _externalData;
  95583. private _uid;
  95584. /**
  95585. * @hidden
  95586. * Backing store of defined scene components.
  95587. */
  95588. _components: ISceneComponent[];
  95589. /**
  95590. * @hidden
  95591. * Backing store of defined scene components.
  95592. */
  95593. _serializableComponents: ISceneSerializableComponent[];
  95594. /**
  95595. * List of components to register on the next registration step.
  95596. */
  95597. private _transientComponents;
  95598. /**
  95599. * Registers the transient components if needed.
  95600. */
  95601. private _registerTransientComponents;
  95602. /**
  95603. * @hidden
  95604. * Add a component to the scene.
  95605. * Note that the ccomponent could be registered on th next frame if this is called after
  95606. * the register component stage.
  95607. * @param component Defines the component to add to the scene
  95608. */
  95609. _addComponent(component: ISceneComponent): void;
  95610. /**
  95611. * @hidden
  95612. * Gets a component from the scene.
  95613. * @param name defines the name of the component to retrieve
  95614. * @returns the component or null if not present
  95615. */
  95616. _getComponent(name: string): Nullable<ISceneComponent>;
  95617. /**
  95618. * @hidden
  95619. * Defines the actions happening before camera updates.
  95620. */
  95621. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95622. /**
  95623. * @hidden
  95624. * Defines the actions happening before clear the canvas.
  95625. */
  95626. _beforeClearStage: Stage<SimpleStageAction>;
  95627. /**
  95628. * @hidden
  95629. * Defines the actions when collecting render targets for the frame.
  95630. */
  95631. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95632. /**
  95633. * @hidden
  95634. * Defines the actions happening for one camera in the frame.
  95635. */
  95636. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95637. /**
  95638. * @hidden
  95639. * Defines the actions happening during the per mesh ready checks.
  95640. */
  95641. _isReadyForMeshStage: Stage<MeshStageAction>;
  95642. /**
  95643. * @hidden
  95644. * Defines the actions happening before evaluate active mesh checks.
  95645. */
  95646. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95647. /**
  95648. * @hidden
  95649. * Defines the actions happening during the evaluate sub mesh checks.
  95650. */
  95651. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95652. /**
  95653. * @hidden
  95654. * Defines the actions happening during the active mesh stage.
  95655. */
  95656. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95657. /**
  95658. * @hidden
  95659. * Defines the actions happening during the per camera render target step.
  95660. */
  95661. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95662. /**
  95663. * @hidden
  95664. * Defines the actions happening just before the active camera is drawing.
  95665. */
  95666. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95667. /**
  95668. * @hidden
  95669. * Defines the actions happening just before a render target is drawing.
  95670. */
  95671. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95672. /**
  95673. * @hidden
  95674. * Defines the actions happening just before a rendering group is drawing.
  95675. */
  95676. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95677. /**
  95678. * @hidden
  95679. * Defines the actions happening just before a mesh is drawing.
  95680. */
  95681. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95682. /**
  95683. * @hidden
  95684. * Defines the actions happening just after a mesh has been drawn.
  95685. */
  95686. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95687. /**
  95688. * @hidden
  95689. * Defines the actions happening just after a rendering group has been drawn.
  95690. */
  95691. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95692. /**
  95693. * @hidden
  95694. * Defines the actions happening just after the active camera has been drawn.
  95695. */
  95696. _afterCameraDrawStage: Stage<CameraStageAction>;
  95697. /**
  95698. * @hidden
  95699. * Defines the actions happening just after a render target has been drawn.
  95700. */
  95701. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95702. /**
  95703. * @hidden
  95704. * Defines the actions happening just after rendering all cameras and computing intersections.
  95705. */
  95706. _afterRenderStage: Stage<SimpleStageAction>;
  95707. /**
  95708. * @hidden
  95709. * Defines the actions happening when a pointer move event happens.
  95710. */
  95711. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95712. /**
  95713. * @hidden
  95714. * Defines the actions happening when a pointer down event happens.
  95715. */
  95716. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95717. /**
  95718. * @hidden
  95719. * Defines the actions happening when a pointer up event happens.
  95720. */
  95721. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95722. /**
  95723. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95724. */
  95725. private geometriesByUniqueId;
  95726. /**
  95727. * Creates a new Scene
  95728. * @param engine defines the engine to use to render this scene
  95729. * @param options defines the scene options
  95730. */
  95731. constructor(engine: Engine, options?: SceneOptions);
  95732. /**
  95733. * Gets a string idenfifying the name of the class
  95734. * @returns "Scene" string
  95735. */
  95736. getClassName(): string;
  95737. private _defaultMeshCandidates;
  95738. /**
  95739. * @hidden
  95740. */
  95741. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95742. private _defaultSubMeshCandidates;
  95743. /**
  95744. * @hidden
  95745. */
  95746. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95747. /**
  95748. * Sets the default candidate providers for the scene.
  95749. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95750. * and getCollidingSubMeshCandidates to their default function
  95751. */
  95752. setDefaultCandidateProviders(): void;
  95753. /**
  95754. * Gets the mesh that is currently under the pointer
  95755. */
  95756. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95757. /**
  95758. * Gets or sets the current on-screen X position of the pointer
  95759. */
  95760. pointerX: number;
  95761. /**
  95762. * Gets or sets the current on-screen Y position of the pointer
  95763. */
  95764. pointerY: number;
  95765. /**
  95766. * Gets the cached material (ie. the latest rendered one)
  95767. * @returns the cached material
  95768. */
  95769. getCachedMaterial(): Nullable<Material>;
  95770. /**
  95771. * Gets the cached effect (ie. the latest rendered one)
  95772. * @returns the cached effect
  95773. */
  95774. getCachedEffect(): Nullable<Effect>;
  95775. /**
  95776. * Gets the cached visibility state (ie. the latest rendered one)
  95777. * @returns the cached visibility state
  95778. */
  95779. getCachedVisibility(): Nullable<number>;
  95780. /**
  95781. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95782. * @param material defines the current material
  95783. * @param effect defines the current effect
  95784. * @param visibility defines the current visibility state
  95785. * @returns true if one parameter is not cached
  95786. */
  95787. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95788. /**
  95789. * Gets the engine associated with the scene
  95790. * @returns an Engine
  95791. */
  95792. getEngine(): Engine;
  95793. /**
  95794. * Gets the total number of vertices rendered per frame
  95795. * @returns the total number of vertices rendered per frame
  95796. */
  95797. getTotalVertices(): number;
  95798. /**
  95799. * Gets the performance counter for total vertices
  95800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95801. */
  95802. readonly totalVerticesPerfCounter: PerfCounter;
  95803. /**
  95804. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95805. * @returns the total number of active indices rendered per frame
  95806. */
  95807. getActiveIndices(): number;
  95808. /**
  95809. * Gets the performance counter for active indices
  95810. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95811. */
  95812. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95813. /**
  95814. * Gets the total number of active particles rendered per frame
  95815. * @returns the total number of active particles rendered per frame
  95816. */
  95817. getActiveParticles(): number;
  95818. /**
  95819. * Gets the performance counter for active particles
  95820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95821. */
  95822. readonly activeParticlesPerfCounter: PerfCounter;
  95823. /**
  95824. * Gets the total number of active bones rendered per frame
  95825. * @returns the total number of active bones rendered per frame
  95826. */
  95827. getActiveBones(): number;
  95828. /**
  95829. * Gets the performance counter for active bones
  95830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95831. */
  95832. readonly activeBonesPerfCounter: PerfCounter;
  95833. /**
  95834. * Gets the array of active meshes
  95835. * @returns an array of AbstractMesh
  95836. */
  95837. getActiveMeshes(): SmartArray<AbstractMesh>;
  95838. /**
  95839. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95840. * @returns a number
  95841. */
  95842. getAnimationRatio(): number;
  95843. /**
  95844. * Gets an unique Id for the current render phase
  95845. * @returns a number
  95846. */
  95847. getRenderId(): number;
  95848. /**
  95849. * Gets an unique Id for the current frame
  95850. * @returns a number
  95851. */
  95852. getFrameId(): number;
  95853. /** Call this function if you want to manually increment the render Id*/
  95854. incrementRenderId(): void;
  95855. private _createUbo;
  95856. /**
  95857. * Use this method to simulate a pointer move on a mesh
  95858. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95859. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95860. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95861. * @returns the current scene
  95862. */
  95863. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95864. /**
  95865. * Use this method to simulate a pointer down on a mesh
  95866. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95867. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95868. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95869. * @returns the current scene
  95870. */
  95871. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95872. /**
  95873. * Use this method to simulate a pointer up on a mesh
  95874. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95875. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95876. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95877. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95878. * @returns the current scene
  95879. */
  95880. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95881. /**
  95882. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95883. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95884. * @returns true if the pointer was captured
  95885. */
  95886. isPointerCaptured(pointerId?: number): boolean;
  95887. /**
  95888. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95889. * @param attachUp defines if you want to attach events to pointerup
  95890. * @param attachDown defines if you want to attach events to pointerdown
  95891. * @param attachMove defines if you want to attach events to pointermove
  95892. */
  95893. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95894. /** Detaches all event handlers*/
  95895. detachControl(): void;
  95896. /**
  95897. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95898. * Delay loaded resources are not taking in account
  95899. * @return true if all required resources are ready
  95900. */
  95901. isReady(): boolean;
  95902. /** Resets all cached information relative to material (including effect and visibility) */
  95903. resetCachedMaterial(): void;
  95904. /**
  95905. * Registers a function to be called before every frame render
  95906. * @param func defines the function to register
  95907. */
  95908. registerBeforeRender(func: () => void): void;
  95909. /**
  95910. * Unregisters a function called before every frame render
  95911. * @param func defines the function to unregister
  95912. */
  95913. unregisterBeforeRender(func: () => void): void;
  95914. /**
  95915. * Registers a function to be called after every frame render
  95916. * @param func defines the function to register
  95917. */
  95918. registerAfterRender(func: () => void): void;
  95919. /**
  95920. * Unregisters a function called after every frame render
  95921. * @param func defines the function to unregister
  95922. */
  95923. unregisterAfterRender(func: () => void): void;
  95924. private _executeOnceBeforeRender;
  95925. /**
  95926. * The provided function will run before render once and will be disposed afterwards.
  95927. * A timeout delay can be provided so that the function will be executed in N ms.
  95928. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95929. * @param func The function to be executed.
  95930. * @param timeout optional delay in ms
  95931. */
  95932. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95933. /** @hidden */
  95934. _addPendingData(data: any): void;
  95935. /** @hidden */
  95936. _removePendingData(data: any): void;
  95937. /**
  95938. * Returns the number of items waiting to be loaded
  95939. * @returns the number of items waiting to be loaded
  95940. */
  95941. getWaitingItemsCount(): number;
  95942. /**
  95943. * Returns a boolean indicating if the scene is still loading data
  95944. */
  95945. readonly isLoading: boolean;
  95946. /**
  95947. * Registers a function to be executed when the scene is ready
  95948. * @param {Function} func - the function to be executed
  95949. */
  95950. executeWhenReady(func: () => void): void;
  95951. /**
  95952. * Returns a promise that resolves when the scene is ready
  95953. * @returns A promise that resolves when the scene is ready
  95954. */
  95955. whenReadyAsync(): Promise<void>;
  95956. /** @hidden */
  95957. _checkIsReady(): void;
  95958. /**
  95959. * Gets all animatable attached to the scene
  95960. */
  95961. readonly animatables: Animatable[];
  95962. /**
  95963. * Resets the last animation time frame.
  95964. * Useful to override when animations start running when loading a scene for the first time.
  95965. */
  95966. resetLastAnimationTimeFrame(): void;
  95967. /**
  95968. * Gets the current view matrix
  95969. * @returns a Matrix
  95970. */
  95971. getViewMatrix(): Matrix;
  95972. /**
  95973. * Gets the current projection matrix
  95974. * @returns a Matrix
  95975. */
  95976. getProjectionMatrix(): Matrix;
  95977. /**
  95978. * Gets the current transform matrix
  95979. * @returns a Matrix made of View * Projection
  95980. */
  95981. getTransformMatrix(): Matrix;
  95982. /**
  95983. * Sets the current transform matrix
  95984. * @param viewL defines the View matrix to use
  95985. * @param projectionL defines the Projection matrix to use
  95986. * @param viewR defines the right View matrix to use (if provided)
  95987. * @param projectionR defines the right Projection matrix to use (if provided)
  95988. */
  95989. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95990. /**
  95991. * Gets the uniform buffer used to store scene data
  95992. * @returns a UniformBuffer
  95993. */
  95994. getSceneUniformBuffer(): UniformBuffer;
  95995. /**
  95996. * Gets an unique (relatively to the current scene) Id
  95997. * @returns an unique number for the scene
  95998. */
  95999. getUniqueId(): number;
  96000. /**
  96001. * Add a mesh to the list of scene's meshes
  96002. * @param newMesh defines the mesh to add
  96003. * @param recursive if all child meshes should also be added to the scene
  96004. */
  96005. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96006. /**
  96007. * Remove a mesh for the list of scene's meshes
  96008. * @param toRemove defines the mesh to remove
  96009. * @param recursive if all child meshes should also be removed from the scene
  96010. * @returns the index where the mesh was in the mesh list
  96011. */
  96012. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96013. /**
  96014. * Add a transform node to the list of scene's transform nodes
  96015. * @param newTransformNode defines the transform node to add
  96016. */
  96017. addTransformNode(newTransformNode: TransformNode): void;
  96018. /**
  96019. * Remove a transform node for the list of scene's transform nodes
  96020. * @param toRemove defines the transform node to remove
  96021. * @returns the index where the transform node was in the transform node list
  96022. */
  96023. removeTransformNode(toRemove: TransformNode): number;
  96024. /**
  96025. * Remove a skeleton for the list of scene's skeletons
  96026. * @param toRemove defines the skeleton to remove
  96027. * @returns the index where the skeleton was in the skeleton list
  96028. */
  96029. removeSkeleton(toRemove: Skeleton): number;
  96030. /**
  96031. * Remove a morph target for the list of scene's morph targets
  96032. * @param toRemove defines the morph target to remove
  96033. * @returns the index where the morph target was in the morph target list
  96034. */
  96035. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96036. /**
  96037. * Remove a light for the list of scene's lights
  96038. * @param toRemove defines the light to remove
  96039. * @returns the index where the light was in the light list
  96040. */
  96041. removeLight(toRemove: Light): number;
  96042. /**
  96043. * Remove a camera for the list of scene's cameras
  96044. * @param toRemove defines the camera to remove
  96045. * @returns the index where the camera was in the camera list
  96046. */
  96047. removeCamera(toRemove: Camera): number;
  96048. /**
  96049. * Remove a particle system for the list of scene's particle systems
  96050. * @param toRemove defines the particle system to remove
  96051. * @returns the index where the particle system was in the particle system list
  96052. */
  96053. removeParticleSystem(toRemove: IParticleSystem): number;
  96054. /**
  96055. * Remove a animation for the list of scene's animations
  96056. * @param toRemove defines the animation to remove
  96057. * @returns the index where the animation was in the animation list
  96058. */
  96059. removeAnimation(toRemove: Animation): number;
  96060. /**
  96061. * Will stop the animation of the given target
  96062. * @param target - the target
  96063. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96064. * @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)
  96065. */
  96066. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96067. /**
  96068. * Removes the given animation group from this scene.
  96069. * @param toRemove The animation group to remove
  96070. * @returns The index of the removed animation group
  96071. */
  96072. removeAnimationGroup(toRemove: AnimationGroup): number;
  96073. /**
  96074. * Removes the given multi-material from this scene.
  96075. * @param toRemove The multi-material to remove
  96076. * @returns The index of the removed multi-material
  96077. */
  96078. removeMultiMaterial(toRemove: MultiMaterial): number;
  96079. /**
  96080. * Removes the given material from this scene.
  96081. * @param toRemove The material to remove
  96082. * @returns The index of the removed material
  96083. */
  96084. removeMaterial(toRemove: Material): number;
  96085. /**
  96086. * Removes the given action manager from this scene.
  96087. * @param toRemove The action manager to remove
  96088. * @returns The index of the removed action manager
  96089. */
  96090. removeActionManager(toRemove: AbstractActionManager): number;
  96091. /**
  96092. * Removes the given texture from this scene.
  96093. * @param toRemove The texture to remove
  96094. * @returns The index of the removed texture
  96095. */
  96096. removeTexture(toRemove: BaseTexture): number;
  96097. /**
  96098. * Adds the given light to this scene
  96099. * @param newLight The light to add
  96100. */
  96101. addLight(newLight: Light): void;
  96102. /**
  96103. * Sorts the list list based on light priorities
  96104. */
  96105. sortLightsByPriority(): void;
  96106. /**
  96107. * Adds the given camera to this scene
  96108. * @param newCamera The camera to add
  96109. */
  96110. addCamera(newCamera: Camera): void;
  96111. /**
  96112. * Adds the given skeleton to this scene
  96113. * @param newSkeleton The skeleton to add
  96114. */
  96115. addSkeleton(newSkeleton: Skeleton): void;
  96116. /**
  96117. * Adds the given particle system to this scene
  96118. * @param newParticleSystem The particle system to add
  96119. */
  96120. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96121. /**
  96122. * Adds the given animation to this scene
  96123. * @param newAnimation The animation to add
  96124. */
  96125. addAnimation(newAnimation: Animation): void;
  96126. /**
  96127. * Adds the given animation group to this scene.
  96128. * @param newAnimationGroup The animation group to add
  96129. */
  96130. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96131. /**
  96132. * Adds the given multi-material to this scene
  96133. * @param newMultiMaterial The multi-material to add
  96134. */
  96135. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96136. /**
  96137. * Adds the given material to this scene
  96138. * @param newMaterial The material to add
  96139. */
  96140. addMaterial(newMaterial: Material): void;
  96141. /**
  96142. * Adds the given morph target to this scene
  96143. * @param newMorphTargetManager The morph target to add
  96144. */
  96145. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96146. /**
  96147. * Adds the given geometry to this scene
  96148. * @param newGeometry The geometry to add
  96149. */
  96150. addGeometry(newGeometry: Geometry): void;
  96151. /**
  96152. * Adds the given action manager to this scene
  96153. * @param newActionManager The action manager to add
  96154. */
  96155. addActionManager(newActionManager: AbstractActionManager): void;
  96156. /**
  96157. * Adds the given texture to this scene.
  96158. * @param newTexture The texture to add
  96159. */
  96160. addTexture(newTexture: BaseTexture): void;
  96161. /**
  96162. * Switch active camera
  96163. * @param newCamera defines the new active camera
  96164. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96165. */
  96166. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96167. /**
  96168. * sets the active camera of the scene using its ID
  96169. * @param id defines the camera's ID
  96170. * @return the new active camera or null if none found.
  96171. */
  96172. setActiveCameraByID(id: string): Nullable<Camera>;
  96173. /**
  96174. * sets the active camera of the scene using its name
  96175. * @param name defines the camera's name
  96176. * @returns the new active camera or null if none found.
  96177. */
  96178. setActiveCameraByName(name: string): Nullable<Camera>;
  96179. /**
  96180. * get an animation group using its name
  96181. * @param name defines the material's name
  96182. * @return the animation group or null if none found.
  96183. */
  96184. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96185. /**
  96186. * Get a material using its unique id
  96187. * @param uniqueId defines the material's unique id
  96188. * @return the material or null if none found.
  96189. */
  96190. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96191. /**
  96192. * get a material using its id
  96193. * @param id defines the material's ID
  96194. * @return the material or null if none found.
  96195. */
  96196. getMaterialByID(id: string): Nullable<Material>;
  96197. /**
  96198. * Gets a the last added material using a given id
  96199. * @param id defines the material's ID
  96200. * @return the last material with the given id or null if none found.
  96201. */
  96202. getLastMaterialByID(id: string): Nullable<Material>;
  96203. /**
  96204. * Gets a material using its name
  96205. * @param name defines the material's name
  96206. * @return the material or null if none found.
  96207. */
  96208. getMaterialByName(name: string): Nullable<Material>;
  96209. /**
  96210. * Gets a camera using its id
  96211. * @param id defines the id to look for
  96212. * @returns the camera or null if not found
  96213. */
  96214. getCameraByID(id: string): Nullable<Camera>;
  96215. /**
  96216. * Gets a camera using its unique id
  96217. * @param uniqueId defines the unique id to look for
  96218. * @returns the camera or null if not found
  96219. */
  96220. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96221. /**
  96222. * Gets a camera using its name
  96223. * @param name defines the camera's name
  96224. * @return the camera or null if none found.
  96225. */
  96226. getCameraByName(name: string): Nullable<Camera>;
  96227. /**
  96228. * Gets a bone using its id
  96229. * @param id defines the bone's id
  96230. * @return the bone or null if not found
  96231. */
  96232. getBoneByID(id: string): Nullable<Bone>;
  96233. /**
  96234. * Gets a bone using its id
  96235. * @param name defines the bone's name
  96236. * @return the bone or null if not found
  96237. */
  96238. getBoneByName(name: string): Nullable<Bone>;
  96239. /**
  96240. * Gets a light node using its name
  96241. * @param name defines the the light's name
  96242. * @return the light or null if none found.
  96243. */
  96244. getLightByName(name: string): Nullable<Light>;
  96245. /**
  96246. * Gets a light node using its id
  96247. * @param id defines the light's id
  96248. * @return the light or null if none found.
  96249. */
  96250. getLightByID(id: string): Nullable<Light>;
  96251. /**
  96252. * Gets a light node using its scene-generated unique ID
  96253. * @param uniqueId defines the light's unique id
  96254. * @return the light or null if none found.
  96255. */
  96256. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96257. /**
  96258. * Gets a particle system by id
  96259. * @param id defines the particle system id
  96260. * @return the corresponding system or null if none found
  96261. */
  96262. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96263. /**
  96264. * Gets a geometry using its ID
  96265. * @param id defines the geometry's id
  96266. * @return the geometry or null if none found.
  96267. */
  96268. getGeometryByID(id: string): Nullable<Geometry>;
  96269. private _getGeometryByUniqueID;
  96270. /**
  96271. * Add a new geometry to this scene
  96272. * @param geometry defines the geometry to be added to the scene.
  96273. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96274. * @return a boolean defining if the geometry was added or not
  96275. */
  96276. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96277. /**
  96278. * Removes an existing geometry
  96279. * @param geometry defines the geometry to be removed from the scene
  96280. * @return a boolean defining if the geometry was removed or not
  96281. */
  96282. removeGeometry(geometry: Geometry): boolean;
  96283. /**
  96284. * Gets the list of geometries attached to the scene
  96285. * @returns an array of Geometry
  96286. */
  96287. getGeometries(): Geometry[];
  96288. /**
  96289. * Gets the first added mesh found of a given ID
  96290. * @param id defines the id to search for
  96291. * @return the mesh found or null if not found at all
  96292. */
  96293. getMeshByID(id: string): Nullable<AbstractMesh>;
  96294. /**
  96295. * Gets a list of meshes using their id
  96296. * @param id defines the id to search for
  96297. * @returns a list of meshes
  96298. */
  96299. getMeshesByID(id: string): Array<AbstractMesh>;
  96300. /**
  96301. * Gets the first added transform node found of a given ID
  96302. * @param id defines the id to search for
  96303. * @return the found transform node or null if not found at all.
  96304. */
  96305. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96306. /**
  96307. * Gets a transform node with its auto-generated unique id
  96308. * @param uniqueId efines the unique id to search for
  96309. * @return the found transform node or null if not found at all.
  96310. */
  96311. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96312. /**
  96313. * Gets a list of transform nodes using their id
  96314. * @param id defines the id to search for
  96315. * @returns a list of transform nodes
  96316. */
  96317. getTransformNodesByID(id: string): Array<TransformNode>;
  96318. /**
  96319. * Gets a mesh with its auto-generated unique id
  96320. * @param uniqueId defines the unique id to search for
  96321. * @return the found mesh or null if not found at all.
  96322. */
  96323. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96324. /**
  96325. * Gets a the last added mesh using a given id
  96326. * @param id defines the id to search for
  96327. * @return the found mesh or null if not found at all.
  96328. */
  96329. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96330. /**
  96331. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96332. * @param id defines the id to search for
  96333. * @return the found node or null if not found at all
  96334. */
  96335. getLastEntryByID(id: string): Nullable<Node>;
  96336. /**
  96337. * Gets a node (Mesh, Camera, Light) using a given id
  96338. * @param id defines the id to search for
  96339. * @return the found node or null if not found at all
  96340. */
  96341. getNodeByID(id: string): Nullable<Node>;
  96342. /**
  96343. * Gets a node (Mesh, Camera, Light) using a given name
  96344. * @param name defines the name to search for
  96345. * @return the found node or null if not found at all.
  96346. */
  96347. getNodeByName(name: string): Nullable<Node>;
  96348. /**
  96349. * Gets a mesh using a given name
  96350. * @param name defines the name to search for
  96351. * @return the found mesh or null if not found at all.
  96352. */
  96353. getMeshByName(name: string): Nullable<AbstractMesh>;
  96354. /**
  96355. * Gets a transform node using a given name
  96356. * @param name defines the name to search for
  96357. * @return the found transform node or null if not found at all.
  96358. */
  96359. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96360. /**
  96361. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96362. * @param id defines the id to search for
  96363. * @return the found skeleton or null if not found at all.
  96364. */
  96365. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96366. /**
  96367. * Gets a skeleton using a given auto generated unique id
  96368. * @param uniqueId defines the unique id to search for
  96369. * @return the found skeleton or null if not found at all.
  96370. */
  96371. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96372. /**
  96373. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96374. * @param id defines the id to search for
  96375. * @return the found skeleton or null if not found at all.
  96376. */
  96377. getSkeletonById(id: string): Nullable<Skeleton>;
  96378. /**
  96379. * Gets a skeleton using a given name
  96380. * @param name defines the name to search for
  96381. * @return the found skeleton or null if not found at all.
  96382. */
  96383. getSkeletonByName(name: string): Nullable<Skeleton>;
  96384. /**
  96385. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96386. * @param id defines the id to search for
  96387. * @return the found morph target manager or null if not found at all.
  96388. */
  96389. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96390. /**
  96391. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96392. * @param id defines the id to search for
  96393. * @return the found morph target or null if not found at all.
  96394. */
  96395. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96396. /**
  96397. * Gets a boolean indicating if the given mesh is active
  96398. * @param mesh defines the mesh to look for
  96399. * @returns true if the mesh is in the active list
  96400. */
  96401. isActiveMesh(mesh: AbstractMesh): boolean;
  96402. /**
  96403. * Return a unique id as a string which can serve as an identifier for the scene
  96404. */
  96405. readonly uid: string;
  96406. /**
  96407. * Add an externaly attached data from its key.
  96408. * This method call will fail and return false, if such key already exists.
  96409. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96410. * @param key the unique key that identifies the data
  96411. * @param data the data object to associate to the key for this Engine instance
  96412. * @return true if no such key were already present and the data was added successfully, false otherwise
  96413. */
  96414. addExternalData<T>(key: string, data: T): boolean;
  96415. /**
  96416. * Get an externaly attached data from its key
  96417. * @param key the unique key that identifies the data
  96418. * @return the associated data, if present (can be null), or undefined if not present
  96419. */
  96420. getExternalData<T>(key: string): Nullable<T>;
  96421. /**
  96422. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96423. * @param key the unique key that identifies the data
  96424. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96425. * @return the associated data, can be null if the factory returned null.
  96426. */
  96427. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96428. /**
  96429. * Remove an externaly attached data from the Engine instance
  96430. * @param key the unique key that identifies the data
  96431. * @return true if the data was successfully removed, false if it doesn't exist
  96432. */
  96433. removeExternalData(key: string): boolean;
  96434. private _evaluateSubMesh;
  96435. /**
  96436. * Clear the processed materials smart array preventing retention point in material dispose.
  96437. */
  96438. freeProcessedMaterials(): void;
  96439. private _preventFreeActiveMeshesAndRenderingGroups;
  96440. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96441. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96442. * when disposing several meshes in a row or a hierarchy of meshes.
  96443. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96444. */
  96445. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96446. /**
  96447. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96448. */
  96449. freeActiveMeshes(): void;
  96450. /**
  96451. * Clear the info related to rendering groups preventing retention points during dispose.
  96452. */
  96453. freeRenderingGroups(): void;
  96454. /** @hidden */
  96455. _isInIntermediateRendering(): boolean;
  96456. /**
  96457. * Lambda returning the list of potentially active meshes.
  96458. */
  96459. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96460. /**
  96461. * Lambda returning the list of potentially active sub meshes.
  96462. */
  96463. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96464. /**
  96465. * Lambda returning the list of potentially intersecting sub meshes.
  96466. */
  96467. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96468. /**
  96469. * Lambda returning the list of potentially colliding sub meshes.
  96470. */
  96471. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96472. private _activeMeshesFrozen;
  96473. /**
  96474. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96475. * @returns the current scene
  96476. */
  96477. freezeActiveMeshes(): Scene;
  96478. /**
  96479. * Use this function to restart evaluating active meshes on every frame
  96480. * @returns the current scene
  96481. */
  96482. unfreezeActiveMeshes(): Scene;
  96483. private _evaluateActiveMeshes;
  96484. private _activeMesh;
  96485. /**
  96486. * Update the transform matrix to update from the current active camera
  96487. * @param force defines a boolean used to force the update even if cache is up to date
  96488. */
  96489. updateTransformMatrix(force?: boolean): void;
  96490. private _bindFrameBuffer;
  96491. /** @hidden */
  96492. _allowPostProcessClearColor: boolean;
  96493. /** @hidden */
  96494. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96495. private _processSubCameras;
  96496. private _checkIntersections;
  96497. /** @hidden */
  96498. _advancePhysicsEngineStep(step: number): void;
  96499. /**
  96500. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96501. */
  96502. getDeterministicFrameTime: () => number;
  96503. /** @hidden */
  96504. _animate(): void;
  96505. /** Execute all animations (for a frame) */
  96506. animate(): void;
  96507. /**
  96508. * Render the scene
  96509. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96510. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96511. */
  96512. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96513. /**
  96514. * Freeze all materials
  96515. * A frozen material will not be updatable but should be faster to render
  96516. */
  96517. freezeMaterials(): void;
  96518. /**
  96519. * Unfreeze all materials
  96520. * A frozen material will not be updatable but should be faster to render
  96521. */
  96522. unfreezeMaterials(): void;
  96523. /**
  96524. * Releases all held ressources
  96525. */
  96526. dispose(): void;
  96527. /**
  96528. * Gets if the scene is already disposed
  96529. */
  96530. readonly isDisposed: boolean;
  96531. /**
  96532. * Call this function to reduce memory footprint of the scene.
  96533. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96534. */
  96535. clearCachedVertexData(): void;
  96536. /**
  96537. * This function will remove the local cached buffer data from texture.
  96538. * It will save memory but will prevent the texture from being rebuilt
  96539. */
  96540. cleanCachedTextureBuffer(): void;
  96541. /**
  96542. * Get the world extend vectors with an optional filter
  96543. *
  96544. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96545. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96546. */
  96547. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96548. min: Vector3;
  96549. max: Vector3;
  96550. };
  96551. /**
  96552. * Creates a ray that can be used to pick in the scene
  96553. * @param x defines the x coordinate of the origin (on-screen)
  96554. * @param y defines the y coordinate of the origin (on-screen)
  96555. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96556. * @param camera defines the camera to use for the picking
  96557. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96558. * @returns a Ray
  96559. */
  96560. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96561. /**
  96562. * Creates a ray that can be used to pick in the scene
  96563. * @param x defines the x coordinate of the origin (on-screen)
  96564. * @param y defines the y coordinate of the origin (on-screen)
  96565. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96566. * @param result defines the ray where to store the picking ray
  96567. * @param camera defines the camera to use for the picking
  96568. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96569. * @returns the current scene
  96570. */
  96571. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96572. /**
  96573. * Creates a ray that can be used to pick in the scene
  96574. * @param x defines the x coordinate of the origin (on-screen)
  96575. * @param y defines the y coordinate of the origin (on-screen)
  96576. * @param camera defines the camera to use for the picking
  96577. * @returns a Ray
  96578. */
  96579. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96580. /**
  96581. * Creates a ray that can be used to pick in the scene
  96582. * @param x defines the x coordinate of the origin (on-screen)
  96583. * @param y defines the y coordinate of the origin (on-screen)
  96584. * @param result defines the ray where to store the picking ray
  96585. * @param camera defines the camera to use for the picking
  96586. * @returns the current scene
  96587. */
  96588. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96589. /** Launch a ray to try to pick a mesh in the scene
  96590. * @param x position on screen
  96591. * @param y position on screen
  96592. * @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
  96593. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96594. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96595. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96596. * @returns a PickingInfo
  96597. */
  96598. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96599. /** Use the given ray to pick a mesh in the scene
  96600. * @param ray The ray to use to pick meshes
  96601. * @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
  96602. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96603. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96604. * @returns a PickingInfo
  96605. */
  96606. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96607. /**
  96608. * Launch a ray to try to pick a mesh in the scene
  96609. * @param x X position on screen
  96610. * @param y Y position on screen
  96611. * @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
  96612. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96613. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96614. * @returns an array of PickingInfo
  96615. */
  96616. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96617. /**
  96618. * Launch a ray to try to pick a mesh in the scene
  96619. * @param ray Ray to use
  96620. * @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
  96621. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96622. * @returns an array of PickingInfo
  96623. */
  96624. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96625. /**
  96626. * Force the value of meshUnderPointer
  96627. * @param mesh defines the mesh to use
  96628. */
  96629. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96630. /**
  96631. * Gets the mesh under the pointer
  96632. * @returns a Mesh or null if no mesh is under the pointer
  96633. */
  96634. getPointerOverMesh(): Nullable<AbstractMesh>;
  96635. /** @hidden */
  96636. _rebuildGeometries(): void;
  96637. /** @hidden */
  96638. _rebuildTextures(): void;
  96639. private _getByTags;
  96640. /**
  96641. * Get a list of meshes by tags
  96642. * @param tagsQuery defines the tags query to use
  96643. * @param forEach defines a predicate used to filter results
  96644. * @returns an array of Mesh
  96645. */
  96646. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96647. /**
  96648. * Get a list of cameras by tags
  96649. * @param tagsQuery defines the tags query to use
  96650. * @param forEach defines a predicate used to filter results
  96651. * @returns an array of Camera
  96652. */
  96653. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96654. /**
  96655. * Get a list of lights by tags
  96656. * @param tagsQuery defines the tags query to use
  96657. * @param forEach defines a predicate used to filter results
  96658. * @returns an array of Light
  96659. */
  96660. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96661. /**
  96662. * Get a list of materials by tags
  96663. * @param tagsQuery defines the tags query to use
  96664. * @param forEach defines a predicate used to filter results
  96665. * @returns an array of Material
  96666. */
  96667. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96668. /**
  96669. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96670. * This allowed control for front to back rendering or reversly depending of the special needs.
  96671. *
  96672. * @param renderingGroupId The rendering group id corresponding to its index
  96673. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96674. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96675. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96676. */
  96677. 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;
  96678. /**
  96679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96680. *
  96681. * @param renderingGroupId The rendering group id corresponding to its index
  96682. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96683. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96684. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96685. */
  96686. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96687. /**
  96688. * Gets the current auto clear configuration for one rendering group of the rendering
  96689. * manager.
  96690. * @param index the rendering group index to get the information for
  96691. * @returns The auto clear setup for the requested rendering group
  96692. */
  96693. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96694. private _blockMaterialDirtyMechanism;
  96695. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96696. blockMaterialDirtyMechanism: boolean;
  96697. /**
  96698. * Will flag all materials as dirty to trigger new shader compilation
  96699. * @param flag defines the flag used to specify which material part must be marked as dirty
  96700. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96701. */
  96702. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96703. /** @hidden */
  96704. _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;
  96705. /** @hidden */
  96706. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96707. }
  96708. }
  96709. declare module BABYLON {
  96710. /**
  96711. * Set of assets to keep when moving a scene into an asset container.
  96712. */
  96713. export class KeepAssets extends AbstractScene {
  96714. }
  96715. /**
  96716. * Container with a set of assets that can be added or removed from a scene.
  96717. */
  96718. export class AssetContainer extends AbstractScene {
  96719. /**
  96720. * The scene the AssetContainer belongs to.
  96721. */
  96722. scene: Scene;
  96723. /**
  96724. * Instantiates an AssetContainer.
  96725. * @param scene The scene the AssetContainer belongs to.
  96726. */
  96727. constructor(scene: Scene);
  96728. /**
  96729. * Adds all the assets from the container to the scene.
  96730. */
  96731. addAllToScene(): void;
  96732. /**
  96733. * Removes all the assets in the container from the scene
  96734. */
  96735. removeAllFromScene(): void;
  96736. /**
  96737. * Disposes all the assets in the container
  96738. */
  96739. dispose(): void;
  96740. private _moveAssets;
  96741. /**
  96742. * Removes all the assets contained in the scene and adds them to the container.
  96743. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96744. */
  96745. moveAllFromScene(keepAssets?: KeepAssets): void;
  96746. /**
  96747. * 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.
  96748. * @returns the root mesh
  96749. */
  96750. createRootMesh(): Mesh;
  96751. }
  96752. }
  96753. declare module BABYLON {
  96754. /**
  96755. * Defines how the parser contract is defined.
  96756. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96757. */
  96758. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96759. /**
  96760. * Defines how the individual parser contract is defined.
  96761. * These parser can parse an individual asset
  96762. */
  96763. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96764. /**
  96765. * Base class of the scene acting as a container for the different elements composing a scene.
  96766. * This class is dynamically extended by the different components of the scene increasing
  96767. * flexibility and reducing coupling
  96768. */
  96769. export abstract class AbstractScene {
  96770. /**
  96771. * Stores the list of available parsers in the application.
  96772. */
  96773. private static _BabylonFileParsers;
  96774. /**
  96775. * Stores the list of available individual parsers in the application.
  96776. */
  96777. private static _IndividualBabylonFileParsers;
  96778. /**
  96779. * Adds a parser in the list of available ones
  96780. * @param name Defines the name of the parser
  96781. * @param parser Defines the parser to add
  96782. */
  96783. static AddParser(name: string, parser: BabylonFileParser): void;
  96784. /**
  96785. * Gets a general parser from the list of avaialble ones
  96786. * @param name Defines the name of the parser
  96787. * @returns the requested parser or null
  96788. */
  96789. static GetParser(name: string): Nullable<BabylonFileParser>;
  96790. /**
  96791. * Adds n individual parser in the list of available ones
  96792. * @param name Defines the name of the parser
  96793. * @param parser Defines the parser to add
  96794. */
  96795. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96796. /**
  96797. * Gets an individual parser from the list of avaialble ones
  96798. * @param name Defines the name of the parser
  96799. * @returns the requested parser or null
  96800. */
  96801. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96802. /**
  96803. * Parser json data and populate both a scene and its associated container object
  96804. * @param jsonData Defines the data to parse
  96805. * @param scene Defines the scene to parse the data for
  96806. * @param container Defines the container attached to the parsing sequence
  96807. * @param rootUrl Defines the root url of the data
  96808. */
  96809. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96810. /**
  96811. * Gets the list of root nodes (ie. nodes with no parent)
  96812. */
  96813. rootNodes: Node[];
  96814. /** All of the cameras added to this scene
  96815. * @see http://doc.babylonjs.com/babylon101/cameras
  96816. */
  96817. cameras: Camera[];
  96818. /**
  96819. * All of the lights added to this scene
  96820. * @see http://doc.babylonjs.com/babylon101/lights
  96821. */
  96822. lights: Light[];
  96823. /**
  96824. * All of the (abstract) meshes added to this scene
  96825. */
  96826. meshes: AbstractMesh[];
  96827. /**
  96828. * The list of skeletons added to the scene
  96829. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96830. */
  96831. skeletons: Skeleton[];
  96832. /**
  96833. * All of the particle systems added to this scene
  96834. * @see http://doc.babylonjs.com/babylon101/particles
  96835. */
  96836. particleSystems: IParticleSystem[];
  96837. /**
  96838. * Gets a list of Animations associated with the scene
  96839. */
  96840. animations: Animation[];
  96841. /**
  96842. * All of the animation groups added to this scene
  96843. * @see http://doc.babylonjs.com/how_to/group
  96844. */
  96845. animationGroups: AnimationGroup[];
  96846. /**
  96847. * All of the multi-materials added to this scene
  96848. * @see http://doc.babylonjs.com/how_to/multi_materials
  96849. */
  96850. multiMaterials: MultiMaterial[];
  96851. /**
  96852. * All of the materials added to this scene
  96853. * In the context of a Scene, it is not supposed to be modified manually.
  96854. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96855. * Note also that the order of the Material wihin the array is not significant and might change.
  96856. * @see http://doc.babylonjs.com/babylon101/materials
  96857. */
  96858. materials: Material[];
  96859. /**
  96860. * The list of morph target managers added to the scene
  96861. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96862. */
  96863. morphTargetManagers: MorphTargetManager[];
  96864. /**
  96865. * The list of geometries used in the scene.
  96866. */
  96867. geometries: Geometry[];
  96868. /**
  96869. * All of the tranform nodes added to this scene
  96870. * In the context of a Scene, it is not supposed to be modified manually.
  96871. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96872. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96873. * @see http://doc.babylonjs.com/how_to/transformnode
  96874. */
  96875. transformNodes: TransformNode[];
  96876. /**
  96877. * ActionManagers available on the scene.
  96878. */
  96879. actionManagers: AbstractActionManager[];
  96880. /**
  96881. * Textures to keep.
  96882. */
  96883. textures: BaseTexture[];
  96884. /**
  96885. * Environment texture for the scene
  96886. */
  96887. environmentTexture: Nullable<BaseTexture>;
  96888. }
  96889. }
  96890. declare module BABYLON {
  96891. /**
  96892. * Interface used to define options for Sound class
  96893. */
  96894. export interface ISoundOptions {
  96895. /**
  96896. * Does the sound autoplay once loaded.
  96897. */
  96898. autoplay?: boolean;
  96899. /**
  96900. * Does the sound loop after it finishes playing once.
  96901. */
  96902. loop?: boolean;
  96903. /**
  96904. * Sound's volume
  96905. */
  96906. volume?: number;
  96907. /**
  96908. * Is it a spatial sound?
  96909. */
  96910. spatialSound?: boolean;
  96911. /**
  96912. * Maximum distance to hear that sound
  96913. */
  96914. maxDistance?: number;
  96915. /**
  96916. * Uses user defined attenuation function
  96917. */
  96918. useCustomAttenuation?: boolean;
  96919. /**
  96920. * Define the roll off factor of spatial sounds.
  96921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96922. */
  96923. rolloffFactor?: number;
  96924. /**
  96925. * Define the reference distance the sound should be heard perfectly.
  96926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96927. */
  96928. refDistance?: number;
  96929. /**
  96930. * Define the distance attenuation model the sound will follow.
  96931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96932. */
  96933. distanceModel?: string;
  96934. /**
  96935. * Defines the playback speed (1 by default)
  96936. */
  96937. playbackRate?: number;
  96938. /**
  96939. * Defines if the sound is from a streaming source
  96940. */
  96941. streaming?: boolean;
  96942. /**
  96943. * Defines an optional length (in seconds) inside the sound file
  96944. */
  96945. length?: number;
  96946. /**
  96947. * Defines an optional offset (in seconds) inside the sound file
  96948. */
  96949. offset?: number;
  96950. /**
  96951. * If true, URLs will not be required to state the audio file codec to use.
  96952. */
  96953. skipCodecCheck?: boolean;
  96954. }
  96955. /**
  96956. * Defines a sound that can be played in the application.
  96957. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96959. */
  96960. export class Sound {
  96961. /**
  96962. * The name of the sound in the scene.
  96963. */
  96964. name: string;
  96965. /**
  96966. * Does the sound autoplay once loaded.
  96967. */
  96968. autoplay: boolean;
  96969. /**
  96970. * Does the sound loop after it finishes playing once.
  96971. */
  96972. loop: boolean;
  96973. /**
  96974. * Does the sound use a custom attenuation curve to simulate the falloff
  96975. * happening when the source gets further away from the camera.
  96976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96977. */
  96978. useCustomAttenuation: boolean;
  96979. /**
  96980. * The sound track id this sound belongs to.
  96981. */
  96982. soundTrackId: number;
  96983. /**
  96984. * Is this sound currently played.
  96985. */
  96986. isPlaying: boolean;
  96987. /**
  96988. * Is this sound currently paused.
  96989. */
  96990. isPaused: boolean;
  96991. /**
  96992. * Does this sound enables spatial sound.
  96993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96994. */
  96995. spatialSound: boolean;
  96996. /**
  96997. * Define the reference distance the sound should be heard perfectly.
  96998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96999. */
  97000. refDistance: number;
  97001. /**
  97002. * Define the roll off factor of spatial sounds.
  97003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97004. */
  97005. rolloffFactor: number;
  97006. /**
  97007. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97009. */
  97010. maxDistance: number;
  97011. /**
  97012. * Define the distance attenuation model the sound will follow.
  97013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97014. */
  97015. distanceModel: string;
  97016. /**
  97017. * @hidden
  97018. * Back Compat
  97019. **/
  97020. onended: () => any;
  97021. /**
  97022. * Observable event when the current playing sound finishes.
  97023. */
  97024. onEndedObservable: Observable<Sound>;
  97025. private _panningModel;
  97026. private _playbackRate;
  97027. private _streaming;
  97028. private _startTime;
  97029. private _startOffset;
  97030. private _position;
  97031. /** @hidden */
  97032. _positionInEmitterSpace: boolean;
  97033. private _localDirection;
  97034. private _volume;
  97035. private _isReadyToPlay;
  97036. private _isDirectional;
  97037. private _readyToPlayCallback;
  97038. private _audioBuffer;
  97039. private _soundSource;
  97040. private _streamingSource;
  97041. private _soundPanner;
  97042. private _soundGain;
  97043. private _inputAudioNode;
  97044. private _outputAudioNode;
  97045. private _coneInnerAngle;
  97046. private _coneOuterAngle;
  97047. private _coneOuterGain;
  97048. private _scene;
  97049. private _connectedTransformNode;
  97050. private _customAttenuationFunction;
  97051. private _registerFunc;
  97052. private _isOutputConnected;
  97053. private _htmlAudioElement;
  97054. private _urlType;
  97055. private _length?;
  97056. private _offset?;
  97057. /** @hidden */
  97058. static _SceneComponentInitialization: (scene: Scene) => void;
  97059. /**
  97060. * Create a sound and attach it to a scene
  97061. * @param name Name of your sound
  97062. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97063. * @param scene defines the scene the sound belongs to
  97064. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97065. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97066. */
  97067. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97068. /**
  97069. * Release the sound and its associated resources
  97070. */
  97071. dispose(): void;
  97072. /**
  97073. * Gets if the sounds is ready to be played or not.
  97074. * @returns true if ready, otherwise false
  97075. */
  97076. isReady(): boolean;
  97077. private _soundLoaded;
  97078. /**
  97079. * Sets the data of the sound from an audiobuffer
  97080. * @param audioBuffer The audioBuffer containing the data
  97081. */
  97082. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97083. /**
  97084. * Updates the current sounds options such as maxdistance, loop...
  97085. * @param options A JSON object containing values named as the object properties
  97086. */
  97087. updateOptions(options: ISoundOptions): void;
  97088. private _createSpatialParameters;
  97089. private _updateSpatialParameters;
  97090. /**
  97091. * Switch the panning model to HRTF:
  97092. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97094. */
  97095. switchPanningModelToHRTF(): void;
  97096. /**
  97097. * Switch the panning model to Equal Power:
  97098. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97100. */
  97101. switchPanningModelToEqualPower(): void;
  97102. private _switchPanningModel;
  97103. /**
  97104. * Connect this sound to a sound track audio node like gain...
  97105. * @param soundTrackAudioNode the sound track audio node to connect to
  97106. */
  97107. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97108. /**
  97109. * Transform this sound into a directional source
  97110. * @param coneInnerAngle Size of the inner cone in degree
  97111. * @param coneOuterAngle Size of the outer cone in degree
  97112. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97113. */
  97114. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97115. /**
  97116. * Gets or sets the inner angle for the directional cone.
  97117. */
  97118. /**
  97119. * Gets or sets the inner angle for the directional cone.
  97120. */
  97121. directionalConeInnerAngle: number;
  97122. /**
  97123. * Gets or sets the outer angle for the directional cone.
  97124. */
  97125. /**
  97126. * Gets or sets the outer angle for the directional cone.
  97127. */
  97128. directionalConeOuterAngle: number;
  97129. /**
  97130. * Sets the position of the emitter if spatial sound is enabled
  97131. * @param newPosition Defines the new posisiton
  97132. */
  97133. setPosition(newPosition: Vector3): void;
  97134. /**
  97135. * Sets the local direction of the emitter if spatial sound is enabled
  97136. * @param newLocalDirection Defines the new local direction
  97137. */
  97138. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97139. private _updateDirection;
  97140. /** @hidden */
  97141. updateDistanceFromListener(): void;
  97142. /**
  97143. * Sets a new custom attenuation function for the sound.
  97144. * @param callback Defines the function used for the attenuation
  97145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97146. */
  97147. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97148. /**
  97149. * Play the sound
  97150. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97151. * @param offset (optional) Start the sound at a specific time in seconds
  97152. * @param length (optional) Sound duration (in seconds)
  97153. */
  97154. play(time?: number, offset?: number, length?: number): void;
  97155. private _onended;
  97156. /**
  97157. * Stop the sound
  97158. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97159. */
  97160. stop(time?: number): void;
  97161. /**
  97162. * Put the sound in pause
  97163. */
  97164. pause(): void;
  97165. /**
  97166. * Sets a dedicated volume for this sounds
  97167. * @param newVolume Define the new volume of the sound
  97168. * @param time Define time for gradual change to new volume
  97169. */
  97170. setVolume(newVolume: number, time?: number): void;
  97171. /**
  97172. * Set the sound play back rate
  97173. * @param newPlaybackRate Define the playback rate the sound should be played at
  97174. */
  97175. setPlaybackRate(newPlaybackRate: number): void;
  97176. /**
  97177. * Gets the volume of the sound.
  97178. * @returns the volume of the sound
  97179. */
  97180. getVolume(): number;
  97181. /**
  97182. * Attach the sound to a dedicated mesh
  97183. * @param transformNode The transform node to connect the sound with
  97184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97185. */
  97186. attachToMesh(transformNode: TransformNode): void;
  97187. /**
  97188. * Detach the sound from the previously attached mesh
  97189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97190. */
  97191. detachFromMesh(): void;
  97192. private _onRegisterAfterWorldMatrixUpdate;
  97193. /**
  97194. * Clone the current sound in the scene.
  97195. * @returns the new sound clone
  97196. */
  97197. clone(): Nullable<Sound>;
  97198. /**
  97199. * Gets the current underlying audio buffer containing the data
  97200. * @returns the audio buffer
  97201. */
  97202. getAudioBuffer(): Nullable<AudioBuffer>;
  97203. /**
  97204. * Serializes the Sound in a JSON representation
  97205. * @returns the JSON representation of the sound
  97206. */
  97207. serialize(): any;
  97208. /**
  97209. * Parse a JSON representation of a sound to innstantiate in a given scene
  97210. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97211. * @param scene Define the scene the new parsed sound should be created in
  97212. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97213. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97214. * @returns the newly parsed sound
  97215. */
  97216. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97217. }
  97218. }
  97219. declare module BABYLON {
  97220. /**
  97221. * This defines an action helpful to play a defined sound on a triggered action.
  97222. */
  97223. export class PlaySoundAction extends Action {
  97224. private _sound;
  97225. /**
  97226. * Instantiate the action
  97227. * @param triggerOptions defines the trigger options
  97228. * @param sound defines the sound to play
  97229. * @param condition defines the trigger related conditions
  97230. */
  97231. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97232. /** @hidden */
  97233. _prepare(): void;
  97234. /**
  97235. * Execute the action and play the sound.
  97236. */
  97237. execute(): void;
  97238. /**
  97239. * Serializes the actions and its related information.
  97240. * @param parent defines the object to serialize in
  97241. * @returns the serialized object
  97242. */
  97243. serialize(parent: any): any;
  97244. }
  97245. /**
  97246. * This defines an action helpful to stop a defined sound on a triggered action.
  97247. */
  97248. export class StopSoundAction extends Action {
  97249. private _sound;
  97250. /**
  97251. * Instantiate the action
  97252. * @param triggerOptions defines the trigger options
  97253. * @param sound defines the sound to stop
  97254. * @param condition defines the trigger related conditions
  97255. */
  97256. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97257. /** @hidden */
  97258. _prepare(): void;
  97259. /**
  97260. * Execute the action and stop the sound.
  97261. */
  97262. execute(): void;
  97263. /**
  97264. * Serializes the actions and its related information.
  97265. * @param parent defines the object to serialize in
  97266. * @returns the serialized object
  97267. */
  97268. serialize(parent: any): any;
  97269. }
  97270. }
  97271. declare module BABYLON {
  97272. /**
  97273. * This defines an action responsible to change the value of a property
  97274. * by interpolating between its current value and the newly set one once triggered.
  97275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97276. */
  97277. export class InterpolateValueAction extends Action {
  97278. /**
  97279. * Defines the path of the property where the value should be interpolated
  97280. */
  97281. propertyPath: string;
  97282. /**
  97283. * Defines the target value at the end of the interpolation.
  97284. */
  97285. value: any;
  97286. /**
  97287. * Defines the time it will take for the property to interpolate to the value.
  97288. */
  97289. duration: number;
  97290. /**
  97291. * Defines if the other scene animations should be stopped when the action has been triggered
  97292. */
  97293. stopOtherAnimations?: boolean;
  97294. /**
  97295. * Defines a callback raised once the interpolation animation has been done.
  97296. */
  97297. onInterpolationDone?: () => void;
  97298. /**
  97299. * Observable triggered once the interpolation animation has been done.
  97300. */
  97301. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97302. private _target;
  97303. private _effectiveTarget;
  97304. private _property;
  97305. /**
  97306. * Instantiate the action
  97307. * @param triggerOptions defines the trigger options
  97308. * @param target defines the object containing the value to interpolate
  97309. * @param propertyPath defines the path to the property in the target object
  97310. * @param value defines the target value at the end of the interpolation
  97311. * @param duration deines the time it will take for the property to interpolate to the value.
  97312. * @param condition defines the trigger related conditions
  97313. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97314. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97315. */
  97316. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97317. /** @hidden */
  97318. _prepare(): void;
  97319. /**
  97320. * Execute the action starts the value interpolation.
  97321. */
  97322. execute(): void;
  97323. /**
  97324. * Serializes the actions and its related information.
  97325. * @param parent defines the object to serialize in
  97326. * @returns the serialized object
  97327. */
  97328. serialize(parent: any): any;
  97329. }
  97330. }
  97331. declare module BABYLON {
  97332. /**
  97333. * Options allowed during the creation of a sound track.
  97334. */
  97335. export interface ISoundTrackOptions {
  97336. /**
  97337. * The volume the sound track should take during creation
  97338. */
  97339. volume?: number;
  97340. /**
  97341. * Define if the sound track is the main sound track of the scene
  97342. */
  97343. mainTrack?: boolean;
  97344. }
  97345. /**
  97346. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97347. * It will be also used in a future release to apply effects on a specific track.
  97348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97349. */
  97350. export class SoundTrack {
  97351. /**
  97352. * The unique identifier of the sound track in the scene.
  97353. */
  97354. id: number;
  97355. /**
  97356. * The list of sounds included in the sound track.
  97357. */
  97358. soundCollection: Array<Sound>;
  97359. private _outputAudioNode;
  97360. private _scene;
  97361. private _isMainTrack;
  97362. private _connectedAnalyser;
  97363. private _options;
  97364. private _isInitialized;
  97365. /**
  97366. * Creates a new sound track.
  97367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97368. * @param scene Define the scene the sound track belongs to
  97369. * @param options
  97370. */
  97371. constructor(scene: Scene, options?: ISoundTrackOptions);
  97372. private _initializeSoundTrackAudioGraph;
  97373. /**
  97374. * Release the sound track and its associated resources
  97375. */
  97376. dispose(): void;
  97377. /**
  97378. * Adds a sound to this sound track
  97379. * @param sound define the cound to add
  97380. * @ignoreNaming
  97381. */
  97382. AddSound(sound: Sound): void;
  97383. /**
  97384. * Removes a sound to this sound track
  97385. * @param sound define the cound to remove
  97386. * @ignoreNaming
  97387. */
  97388. RemoveSound(sound: Sound): void;
  97389. /**
  97390. * Set a global volume for the full sound track.
  97391. * @param newVolume Define the new volume of the sound track
  97392. */
  97393. setVolume(newVolume: number): void;
  97394. /**
  97395. * Switch the panning model to HRTF:
  97396. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97398. */
  97399. switchPanningModelToHRTF(): void;
  97400. /**
  97401. * Switch the panning model to Equal Power:
  97402. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97404. */
  97405. switchPanningModelToEqualPower(): void;
  97406. /**
  97407. * Connect the sound track to an audio analyser allowing some amazing
  97408. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97410. * @param analyser The analyser to connect to the engine
  97411. */
  97412. connectToAnalyser(analyser: Analyser): void;
  97413. }
  97414. }
  97415. declare module BABYLON {
  97416. interface AbstractScene {
  97417. /**
  97418. * The list of sounds used in the scene.
  97419. */
  97420. sounds: Nullable<Array<Sound>>;
  97421. }
  97422. interface Scene {
  97423. /**
  97424. * @hidden
  97425. * Backing field
  97426. */
  97427. _mainSoundTrack: SoundTrack;
  97428. /**
  97429. * The main sound track played by the scene.
  97430. * It cotains your primary collection of sounds.
  97431. */
  97432. mainSoundTrack: SoundTrack;
  97433. /**
  97434. * The list of sound tracks added to the scene
  97435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97436. */
  97437. soundTracks: Nullable<Array<SoundTrack>>;
  97438. /**
  97439. * Gets a sound using a given name
  97440. * @param name defines the name to search for
  97441. * @return the found sound or null if not found at all.
  97442. */
  97443. getSoundByName(name: string): Nullable<Sound>;
  97444. /**
  97445. * Gets or sets if audio support is enabled
  97446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97447. */
  97448. audioEnabled: boolean;
  97449. /**
  97450. * Gets or sets if audio will be output to headphones
  97451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97452. */
  97453. headphone: boolean;
  97454. }
  97455. /**
  97456. * Defines the sound scene component responsible to manage any sounds
  97457. * in a given scene.
  97458. */
  97459. export class AudioSceneComponent implements ISceneSerializableComponent {
  97460. /**
  97461. * The component name helpfull to identify the component in the list of scene components.
  97462. */
  97463. readonly name: string;
  97464. /**
  97465. * The scene the component belongs to.
  97466. */
  97467. scene: Scene;
  97468. private _audioEnabled;
  97469. /**
  97470. * Gets whether audio is enabled or not.
  97471. * Please use related enable/disable method to switch state.
  97472. */
  97473. readonly audioEnabled: boolean;
  97474. private _headphone;
  97475. /**
  97476. * Gets whether audio is outputing to headphone or not.
  97477. * Please use the according Switch methods to change output.
  97478. */
  97479. readonly headphone: boolean;
  97480. /**
  97481. * Creates a new instance of the component for the given scene
  97482. * @param scene Defines the scene to register the component in
  97483. */
  97484. constructor(scene: Scene);
  97485. /**
  97486. * Registers the component in a given scene
  97487. */
  97488. register(): void;
  97489. /**
  97490. * Rebuilds the elements related to this component in case of
  97491. * context lost for instance.
  97492. */
  97493. rebuild(): void;
  97494. /**
  97495. * Serializes the component data to the specified json object
  97496. * @param serializationObject The object to serialize to
  97497. */
  97498. serialize(serializationObject: any): void;
  97499. /**
  97500. * Adds all the elements from the container to the scene
  97501. * @param container the container holding the elements
  97502. */
  97503. addFromContainer(container: AbstractScene): void;
  97504. /**
  97505. * Removes all the elements in the container from the scene
  97506. * @param container contains the elements to remove
  97507. * @param dispose if the removed element should be disposed (default: false)
  97508. */
  97509. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97510. /**
  97511. * Disposes the component and the associated ressources.
  97512. */
  97513. dispose(): void;
  97514. /**
  97515. * Disables audio in the associated scene.
  97516. */
  97517. disableAudio(): void;
  97518. /**
  97519. * Enables audio in the associated scene.
  97520. */
  97521. enableAudio(): void;
  97522. /**
  97523. * Switch audio to headphone output.
  97524. */
  97525. switchAudioModeForHeadphones(): void;
  97526. /**
  97527. * Switch audio to normal speakers.
  97528. */
  97529. switchAudioModeForNormalSpeakers(): void;
  97530. private _afterRender;
  97531. }
  97532. }
  97533. declare module BABYLON {
  97534. /**
  97535. * Wraps one or more Sound objects and selects one with random weight for playback.
  97536. */
  97537. export class WeightedSound {
  97538. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97539. loop: boolean;
  97540. private _coneInnerAngle;
  97541. private _coneOuterAngle;
  97542. private _volume;
  97543. /** A Sound is currently playing. */
  97544. isPlaying: boolean;
  97545. /** A Sound is currently paused. */
  97546. isPaused: boolean;
  97547. private _sounds;
  97548. private _weights;
  97549. private _currentIndex?;
  97550. /**
  97551. * Creates a new WeightedSound from the list of sounds given.
  97552. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97553. * @param sounds Array of Sounds that will be selected from.
  97554. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97555. */
  97556. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97557. /**
  97558. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97559. */
  97560. /**
  97561. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97562. */
  97563. directionalConeInnerAngle: number;
  97564. /**
  97565. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97566. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97567. */
  97568. /**
  97569. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97570. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97571. */
  97572. directionalConeOuterAngle: number;
  97573. /**
  97574. * Playback volume.
  97575. */
  97576. /**
  97577. * Playback volume.
  97578. */
  97579. volume: number;
  97580. private _onended;
  97581. /**
  97582. * Suspend playback
  97583. */
  97584. pause(): void;
  97585. /**
  97586. * Stop playback
  97587. */
  97588. stop(): void;
  97589. /**
  97590. * Start playback.
  97591. * @param startOffset Position the clip head at a specific time in seconds.
  97592. */
  97593. play(startOffset?: number): void;
  97594. }
  97595. }
  97596. declare module BABYLON {
  97597. /**
  97598. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97600. */
  97601. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97602. /**
  97603. * Gets the name of the behavior.
  97604. */
  97605. readonly name: string;
  97606. /**
  97607. * The easing function used by animations
  97608. */
  97609. static EasingFunction: BackEase;
  97610. /**
  97611. * The easing mode used by animations
  97612. */
  97613. static EasingMode: number;
  97614. /**
  97615. * The duration of the animation, in milliseconds
  97616. */
  97617. transitionDuration: number;
  97618. /**
  97619. * Length of the distance animated by the transition when lower radius is reached
  97620. */
  97621. lowerRadiusTransitionRange: number;
  97622. /**
  97623. * Length of the distance animated by the transition when upper radius is reached
  97624. */
  97625. upperRadiusTransitionRange: number;
  97626. private _autoTransitionRange;
  97627. /**
  97628. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97629. */
  97630. /**
  97631. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97632. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97633. */
  97634. autoTransitionRange: boolean;
  97635. private _attachedCamera;
  97636. private _onAfterCheckInputsObserver;
  97637. private _onMeshTargetChangedObserver;
  97638. /**
  97639. * Initializes the behavior.
  97640. */
  97641. init(): void;
  97642. /**
  97643. * Attaches the behavior to its arc rotate camera.
  97644. * @param camera Defines the camera to attach the behavior to
  97645. */
  97646. attach(camera: ArcRotateCamera): void;
  97647. /**
  97648. * Detaches the behavior from its current arc rotate camera.
  97649. */
  97650. detach(): void;
  97651. private _radiusIsAnimating;
  97652. private _radiusBounceTransition;
  97653. private _animatables;
  97654. private _cachedWheelPrecision;
  97655. /**
  97656. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97657. * @param radiusLimit The limit to check against.
  97658. * @return Bool to indicate if at limit.
  97659. */
  97660. private _isRadiusAtLimit;
  97661. /**
  97662. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97663. * @param radiusDelta The delta by which to animate to. Can be negative.
  97664. */
  97665. private _applyBoundRadiusAnimation;
  97666. /**
  97667. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97668. */
  97669. protected _clearAnimationLocks(): void;
  97670. /**
  97671. * Stops and removes all animations that have been applied to the camera
  97672. */
  97673. stopAllAnimations(): void;
  97674. }
  97675. }
  97676. declare module BABYLON {
  97677. /**
  97678. * 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.
  97679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97680. */
  97681. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97682. /**
  97683. * Gets the name of the behavior.
  97684. */
  97685. readonly name: string;
  97686. private _mode;
  97687. private _radiusScale;
  97688. private _positionScale;
  97689. private _defaultElevation;
  97690. private _elevationReturnTime;
  97691. private _elevationReturnWaitTime;
  97692. private _zoomStopsAnimation;
  97693. private _framingTime;
  97694. /**
  97695. * The easing function used by animations
  97696. */
  97697. static EasingFunction: ExponentialEase;
  97698. /**
  97699. * The easing mode used by animations
  97700. */
  97701. static EasingMode: number;
  97702. /**
  97703. * Sets the current mode used by the behavior
  97704. */
  97705. /**
  97706. * Gets current mode used by the behavior.
  97707. */
  97708. mode: number;
  97709. /**
  97710. * Sets the scale applied to the radius (1 by default)
  97711. */
  97712. /**
  97713. * Gets the scale applied to the radius
  97714. */
  97715. radiusScale: number;
  97716. /**
  97717. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97718. */
  97719. /**
  97720. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97721. */
  97722. positionScale: number;
  97723. /**
  97724. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97725. * behaviour is triggered, in radians.
  97726. */
  97727. /**
  97728. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97729. * behaviour is triggered, in radians.
  97730. */
  97731. defaultElevation: number;
  97732. /**
  97733. * Sets the time (in milliseconds) taken to return to the default beta position.
  97734. * Negative value indicates camera should not return to default.
  97735. */
  97736. /**
  97737. * Gets the time (in milliseconds) taken to return to the default beta position.
  97738. * Negative value indicates camera should not return to default.
  97739. */
  97740. elevationReturnTime: number;
  97741. /**
  97742. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97743. */
  97744. /**
  97745. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97746. */
  97747. elevationReturnWaitTime: number;
  97748. /**
  97749. * Sets the flag that indicates if user zooming should stop animation.
  97750. */
  97751. /**
  97752. * Gets the flag that indicates if user zooming should stop animation.
  97753. */
  97754. zoomStopsAnimation: boolean;
  97755. /**
  97756. * Sets the transition time when framing the mesh, in milliseconds
  97757. */
  97758. /**
  97759. * Gets the transition time when framing the mesh, in milliseconds
  97760. */
  97761. framingTime: number;
  97762. /**
  97763. * Define if the behavior should automatically change the configured
  97764. * camera limits and sensibilities.
  97765. */
  97766. autoCorrectCameraLimitsAndSensibility: boolean;
  97767. private _onPrePointerObservableObserver;
  97768. private _onAfterCheckInputsObserver;
  97769. private _onMeshTargetChangedObserver;
  97770. private _attachedCamera;
  97771. private _isPointerDown;
  97772. private _lastInteractionTime;
  97773. /**
  97774. * Initializes the behavior.
  97775. */
  97776. init(): void;
  97777. /**
  97778. * Attaches the behavior to its arc rotate camera.
  97779. * @param camera Defines the camera to attach the behavior to
  97780. */
  97781. attach(camera: ArcRotateCamera): void;
  97782. /**
  97783. * Detaches the behavior from its current arc rotate camera.
  97784. */
  97785. detach(): void;
  97786. private _animatables;
  97787. private _betaIsAnimating;
  97788. private _betaTransition;
  97789. private _radiusTransition;
  97790. private _vectorTransition;
  97791. /**
  97792. * Targets the given mesh and updates zoom level accordingly.
  97793. * @param mesh The mesh to target.
  97794. * @param radius Optional. If a cached radius position already exists, overrides default.
  97795. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97796. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97797. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97798. */
  97799. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97800. /**
  97801. * Targets the given mesh with its children and updates zoom level accordingly.
  97802. * @param mesh The mesh to target.
  97803. * @param radius Optional. If a cached radius position already exists, overrides default.
  97804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97807. */
  97808. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97809. /**
  97810. * Targets the given meshes with their children and updates zoom level accordingly.
  97811. * @param meshes The mesh to target.
  97812. * @param radius Optional. If a cached radius position already exists, overrides default.
  97813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97816. */
  97817. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97818. /**
  97819. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97820. * @param minimumWorld Determines the smaller position of the bounding box extend
  97821. * @param maximumWorld Determines the bigger position of the bounding box extend
  97822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97824. */
  97825. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97826. /**
  97827. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97828. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97829. * frustum width.
  97830. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97831. * to fully enclose the mesh in the viewing frustum.
  97832. */
  97833. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97834. /**
  97835. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97836. * is automatically returned to its default position (expected to be above ground plane).
  97837. */
  97838. private _maintainCameraAboveGround;
  97839. /**
  97840. * Returns the frustum slope based on the canvas ratio and camera FOV
  97841. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97842. */
  97843. private _getFrustumSlope;
  97844. /**
  97845. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97846. */
  97847. private _clearAnimationLocks;
  97848. /**
  97849. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97850. */
  97851. private _applyUserInteraction;
  97852. /**
  97853. * Stops and removes all animations that have been applied to the camera
  97854. */
  97855. stopAllAnimations(): void;
  97856. /**
  97857. * Gets a value indicating if the user is moving the camera
  97858. */
  97859. readonly isUserIsMoving: boolean;
  97860. /**
  97861. * The camera can move all the way towards the mesh.
  97862. */
  97863. static IgnoreBoundsSizeMode: number;
  97864. /**
  97865. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97866. */
  97867. static FitFrustumSidesMode: number;
  97868. }
  97869. }
  97870. declare module BABYLON {
  97871. /**
  97872. * Base class for Camera Pointer Inputs.
  97873. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97874. * for example usage.
  97875. */
  97876. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97877. /**
  97878. * Defines the camera the input is attached to.
  97879. */
  97880. abstract camera: Camera;
  97881. /**
  97882. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97883. */
  97884. protected _altKey: boolean;
  97885. protected _ctrlKey: boolean;
  97886. protected _metaKey: boolean;
  97887. protected _shiftKey: boolean;
  97888. /**
  97889. * Which mouse buttons were pressed at time of last mouse event.
  97890. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97891. */
  97892. protected _buttonsPressed: number;
  97893. /**
  97894. * Defines the buttons associated with the input to handle camera move.
  97895. */
  97896. buttons: number[];
  97897. /**
  97898. * Attach the input controls to a specific dom element to get the input from.
  97899. * @param element Defines the element the controls should be listened from
  97900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97901. */
  97902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97903. /**
  97904. * Detach the current controls from the specified dom element.
  97905. * @param element Defines the element to stop listening the inputs from
  97906. */
  97907. detachControl(element: Nullable<HTMLElement>): void;
  97908. /**
  97909. * Gets the class name of the current input.
  97910. * @returns the class name
  97911. */
  97912. getClassName(): string;
  97913. /**
  97914. * Get the friendly name associated with the input class.
  97915. * @returns the input friendly name
  97916. */
  97917. getSimpleName(): string;
  97918. /**
  97919. * Called on pointer POINTERDOUBLETAP event.
  97920. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97921. */
  97922. protected onDoubleTap(type: string): void;
  97923. /**
  97924. * Called on pointer POINTERMOVE event if only a single touch is active.
  97925. * Override this method to provide functionality.
  97926. */
  97927. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97928. /**
  97929. * Called on pointer POINTERMOVE event if multiple touches are active.
  97930. * Override this method to provide functionality.
  97931. */
  97932. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97933. /**
  97934. * Called on JS contextmenu event.
  97935. * Override this method to provide functionality.
  97936. */
  97937. protected onContextMenu(evt: PointerEvent): void;
  97938. /**
  97939. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97940. * press.
  97941. * Override this method to provide functionality.
  97942. */
  97943. protected onButtonDown(evt: PointerEvent): void;
  97944. /**
  97945. * Called each time a new POINTERUP event occurs. Ie, for each button
  97946. * release.
  97947. * Override this method to provide functionality.
  97948. */
  97949. protected onButtonUp(evt: PointerEvent): void;
  97950. /**
  97951. * Called when window becomes inactive.
  97952. * Override this method to provide functionality.
  97953. */
  97954. protected onLostFocus(): void;
  97955. private _pointerInput;
  97956. private _observer;
  97957. private _onLostFocus;
  97958. private pointA;
  97959. private pointB;
  97960. }
  97961. }
  97962. declare module BABYLON {
  97963. /**
  97964. * Manage the pointers inputs to control an arc rotate camera.
  97965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97966. */
  97967. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97968. /**
  97969. * Defines the camera the input is attached to.
  97970. */
  97971. camera: ArcRotateCamera;
  97972. /**
  97973. * Gets the class name of the current input.
  97974. * @returns the class name
  97975. */
  97976. getClassName(): string;
  97977. /**
  97978. * Defines the buttons associated with the input to handle camera move.
  97979. */
  97980. buttons: number[];
  97981. /**
  97982. * Defines the pointer angular sensibility along the X axis or how fast is
  97983. * the camera rotating.
  97984. */
  97985. angularSensibilityX: number;
  97986. /**
  97987. * Defines the pointer angular sensibility along the Y axis or how fast is
  97988. * the camera rotating.
  97989. */
  97990. angularSensibilityY: number;
  97991. /**
  97992. * Defines the pointer pinch precision or how fast is the camera zooming.
  97993. */
  97994. pinchPrecision: number;
  97995. /**
  97996. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97997. * from 0.
  97998. * It defines the percentage of current camera.radius to use as delta when
  97999. * pinch zoom is used.
  98000. */
  98001. pinchDeltaPercentage: number;
  98002. /**
  98003. * Defines the pointer panning sensibility or how fast is the camera moving.
  98004. */
  98005. panningSensibility: number;
  98006. /**
  98007. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98008. */
  98009. multiTouchPanning: boolean;
  98010. /**
  98011. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98012. * zoom (pinch) through multitouch.
  98013. */
  98014. multiTouchPanAndZoom: boolean;
  98015. /**
  98016. * Revers pinch action direction.
  98017. */
  98018. pinchInwards: boolean;
  98019. private _isPanClick;
  98020. private _twoFingerActivityCount;
  98021. private _isPinching;
  98022. /**
  98023. * Called on pointer POINTERMOVE event if only a single touch is active.
  98024. */
  98025. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98026. /**
  98027. * Called on pointer POINTERDOUBLETAP event.
  98028. */
  98029. protected onDoubleTap(type: string): void;
  98030. /**
  98031. * Called on pointer POINTERMOVE event if multiple touches are active.
  98032. */
  98033. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98034. /**
  98035. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98036. * press.
  98037. */
  98038. protected onButtonDown(evt: PointerEvent): void;
  98039. /**
  98040. * Called each time a new POINTERUP event occurs. Ie, for each button
  98041. * release.
  98042. */
  98043. protected onButtonUp(evt: PointerEvent): void;
  98044. /**
  98045. * Called when window becomes inactive.
  98046. */
  98047. protected onLostFocus(): void;
  98048. }
  98049. }
  98050. declare module BABYLON {
  98051. /**
  98052. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98054. */
  98055. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98056. /**
  98057. * Defines the camera the input is attached to.
  98058. */
  98059. camera: ArcRotateCamera;
  98060. /**
  98061. * Defines the list of key codes associated with the up action (increase alpha)
  98062. */
  98063. keysUp: number[];
  98064. /**
  98065. * Defines the list of key codes associated with the down action (decrease alpha)
  98066. */
  98067. keysDown: number[];
  98068. /**
  98069. * Defines the list of key codes associated with the left action (increase beta)
  98070. */
  98071. keysLeft: number[];
  98072. /**
  98073. * Defines the list of key codes associated with the right action (decrease beta)
  98074. */
  98075. keysRight: number[];
  98076. /**
  98077. * Defines the list of key codes associated with the reset action.
  98078. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98079. */
  98080. keysReset: number[];
  98081. /**
  98082. * Defines the panning sensibility of the inputs.
  98083. * (How fast is the camera paning)
  98084. */
  98085. panningSensibility: number;
  98086. /**
  98087. * Defines the zooming sensibility of the inputs.
  98088. * (How fast is the camera zooming)
  98089. */
  98090. zoomingSensibility: number;
  98091. /**
  98092. * Defines wether maintaining the alt key down switch the movement mode from
  98093. * orientation to zoom.
  98094. */
  98095. useAltToZoom: boolean;
  98096. /**
  98097. * Rotation speed of the camera
  98098. */
  98099. angularSpeed: number;
  98100. private _keys;
  98101. private _ctrlPressed;
  98102. private _altPressed;
  98103. private _onCanvasBlurObserver;
  98104. private _onKeyboardObserver;
  98105. private _engine;
  98106. private _scene;
  98107. /**
  98108. * Attach the input controls to a specific dom element to get the input from.
  98109. * @param element Defines the element the controls should be listened from
  98110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98111. */
  98112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98113. /**
  98114. * Detach the current controls from the specified dom element.
  98115. * @param element Defines the element to stop listening the inputs from
  98116. */
  98117. detachControl(element: Nullable<HTMLElement>): void;
  98118. /**
  98119. * Update the current camera state depending on the inputs that have been used this frame.
  98120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98121. */
  98122. checkInputs(): void;
  98123. /**
  98124. * Gets the class name of the current intput.
  98125. * @returns the class name
  98126. */
  98127. getClassName(): string;
  98128. /**
  98129. * Get the friendly name associated with the input class.
  98130. * @returns the input friendly name
  98131. */
  98132. getSimpleName(): string;
  98133. }
  98134. }
  98135. declare module BABYLON {
  98136. /**
  98137. * Manage the mouse wheel inputs to control an arc rotate camera.
  98138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98139. */
  98140. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98141. /**
  98142. * Defines the camera the input is attached to.
  98143. */
  98144. camera: ArcRotateCamera;
  98145. /**
  98146. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98147. */
  98148. wheelPrecision: number;
  98149. /**
  98150. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98151. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98152. */
  98153. wheelDeltaPercentage: number;
  98154. private _wheel;
  98155. private _observer;
  98156. private computeDeltaFromMouseWheelLegacyEvent;
  98157. /**
  98158. * Attach the input controls to a specific dom element to get the input from.
  98159. * @param element Defines the element the controls should be listened from
  98160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98161. */
  98162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98163. /**
  98164. * Detach the current controls from the specified dom element.
  98165. * @param element Defines the element to stop listening the inputs from
  98166. */
  98167. detachControl(element: Nullable<HTMLElement>): void;
  98168. /**
  98169. * Gets the class name of the current intput.
  98170. * @returns the class name
  98171. */
  98172. getClassName(): string;
  98173. /**
  98174. * Get the friendly name associated with the input class.
  98175. * @returns the input friendly name
  98176. */
  98177. getSimpleName(): string;
  98178. }
  98179. }
  98180. declare module BABYLON {
  98181. /**
  98182. * Default Inputs manager for the ArcRotateCamera.
  98183. * It groups all the default supported inputs for ease of use.
  98184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98185. */
  98186. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98187. /**
  98188. * Instantiates a new ArcRotateCameraInputsManager.
  98189. * @param camera Defines the camera the inputs belong to
  98190. */
  98191. constructor(camera: ArcRotateCamera);
  98192. /**
  98193. * Add mouse wheel input support to the input manager.
  98194. * @returns the current input manager
  98195. */
  98196. addMouseWheel(): ArcRotateCameraInputsManager;
  98197. /**
  98198. * Add pointers input support to the input manager.
  98199. * @returns the current input manager
  98200. */
  98201. addPointers(): ArcRotateCameraInputsManager;
  98202. /**
  98203. * Add keyboard input support to the input manager.
  98204. * @returns the current input manager
  98205. */
  98206. addKeyboard(): ArcRotateCameraInputsManager;
  98207. }
  98208. }
  98209. declare module BABYLON {
  98210. /**
  98211. * This represents an orbital type of camera.
  98212. *
  98213. * 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.
  98214. * 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.
  98215. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98216. */
  98217. export class ArcRotateCamera extends TargetCamera {
  98218. /**
  98219. * Defines the rotation angle of the camera along the longitudinal axis.
  98220. */
  98221. alpha: number;
  98222. /**
  98223. * Defines the rotation angle of the camera along the latitudinal axis.
  98224. */
  98225. beta: number;
  98226. /**
  98227. * Defines the radius of the camera from it s target point.
  98228. */
  98229. radius: number;
  98230. protected _target: Vector3;
  98231. protected _targetHost: Nullable<AbstractMesh>;
  98232. /**
  98233. * Defines the target point of the camera.
  98234. * The camera looks towards it form the radius distance.
  98235. */
  98236. target: Vector3;
  98237. /**
  98238. * Define the current local position of the camera in the scene
  98239. */
  98240. position: Vector3;
  98241. protected _upVector: Vector3;
  98242. protected _upToYMatrix: Matrix;
  98243. protected _YToUpMatrix: Matrix;
  98244. /**
  98245. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98246. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98247. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98248. */
  98249. upVector: Vector3;
  98250. /**
  98251. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98252. */
  98253. setMatUp(): void;
  98254. /**
  98255. * Current inertia value on the longitudinal axis.
  98256. * The bigger this number the longer it will take for the camera to stop.
  98257. */
  98258. inertialAlphaOffset: number;
  98259. /**
  98260. * Current inertia value on the latitudinal axis.
  98261. * The bigger this number the longer it will take for the camera to stop.
  98262. */
  98263. inertialBetaOffset: number;
  98264. /**
  98265. * Current inertia value on the radius axis.
  98266. * The bigger this number the longer it will take for the camera to stop.
  98267. */
  98268. inertialRadiusOffset: number;
  98269. /**
  98270. * Minimum allowed angle on the longitudinal axis.
  98271. * This can help limiting how the Camera is able to move in the scene.
  98272. */
  98273. lowerAlphaLimit: Nullable<number>;
  98274. /**
  98275. * Maximum allowed angle on the longitudinal axis.
  98276. * This can help limiting how the Camera is able to move in the scene.
  98277. */
  98278. upperAlphaLimit: Nullable<number>;
  98279. /**
  98280. * Minimum allowed angle on the latitudinal axis.
  98281. * This can help limiting how the Camera is able to move in the scene.
  98282. */
  98283. lowerBetaLimit: number;
  98284. /**
  98285. * Maximum allowed angle on the latitudinal axis.
  98286. * This can help limiting how the Camera is able to move in the scene.
  98287. */
  98288. upperBetaLimit: number;
  98289. /**
  98290. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98291. * This can help limiting how the Camera is able to move in the scene.
  98292. */
  98293. lowerRadiusLimit: Nullable<number>;
  98294. /**
  98295. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98296. * This can help limiting how the Camera is able to move in the scene.
  98297. */
  98298. upperRadiusLimit: Nullable<number>;
  98299. /**
  98300. * Defines the current inertia value used during panning of the camera along the X axis.
  98301. */
  98302. inertialPanningX: number;
  98303. /**
  98304. * Defines the current inertia value used during panning of the camera along the Y axis.
  98305. */
  98306. inertialPanningY: number;
  98307. /**
  98308. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98309. * Basically if your fingers moves away from more than this distance you will be considered
  98310. * in pinch mode.
  98311. */
  98312. pinchToPanMaxDistance: number;
  98313. /**
  98314. * Defines the maximum distance the camera can pan.
  98315. * This could help keeping the cammera always in your scene.
  98316. */
  98317. panningDistanceLimit: Nullable<number>;
  98318. /**
  98319. * Defines the target of the camera before paning.
  98320. */
  98321. panningOriginTarget: Vector3;
  98322. /**
  98323. * Defines the value of the inertia used during panning.
  98324. * 0 would mean stop inertia and one would mean no decelleration at all.
  98325. */
  98326. panningInertia: number;
  98327. /**
  98328. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98329. */
  98330. angularSensibilityX: number;
  98331. /**
  98332. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98333. */
  98334. angularSensibilityY: number;
  98335. /**
  98336. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98337. */
  98338. pinchPrecision: number;
  98339. /**
  98340. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98341. * It will be used instead of pinchDeltaPrecision if different from 0.
  98342. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98343. */
  98344. pinchDeltaPercentage: number;
  98345. /**
  98346. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98347. */
  98348. panningSensibility: number;
  98349. /**
  98350. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98351. */
  98352. keysUp: number[];
  98353. /**
  98354. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98355. */
  98356. keysDown: number[];
  98357. /**
  98358. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98359. */
  98360. keysLeft: number[];
  98361. /**
  98362. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98363. */
  98364. keysRight: number[];
  98365. /**
  98366. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98367. */
  98368. wheelPrecision: number;
  98369. /**
  98370. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98371. * It will be used instead of pinchDeltaPrecision if different from 0.
  98372. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98373. */
  98374. wheelDeltaPercentage: number;
  98375. /**
  98376. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98377. */
  98378. zoomOnFactor: number;
  98379. /**
  98380. * Defines a screen offset for the camera position.
  98381. */
  98382. targetScreenOffset: Vector2;
  98383. /**
  98384. * Allows the camera to be completely reversed.
  98385. * If false the camera can not arrive upside down.
  98386. */
  98387. allowUpsideDown: boolean;
  98388. /**
  98389. * Define if double tap/click is used to restore the previously saved state of the camera.
  98390. */
  98391. useInputToRestoreState: boolean;
  98392. /** @hidden */
  98393. _viewMatrix: Matrix;
  98394. /** @hidden */
  98395. _useCtrlForPanning: boolean;
  98396. /** @hidden */
  98397. _panningMouseButton: number;
  98398. /**
  98399. * Defines the input associated to the camera.
  98400. */
  98401. inputs: ArcRotateCameraInputsManager;
  98402. /** @hidden */
  98403. _reset: () => void;
  98404. /**
  98405. * Defines the allowed panning axis.
  98406. */
  98407. panningAxis: Vector3;
  98408. protected _localDirection: Vector3;
  98409. protected _transformedDirection: Vector3;
  98410. private _bouncingBehavior;
  98411. /**
  98412. * Gets the bouncing behavior of the camera if it has been enabled.
  98413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98414. */
  98415. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98416. /**
  98417. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98419. */
  98420. useBouncingBehavior: boolean;
  98421. private _framingBehavior;
  98422. /**
  98423. * Gets the framing behavior of the camera if it has been enabled.
  98424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98425. */
  98426. readonly framingBehavior: Nullable<FramingBehavior>;
  98427. /**
  98428. * Defines if the framing behavior of the camera is enabled on the camera.
  98429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98430. */
  98431. useFramingBehavior: boolean;
  98432. private _autoRotationBehavior;
  98433. /**
  98434. * Gets the auto rotation behavior of the camera if it has been enabled.
  98435. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98436. */
  98437. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98438. /**
  98439. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98440. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98441. */
  98442. useAutoRotationBehavior: boolean;
  98443. /**
  98444. * Observable triggered when the mesh target has been changed on the camera.
  98445. */
  98446. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98447. /**
  98448. * Event raised when the camera is colliding with a mesh.
  98449. */
  98450. onCollide: (collidedMesh: AbstractMesh) => void;
  98451. /**
  98452. * Defines whether the camera should check collision with the objects oh the scene.
  98453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98454. */
  98455. checkCollisions: boolean;
  98456. /**
  98457. * Defines the collision radius of the camera.
  98458. * This simulates a sphere around the camera.
  98459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98460. */
  98461. collisionRadius: Vector3;
  98462. protected _collider: Collider;
  98463. protected _previousPosition: Vector3;
  98464. protected _collisionVelocity: Vector3;
  98465. protected _newPosition: Vector3;
  98466. protected _previousAlpha: number;
  98467. protected _previousBeta: number;
  98468. protected _previousRadius: number;
  98469. protected _collisionTriggered: boolean;
  98470. protected _targetBoundingCenter: Nullable<Vector3>;
  98471. private _computationVector;
  98472. /**
  98473. * Instantiates a new ArcRotateCamera in a given scene
  98474. * @param name Defines the name of the camera
  98475. * @param alpha Defines the camera rotation along the logitudinal axis
  98476. * @param beta Defines the camera rotation along the latitudinal axis
  98477. * @param radius Defines the camera distance from its target
  98478. * @param target Defines the camera target
  98479. * @param scene Defines the scene the camera belongs to
  98480. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98481. */
  98482. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98483. /** @hidden */
  98484. _initCache(): void;
  98485. /** @hidden */
  98486. _updateCache(ignoreParentClass?: boolean): void;
  98487. protected _getTargetPosition(): Vector3;
  98488. private _storedAlpha;
  98489. private _storedBeta;
  98490. private _storedRadius;
  98491. private _storedTarget;
  98492. /**
  98493. * Stores the current state of the camera (alpha, beta, radius and target)
  98494. * @returns the camera itself
  98495. */
  98496. storeState(): Camera;
  98497. /**
  98498. * @hidden
  98499. * Restored camera state. You must call storeState() first
  98500. */
  98501. _restoreStateValues(): boolean;
  98502. /** @hidden */
  98503. _isSynchronizedViewMatrix(): boolean;
  98504. /**
  98505. * Attached controls to the current camera.
  98506. * @param element Defines the element the controls should be listened from
  98507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98508. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98509. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98510. */
  98511. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98512. /**
  98513. * Detach the current controls from the camera.
  98514. * The camera will stop reacting to inputs.
  98515. * @param element Defines the element to stop listening the inputs from
  98516. */
  98517. detachControl(element: HTMLElement): void;
  98518. /** @hidden */
  98519. _checkInputs(): void;
  98520. protected _checkLimits(): void;
  98521. /**
  98522. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98523. */
  98524. rebuildAnglesAndRadius(): void;
  98525. /**
  98526. * Use a position to define the current camera related information like aplha, beta and radius
  98527. * @param position Defines the position to set the camera at
  98528. */
  98529. setPosition(position: Vector3): void;
  98530. /**
  98531. * Defines the target the camera should look at.
  98532. * This will automatically adapt alpha beta and radius to fit within the new target.
  98533. * @param target Defines the new target as a Vector or a mesh
  98534. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98535. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98536. */
  98537. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98538. /** @hidden */
  98539. _getViewMatrix(): Matrix;
  98540. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98541. /**
  98542. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98543. * @param meshes Defines the mesh to zoom on
  98544. * @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)
  98545. */
  98546. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98547. /**
  98548. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98549. * The target will be changed but the radius
  98550. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98551. * @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)
  98552. */
  98553. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98554. min: Vector3;
  98555. max: Vector3;
  98556. distance: number;
  98557. }, doNotUpdateMaxZ?: boolean): void;
  98558. /**
  98559. * @override
  98560. * Override Camera.createRigCamera
  98561. */
  98562. createRigCamera(name: string, cameraIndex: number): Camera;
  98563. /**
  98564. * @hidden
  98565. * @override
  98566. * Override Camera._updateRigCameras
  98567. */
  98568. _updateRigCameras(): void;
  98569. /**
  98570. * Destroy the camera and release the current resources hold by it.
  98571. */
  98572. dispose(): void;
  98573. /**
  98574. * Gets the current object class name.
  98575. * @return the class name
  98576. */
  98577. getClassName(): string;
  98578. }
  98579. }
  98580. declare module BABYLON {
  98581. /**
  98582. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98584. */
  98585. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98586. /**
  98587. * Gets the name of the behavior.
  98588. */
  98589. readonly name: string;
  98590. private _zoomStopsAnimation;
  98591. private _idleRotationSpeed;
  98592. private _idleRotationWaitTime;
  98593. private _idleRotationSpinupTime;
  98594. /**
  98595. * Sets the flag that indicates if user zooming should stop animation.
  98596. */
  98597. /**
  98598. * Gets the flag that indicates if user zooming should stop animation.
  98599. */
  98600. zoomStopsAnimation: boolean;
  98601. /**
  98602. * Sets the default speed at which the camera rotates around the model.
  98603. */
  98604. /**
  98605. * Gets the default speed at which the camera rotates around the model.
  98606. */
  98607. idleRotationSpeed: number;
  98608. /**
  98609. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98610. */
  98611. /**
  98612. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98613. */
  98614. idleRotationWaitTime: number;
  98615. /**
  98616. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98617. */
  98618. /**
  98619. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98620. */
  98621. idleRotationSpinupTime: number;
  98622. /**
  98623. * Gets a value indicating if the camera is currently rotating because of this behavior
  98624. */
  98625. readonly rotationInProgress: boolean;
  98626. private _onPrePointerObservableObserver;
  98627. private _onAfterCheckInputsObserver;
  98628. private _attachedCamera;
  98629. private _isPointerDown;
  98630. private _lastFrameTime;
  98631. private _lastInteractionTime;
  98632. private _cameraRotationSpeed;
  98633. /**
  98634. * Initializes the behavior.
  98635. */
  98636. init(): void;
  98637. /**
  98638. * Attaches the behavior to its arc rotate camera.
  98639. * @param camera Defines the camera to attach the behavior to
  98640. */
  98641. attach(camera: ArcRotateCamera): void;
  98642. /**
  98643. * Detaches the behavior from its current arc rotate camera.
  98644. */
  98645. detach(): void;
  98646. /**
  98647. * Returns true if user is scrolling.
  98648. * @return true if user is scrolling.
  98649. */
  98650. private _userIsZooming;
  98651. private _lastFrameRadius;
  98652. private _shouldAnimationStopForInteraction;
  98653. /**
  98654. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98655. */
  98656. private _applyUserInteraction;
  98657. private _userIsMoving;
  98658. }
  98659. }
  98660. declare module BABYLON {
  98661. /**
  98662. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98663. */
  98664. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98665. private ui;
  98666. /**
  98667. * The name of the behavior
  98668. */
  98669. name: string;
  98670. /**
  98671. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98672. */
  98673. distanceAwayFromFace: number;
  98674. /**
  98675. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98676. */
  98677. distanceAwayFromBottomOfFace: number;
  98678. private _faceVectors;
  98679. private _target;
  98680. private _scene;
  98681. private _onRenderObserver;
  98682. private _tmpMatrix;
  98683. private _tmpVector;
  98684. /**
  98685. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98686. * @param ui The transform node that should be attched to the mesh
  98687. */
  98688. constructor(ui: TransformNode);
  98689. /**
  98690. * Initializes the behavior
  98691. */
  98692. init(): void;
  98693. private _closestFace;
  98694. private _zeroVector;
  98695. private _lookAtTmpMatrix;
  98696. private _lookAtToRef;
  98697. /**
  98698. * Attaches the AttachToBoxBehavior to the passed in mesh
  98699. * @param target The mesh that the specified node will be attached to
  98700. */
  98701. attach(target: Mesh): void;
  98702. /**
  98703. * Detaches the behavior from the mesh
  98704. */
  98705. detach(): void;
  98706. }
  98707. }
  98708. declare module BABYLON {
  98709. /**
  98710. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98711. */
  98712. export class FadeInOutBehavior implements Behavior<Mesh> {
  98713. /**
  98714. * Time in milliseconds to delay before fading in (Default: 0)
  98715. */
  98716. delay: number;
  98717. /**
  98718. * Time in milliseconds for the mesh to fade in (Default: 300)
  98719. */
  98720. fadeInTime: number;
  98721. private _millisecondsPerFrame;
  98722. private _hovered;
  98723. private _hoverValue;
  98724. private _ownerNode;
  98725. /**
  98726. * Instatiates the FadeInOutBehavior
  98727. */
  98728. constructor();
  98729. /**
  98730. * The name of the behavior
  98731. */
  98732. readonly name: string;
  98733. /**
  98734. * Initializes the behavior
  98735. */
  98736. init(): void;
  98737. /**
  98738. * Attaches the fade behavior on the passed in mesh
  98739. * @param ownerNode The mesh that will be faded in/out once attached
  98740. */
  98741. attach(ownerNode: Mesh): void;
  98742. /**
  98743. * Detaches the behavior from the mesh
  98744. */
  98745. detach(): void;
  98746. /**
  98747. * Triggers the mesh to begin fading in or out
  98748. * @param value if the object should fade in or out (true to fade in)
  98749. */
  98750. fadeIn(value: boolean): void;
  98751. private _update;
  98752. private _setAllVisibility;
  98753. }
  98754. }
  98755. declare module BABYLON {
  98756. /**
  98757. * Class containing a set of static utilities functions for managing Pivots
  98758. * @hidden
  98759. */
  98760. export class PivotTools {
  98761. private static _PivotCached;
  98762. private static _OldPivotPoint;
  98763. private static _PivotTranslation;
  98764. private static _PivotTmpVector;
  98765. /** @hidden */
  98766. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98767. /** @hidden */
  98768. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98769. }
  98770. }
  98771. declare module BABYLON {
  98772. /**
  98773. * Class containing static functions to help procedurally build meshes
  98774. */
  98775. export class PlaneBuilder {
  98776. /**
  98777. * Creates a plane mesh
  98778. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98779. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98780. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98784. * @param name defines the name of the mesh
  98785. * @param options defines the options used to create the mesh
  98786. * @param scene defines the hosting scene
  98787. * @returns the plane mesh
  98788. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98789. */
  98790. static CreatePlane(name: string, options: {
  98791. size?: number;
  98792. width?: number;
  98793. height?: number;
  98794. sideOrientation?: number;
  98795. frontUVs?: Vector4;
  98796. backUVs?: Vector4;
  98797. updatable?: boolean;
  98798. sourcePlane?: Plane;
  98799. }, scene?: Nullable<Scene>): Mesh;
  98800. }
  98801. }
  98802. declare module BABYLON {
  98803. /**
  98804. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98805. */
  98806. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98807. private static _AnyMouseID;
  98808. /**
  98809. * Abstract mesh the behavior is set on
  98810. */
  98811. attachedNode: AbstractMesh;
  98812. private _dragPlane;
  98813. private _scene;
  98814. private _pointerObserver;
  98815. private _beforeRenderObserver;
  98816. private static _planeScene;
  98817. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98818. /**
  98819. * 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)
  98820. */
  98821. maxDragAngle: number;
  98822. /**
  98823. * @hidden
  98824. */
  98825. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98826. /**
  98827. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98828. */
  98829. currentDraggingPointerID: number;
  98830. /**
  98831. * The last position where the pointer hit the drag plane in world space
  98832. */
  98833. lastDragPosition: Vector3;
  98834. /**
  98835. * If the behavior is currently in a dragging state
  98836. */
  98837. dragging: boolean;
  98838. /**
  98839. * 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)
  98840. */
  98841. dragDeltaRatio: number;
  98842. /**
  98843. * If the drag plane orientation should be updated during the dragging (Default: true)
  98844. */
  98845. updateDragPlane: boolean;
  98846. private _debugMode;
  98847. private _moving;
  98848. /**
  98849. * Fires each time the attached mesh is dragged with the pointer
  98850. * * delta between last drag position and current drag position in world space
  98851. * * dragDistance along the drag axis
  98852. * * dragPlaneNormal normal of the current drag plane used during the drag
  98853. * * dragPlanePoint in world space where the drag intersects the drag plane
  98854. */
  98855. onDragObservable: Observable<{
  98856. delta: Vector3;
  98857. dragPlanePoint: Vector3;
  98858. dragPlaneNormal: Vector3;
  98859. dragDistance: number;
  98860. pointerId: number;
  98861. }>;
  98862. /**
  98863. * Fires each time a drag begins (eg. mouse down on mesh)
  98864. */
  98865. onDragStartObservable: Observable<{
  98866. dragPlanePoint: Vector3;
  98867. pointerId: number;
  98868. }>;
  98869. /**
  98870. * Fires each time a drag ends (eg. mouse release after drag)
  98871. */
  98872. onDragEndObservable: Observable<{
  98873. dragPlanePoint: Vector3;
  98874. pointerId: number;
  98875. }>;
  98876. /**
  98877. * If the attached mesh should be moved when dragged
  98878. */
  98879. moveAttached: boolean;
  98880. /**
  98881. * If the drag behavior will react to drag events (Default: true)
  98882. */
  98883. enabled: boolean;
  98884. /**
  98885. * If pointer events should start and release the drag (Default: true)
  98886. */
  98887. startAndReleaseDragOnPointerEvents: boolean;
  98888. /**
  98889. * If camera controls should be detached during the drag
  98890. */
  98891. detachCameraControls: boolean;
  98892. /**
  98893. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98894. */
  98895. useObjectOrienationForDragging: boolean;
  98896. private _options;
  98897. /**
  98898. * Creates a pointer drag behavior that can be attached to a mesh
  98899. * @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)
  98900. */
  98901. constructor(options?: {
  98902. dragAxis?: Vector3;
  98903. dragPlaneNormal?: Vector3;
  98904. });
  98905. /**
  98906. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98907. */
  98908. validateDrag: (targetPosition: Vector3) => boolean;
  98909. /**
  98910. * The name of the behavior
  98911. */
  98912. readonly name: string;
  98913. /**
  98914. * Initializes the behavior
  98915. */
  98916. init(): void;
  98917. private _tmpVector;
  98918. private _alternatePickedPoint;
  98919. private _worldDragAxis;
  98920. private _targetPosition;
  98921. private _attachedElement;
  98922. /**
  98923. * Attaches the drag behavior the passed in mesh
  98924. * @param ownerNode The mesh that will be dragged around once attached
  98925. */
  98926. attach(ownerNode: AbstractMesh): void;
  98927. /**
  98928. * Force relase the drag action by code.
  98929. */
  98930. releaseDrag(): void;
  98931. private _startDragRay;
  98932. private _lastPointerRay;
  98933. /**
  98934. * Simulates the start of a pointer drag event on the behavior
  98935. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98936. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98937. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98938. */
  98939. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98940. private _startDrag;
  98941. private _dragDelta;
  98942. private _moveDrag;
  98943. private _pickWithRayOnDragPlane;
  98944. private _pointA;
  98945. private _pointB;
  98946. private _pointC;
  98947. private _lineA;
  98948. private _lineB;
  98949. private _localAxis;
  98950. private _lookAt;
  98951. private _updateDragPlanePosition;
  98952. /**
  98953. * Detaches the behavior from the mesh
  98954. */
  98955. detach(): void;
  98956. }
  98957. }
  98958. declare module BABYLON {
  98959. /**
  98960. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98961. */
  98962. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98963. private _dragBehaviorA;
  98964. private _dragBehaviorB;
  98965. private _startDistance;
  98966. private _initialScale;
  98967. private _targetScale;
  98968. private _ownerNode;
  98969. private _sceneRenderObserver;
  98970. /**
  98971. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98972. */
  98973. constructor();
  98974. /**
  98975. * The name of the behavior
  98976. */
  98977. readonly name: string;
  98978. /**
  98979. * Initializes the behavior
  98980. */
  98981. init(): void;
  98982. private _getCurrentDistance;
  98983. /**
  98984. * Attaches the scale behavior the passed in mesh
  98985. * @param ownerNode The mesh that will be scaled around once attached
  98986. */
  98987. attach(ownerNode: Mesh): void;
  98988. /**
  98989. * Detaches the behavior from the mesh
  98990. */
  98991. detach(): void;
  98992. }
  98993. }
  98994. declare module BABYLON {
  98995. /**
  98996. * 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
  98997. */
  98998. export class SixDofDragBehavior implements Behavior<Mesh> {
  98999. private static _virtualScene;
  99000. private _ownerNode;
  99001. private _sceneRenderObserver;
  99002. private _scene;
  99003. private _targetPosition;
  99004. private _virtualOriginMesh;
  99005. private _virtualDragMesh;
  99006. private _pointerObserver;
  99007. private _moving;
  99008. private _startingOrientation;
  99009. /**
  99010. * 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)
  99011. */
  99012. private zDragFactor;
  99013. /**
  99014. * If the object should rotate to face the drag origin
  99015. */
  99016. rotateDraggedObject: boolean;
  99017. /**
  99018. * If the behavior is currently in a dragging state
  99019. */
  99020. dragging: boolean;
  99021. /**
  99022. * 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)
  99023. */
  99024. dragDeltaRatio: number;
  99025. /**
  99026. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99027. */
  99028. currentDraggingPointerID: number;
  99029. /**
  99030. * If camera controls should be detached during the drag
  99031. */
  99032. detachCameraControls: boolean;
  99033. /**
  99034. * Fires each time a drag starts
  99035. */
  99036. onDragStartObservable: Observable<{}>;
  99037. /**
  99038. * Fires each time a drag ends (eg. mouse release after drag)
  99039. */
  99040. onDragEndObservable: Observable<{}>;
  99041. /**
  99042. * 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
  99043. */
  99044. constructor();
  99045. /**
  99046. * The name of the behavior
  99047. */
  99048. readonly name: string;
  99049. /**
  99050. * Initializes the behavior
  99051. */
  99052. init(): void;
  99053. /**
  99054. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99055. */
  99056. private readonly _pointerCamera;
  99057. /**
  99058. * Attaches the scale behavior the passed in mesh
  99059. * @param ownerNode The mesh that will be scaled around once attached
  99060. */
  99061. attach(ownerNode: Mesh): void;
  99062. /**
  99063. * Detaches the behavior from the mesh
  99064. */
  99065. detach(): void;
  99066. }
  99067. }
  99068. declare module BABYLON {
  99069. /**
  99070. * Class used to apply inverse kinematics to bones
  99071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99072. */
  99073. export class BoneIKController {
  99074. private static _tmpVecs;
  99075. private static _tmpQuat;
  99076. private static _tmpMats;
  99077. /**
  99078. * Gets or sets the target mesh
  99079. */
  99080. targetMesh: AbstractMesh;
  99081. /** Gets or sets the mesh used as pole */
  99082. poleTargetMesh: AbstractMesh;
  99083. /**
  99084. * Gets or sets the bone used as pole
  99085. */
  99086. poleTargetBone: Nullable<Bone>;
  99087. /**
  99088. * Gets or sets the target position
  99089. */
  99090. targetPosition: Vector3;
  99091. /**
  99092. * Gets or sets the pole target position
  99093. */
  99094. poleTargetPosition: Vector3;
  99095. /**
  99096. * Gets or sets the pole target local offset
  99097. */
  99098. poleTargetLocalOffset: Vector3;
  99099. /**
  99100. * Gets or sets the pole angle
  99101. */
  99102. poleAngle: number;
  99103. /**
  99104. * Gets or sets the mesh associated with the controller
  99105. */
  99106. mesh: AbstractMesh;
  99107. /**
  99108. * 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)
  99109. */
  99110. slerpAmount: number;
  99111. private _bone1Quat;
  99112. private _bone1Mat;
  99113. private _bone2Ang;
  99114. private _bone1;
  99115. private _bone2;
  99116. private _bone1Length;
  99117. private _bone2Length;
  99118. private _maxAngle;
  99119. private _maxReach;
  99120. private _rightHandedSystem;
  99121. private _bendAxis;
  99122. private _slerping;
  99123. private _adjustRoll;
  99124. /**
  99125. * Gets or sets maximum allowed angle
  99126. */
  99127. maxAngle: number;
  99128. /**
  99129. * Creates a new BoneIKController
  99130. * @param mesh defines the mesh to control
  99131. * @param bone defines the bone to control
  99132. * @param options defines options to set up the controller
  99133. */
  99134. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99135. targetMesh?: AbstractMesh;
  99136. poleTargetMesh?: AbstractMesh;
  99137. poleTargetBone?: Bone;
  99138. poleTargetLocalOffset?: Vector3;
  99139. poleAngle?: number;
  99140. bendAxis?: Vector3;
  99141. maxAngle?: number;
  99142. slerpAmount?: number;
  99143. });
  99144. private _setMaxAngle;
  99145. /**
  99146. * Force the controller to update the bones
  99147. */
  99148. update(): void;
  99149. }
  99150. }
  99151. declare module BABYLON {
  99152. /**
  99153. * Class used to make a bone look toward a point in space
  99154. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99155. */
  99156. export class BoneLookController {
  99157. private static _tmpVecs;
  99158. private static _tmpQuat;
  99159. private static _tmpMats;
  99160. /**
  99161. * The target Vector3 that the bone will look at
  99162. */
  99163. target: Vector3;
  99164. /**
  99165. * The mesh that the bone is attached to
  99166. */
  99167. mesh: AbstractMesh;
  99168. /**
  99169. * The bone that will be looking to the target
  99170. */
  99171. bone: Bone;
  99172. /**
  99173. * The up axis of the coordinate system that is used when the bone is rotated
  99174. */
  99175. upAxis: Vector3;
  99176. /**
  99177. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99178. */
  99179. upAxisSpace: Space;
  99180. /**
  99181. * Used to make an adjustment to the yaw of the bone
  99182. */
  99183. adjustYaw: number;
  99184. /**
  99185. * Used to make an adjustment to the pitch of the bone
  99186. */
  99187. adjustPitch: number;
  99188. /**
  99189. * Used to make an adjustment to the roll of the bone
  99190. */
  99191. adjustRoll: number;
  99192. /**
  99193. * 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)
  99194. */
  99195. slerpAmount: number;
  99196. private _minYaw;
  99197. private _maxYaw;
  99198. private _minPitch;
  99199. private _maxPitch;
  99200. private _minYawSin;
  99201. private _minYawCos;
  99202. private _maxYawSin;
  99203. private _maxYawCos;
  99204. private _midYawConstraint;
  99205. private _minPitchTan;
  99206. private _maxPitchTan;
  99207. private _boneQuat;
  99208. private _slerping;
  99209. private _transformYawPitch;
  99210. private _transformYawPitchInv;
  99211. private _firstFrameSkipped;
  99212. private _yawRange;
  99213. private _fowardAxis;
  99214. /**
  99215. * Gets or sets the minimum yaw angle that the bone can look to
  99216. */
  99217. minYaw: number;
  99218. /**
  99219. * Gets or sets the maximum yaw angle that the bone can look to
  99220. */
  99221. maxYaw: number;
  99222. /**
  99223. * Gets or sets the minimum pitch angle that the bone can look to
  99224. */
  99225. minPitch: number;
  99226. /**
  99227. * Gets or sets the maximum pitch angle that the bone can look to
  99228. */
  99229. maxPitch: number;
  99230. /**
  99231. * Create a BoneLookController
  99232. * @param mesh the mesh that the bone belongs to
  99233. * @param bone the bone that will be looking to the target
  99234. * @param target the target Vector3 to look at
  99235. * @param options optional settings:
  99236. * * maxYaw: the maximum angle the bone will yaw to
  99237. * * minYaw: the minimum angle the bone will yaw to
  99238. * * maxPitch: the maximum angle the bone will pitch to
  99239. * * minPitch: the minimum angle the bone will yaw to
  99240. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99241. * * upAxis: the up axis of the coordinate system
  99242. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99243. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99244. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99245. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99246. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99247. * * adjustRoll: used to make an adjustment to the roll of the bone
  99248. **/
  99249. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99250. maxYaw?: number;
  99251. minYaw?: number;
  99252. maxPitch?: number;
  99253. minPitch?: number;
  99254. slerpAmount?: number;
  99255. upAxis?: Vector3;
  99256. upAxisSpace?: Space;
  99257. yawAxis?: Vector3;
  99258. pitchAxis?: Vector3;
  99259. adjustYaw?: number;
  99260. adjustPitch?: number;
  99261. adjustRoll?: number;
  99262. });
  99263. /**
  99264. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99265. */
  99266. update(): void;
  99267. private _getAngleDiff;
  99268. private _getAngleBetween;
  99269. private _isAngleBetween;
  99270. }
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Manage the gamepad inputs to control an arc rotate camera.
  99275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99276. */
  99277. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99278. /**
  99279. * Defines the camera the input is attached to.
  99280. */
  99281. camera: ArcRotateCamera;
  99282. /**
  99283. * Defines the gamepad the input is gathering event from.
  99284. */
  99285. gamepad: Nullable<Gamepad>;
  99286. /**
  99287. * Defines the gamepad rotation sensiblity.
  99288. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99289. */
  99290. gamepadRotationSensibility: number;
  99291. /**
  99292. * Defines the gamepad move sensiblity.
  99293. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99294. */
  99295. gamepadMoveSensibility: number;
  99296. private _onGamepadConnectedObserver;
  99297. private _onGamepadDisconnectedObserver;
  99298. /**
  99299. * Attach the input controls to a specific dom element to get the input from.
  99300. * @param element Defines the element the controls should be listened from
  99301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99302. */
  99303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99304. /**
  99305. * Detach the current controls from the specified dom element.
  99306. * @param element Defines the element to stop listening the inputs from
  99307. */
  99308. detachControl(element: Nullable<HTMLElement>): void;
  99309. /**
  99310. * Update the current camera state depending on the inputs that have been used this frame.
  99311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99312. */
  99313. checkInputs(): void;
  99314. /**
  99315. * Gets the class name of the current intput.
  99316. * @returns the class name
  99317. */
  99318. getClassName(): string;
  99319. /**
  99320. * Get the friendly name associated with the input class.
  99321. * @returns the input friendly name
  99322. */
  99323. getSimpleName(): string;
  99324. }
  99325. }
  99326. declare module BABYLON {
  99327. interface ArcRotateCameraInputsManager {
  99328. /**
  99329. * Add orientation input support to the input manager.
  99330. * @returns the current input manager
  99331. */
  99332. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99333. }
  99334. /**
  99335. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99337. */
  99338. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99339. /**
  99340. * Defines the camera the input is attached to.
  99341. */
  99342. camera: ArcRotateCamera;
  99343. /**
  99344. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99345. */
  99346. alphaCorrection: number;
  99347. /**
  99348. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99349. */
  99350. gammaCorrection: number;
  99351. private _alpha;
  99352. private _gamma;
  99353. private _dirty;
  99354. private _deviceOrientationHandler;
  99355. /**
  99356. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99357. */
  99358. constructor();
  99359. /**
  99360. * Attach the input controls to a specific dom element to get the input from.
  99361. * @param element Defines the element the controls should be listened from
  99362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99363. */
  99364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99365. /** @hidden */
  99366. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99367. /**
  99368. * Update the current camera state depending on the inputs that have been used this frame.
  99369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99370. */
  99371. checkInputs(): void;
  99372. /**
  99373. * Detach the current controls from the specified dom element.
  99374. * @param element Defines the element to stop listening the inputs from
  99375. */
  99376. detachControl(element: Nullable<HTMLElement>): void;
  99377. /**
  99378. * Gets the class name of the current intput.
  99379. * @returns the class name
  99380. */
  99381. getClassName(): string;
  99382. /**
  99383. * Get the friendly name associated with the input class.
  99384. * @returns the input friendly name
  99385. */
  99386. getSimpleName(): string;
  99387. }
  99388. }
  99389. declare module BABYLON {
  99390. /**
  99391. * Listen to mouse events to control the camera.
  99392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99393. */
  99394. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99395. /**
  99396. * Defines the camera the input is attached to.
  99397. */
  99398. camera: FlyCamera;
  99399. /**
  99400. * Defines if touch is enabled. (Default is true.)
  99401. */
  99402. touchEnabled: boolean;
  99403. /**
  99404. * Defines the buttons associated with the input to handle camera rotation.
  99405. */
  99406. buttons: number[];
  99407. /**
  99408. * Assign buttons for Yaw control.
  99409. */
  99410. buttonsYaw: number[];
  99411. /**
  99412. * Assign buttons for Pitch control.
  99413. */
  99414. buttonsPitch: number[];
  99415. /**
  99416. * Assign buttons for Roll control.
  99417. */
  99418. buttonsRoll: number[];
  99419. /**
  99420. * Detect if any button is being pressed while mouse is moved.
  99421. * -1 = Mouse locked.
  99422. * 0 = Left button.
  99423. * 1 = Middle Button.
  99424. * 2 = Right Button.
  99425. */
  99426. activeButton: number;
  99427. /**
  99428. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99429. * Higher values reduce its sensitivity.
  99430. */
  99431. angularSensibility: number;
  99432. private _mousemoveCallback;
  99433. private _observer;
  99434. private _rollObserver;
  99435. private previousPosition;
  99436. private noPreventDefault;
  99437. private element;
  99438. /**
  99439. * Listen to mouse events to control the camera.
  99440. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99441. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99442. */
  99443. constructor(touchEnabled?: boolean);
  99444. /**
  99445. * Attach the mouse control to the HTML DOM element.
  99446. * @param element Defines the element that listens to the input events.
  99447. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99448. */
  99449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99450. /**
  99451. * Detach the current controls from the specified dom element.
  99452. * @param element Defines the element to stop listening the inputs from
  99453. */
  99454. detachControl(element: Nullable<HTMLElement>): void;
  99455. /**
  99456. * Gets the class name of the current input.
  99457. * @returns the class name.
  99458. */
  99459. getClassName(): string;
  99460. /**
  99461. * Get the friendly name associated with the input class.
  99462. * @returns the input's friendly name.
  99463. */
  99464. getSimpleName(): string;
  99465. private _pointerInput;
  99466. private _onMouseMove;
  99467. /**
  99468. * Rotate camera by mouse offset.
  99469. */
  99470. private rotateCamera;
  99471. }
  99472. }
  99473. declare module BABYLON {
  99474. /**
  99475. * Default Inputs manager for the FlyCamera.
  99476. * It groups all the default supported inputs for ease of use.
  99477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99478. */
  99479. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99480. /**
  99481. * Instantiates a new FlyCameraInputsManager.
  99482. * @param camera Defines the camera the inputs belong to.
  99483. */
  99484. constructor(camera: FlyCamera);
  99485. /**
  99486. * Add keyboard input support to the input manager.
  99487. * @returns the new FlyCameraKeyboardMoveInput().
  99488. */
  99489. addKeyboard(): FlyCameraInputsManager;
  99490. /**
  99491. * Add mouse input support to the input manager.
  99492. * @param touchEnabled Enable touch screen support.
  99493. * @returns the new FlyCameraMouseInput().
  99494. */
  99495. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99496. }
  99497. }
  99498. declare module BABYLON {
  99499. /**
  99500. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99501. * such as in a 3D Space Shooter or a Flight Simulator.
  99502. */
  99503. export class FlyCamera extends TargetCamera {
  99504. /**
  99505. * Define the collision ellipsoid of the camera.
  99506. * This is helpful for simulating a camera body, like a player's body.
  99507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99508. */
  99509. ellipsoid: Vector3;
  99510. /**
  99511. * Define an offset for the position of the ellipsoid around the camera.
  99512. * This can be helpful if the camera is attached away from the player's body center,
  99513. * such as at its head.
  99514. */
  99515. ellipsoidOffset: Vector3;
  99516. /**
  99517. * Enable or disable collisions of the camera with the rest of the scene objects.
  99518. */
  99519. checkCollisions: boolean;
  99520. /**
  99521. * Enable or disable gravity on the camera.
  99522. */
  99523. applyGravity: boolean;
  99524. /**
  99525. * Define the current direction the camera is moving to.
  99526. */
  99527. cameraDirection: Vector3;
  99528. /**
  99529. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99530. * This overrides and empties cameraRotation.
  99531. */
  99532. rotationQuaternion: Quaternion;
  99533. /**
  99534. * Track Roll to maintain the wanted Rolling when looking around.
  99535. */
  99536. _trackRoll: number;
  99537. /**
  99538. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99539. */
  99540. rollCorrect: number;
  99541. /**
  99542. * Mimic a banked turn, Rolling the camera when Yawing.
  99543. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99544. */
  99545. bankedTurn: boolean;
  99546. /**
  99547. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99548. */
  99549. bankedTurnLimit: number;
  99550. /**
  99551. * Value of 0 disables the banked Roll.
  99552. * Value of 1 is equal to the Yaw angle in radians.
  99553. */
  99554. bankedTurnMultiplier: number;
  99555. /**
  99556. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99557. */
  99558. inputs: FlyCameraInputsManager;
  99559. /**
  99560. * Gets the input sensibility for mouse input.
  99561. * Higher values reduce sensitivity.
  99562. */
  99563. /**
  99564. * Sets the input sensibility for a mouse input.
  99565. * Higher values reduce sensitivity.
  99566. */
  99567. angularSensibility: number;
  99568. /**
  99569. * Get the keys for camera movement forward.
  99570. */
  99571. /**
  99572. * Set the keys for camera movement forward.
  99573. */
  99574. keysForward: number[];
  99575. /**
  99576. * Get the keys for camera movement backward.
  99577. */
  99578. keysBackward: number[];
  99579. /**
  99580. * Get the keys for camera movement up.
  99581. */
  99582. /**
  99583. * Set the keys for camera movement up.
  99584. */
  99585. keysUp: number[];
  99586. /**
  99587. * Get the keys for camera movement down.
  99588. */
  99589. /**
  99590. * Set the keys for camera movement down.
  99591. */
  99592. keysDown: number[];
  99593. /**
  99594. * Get the keys for camera movement left.
  99595. */
  99596. /**
  99597. * Set the keys for camera movement left.
  99598. */
  99599. keysLeft: number[];
  99600. /**
  99601. * Set the keys for camera movement right.
  99602. */
  99603. /**
  99604. * Set the keys for camera movement right.
  99605. */
  99606. keysRight: number[];
  99607. /**
  99608. * Event raised when the camera collides with a mesh in the scene.
  99609. */
  99610. onCollide: (collidedMesh: AbstractMesh) => void;
  99611. private _collider;
  99612. private _needMoveForGravity;
  99613. private _oldPosition;
  99614. private _diffPosition;
  99615. private _newPosition;
  99616. /** @hidden */
  99617. _localDirection: Vector3;
  99618. /** @hidden */
  99619. _transformedDirection: Vector3;
  99620. /**
  99621. * Instantiates a FlyCamera.
  99622. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99623. * such as in a 3D Space Shooter or a Flight Simulator.
  99624. * @param name Define the name of the camera in the scene.
  99625. * @param position Define the starting position of the camera in the scene.
  99626. * @param scene Define the scene the camera belongs to.
  99627. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99628. */
  99629. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99630. /**
  99631. * Attach a control to the HTML DOM element.
  99632. * @param element Defines the element that listens to the input events.
  99633. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99634. */
  99635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99636. /**
  99637. * Detach a control from the HTML DOM element.
  99638. * The camera will stop reacting to that input.
  99639. * @param element Defines the element that listens to the input events.
  99640. */
  99641. detachControl(element: HTMLElement): void;
  99642. private _collisionMask;
  99643. /**
  99644. * Get the mask that the camera ignores in collision events.
  99645. */
  99646. /**
  99647. * Set the mask that the camera ignores in collision events.
  99648. */
  99649. collisionMask: number;
  99650. /** @hidden */
  99651. _collideWithWorld(displacement: Vector3): void;
  99652. /** @hidden */
  99653. private _onCollisionPositionChange;
  99654. /** @hidden */
  99655. _checkInputs(): void;
  99656. /** @hidden */
  99657. _decideIfNeedsToMove(): boolean;
  99658. /** @hidden */
  99659. _updatePosition(): void;
  99660. /**
  99661. * Restore the Roll to its target value at the rate specified.
  99662. * @param rate - Higher means slower restoring.
  99663. * @hidden
  99664. */
  99665. restoreRoll(rate: number): void;
  99666. /**
  99667. * Destroy the camera and release the current resources held by it.
  99668. */
  99669. dispose(): void;
  99670. /**
  99671. * Get the current object class name.
  99672. * @returns the class name.
  99673. */
  99674. getClassName(): string;
  99675. }
  99676. }
  99677. declare module BABYLON {
  99678. /**
  99679. * Listen to keyboard events to control the camera.
  99680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99681. */
  99682. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99683. /**
  99684. * Defines the camera the input is attached to.
  99685. */
  99686. camera: FlyCamera;
  99687. /**
  99688. * The list of keyboard keys used to control the forward move of the camera.
  99689. */
  99690. keysForward: number[];
  99691. /**
  99692. * The list of keyboard keys used to control the backward move of the camera.
  99693. */
  99694. keysBackward: number[];
  99695. /**
  99696. * The list of keyboard keys used to control the forward move of the camera.
  99697. */
  99698. keysUp: number[];
  99699. /**
  99700. * The list of keyboard keys used to control the backward move of the camera.
  99701. */
  99702. keysDown: number[];
  99703. /**
  99704. * The list of keyboard keys used to control the right strafe move of the camera.
  99705. */
  99706. keysRight: number[];
  99707. /**
  99708. * The list of keyboard keys used to control the left strafe move of the camera.
  99709. */
  99710. keysLeft: number[];
  99711. private _keys;
  99712. private _onCanvasBlurObserver;
  99713. private _onKeyboardObserver;
  99714. private _engine;
  99715. private _scene;
  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. /**
  99723. * Detach the current controls from the specified dom element.
  99724. * @param element Defines the element to stop listening the inputs from
  99725. */
  99726. detachControl(element: Nullable<HTMLElement>): void;
  99727. /**
  99728. * Gets the class name of the current intput.
  99729. * @returns the class name
  99730. */
  99731. getClassName(): string;
  99732. /** @hidden */
  99733. _onLostFocus(e: FocusEvent): void;
  99734. /**
  99735. * Get the friendly name associated with the input class.
  99736. * @returns the input friendly name
  99737. */
  99738. getSimpleName(): string;
  99739. /**
  99740. * Update the current camera state depending on the inputs that have been used this frame.
  99741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99742. */
  99743. checkInputs(): void;
  99744. }
  99745. }
  99746. declare module BABYLON {
  99747. /**
  99748. * Manage the mouse wheel inputs to control a follow camera.
  99749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99750. */
  99751. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99752. /**
  99753. * Defines the camera the input is attached to.
  99754. */
  99755. camera: FollowCamera;
  99756. /**
  99757. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99758. */
  99759. axisControlRadius: boolean;
  99760. /**
  99761. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99762. */
  99763. axisControlHeight: boolean;
  99764. /**
  99765. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99766. */
  99767. axisControlRotation: boolean;
  99768. /**
  99769. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99770. * relation to mouseWheel events.
  99771. */
  99772. wheelPrecision: number;
  99773. /**
  99774. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99775. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99776. */
  99777. wheelDeltaPercentage: number;
  99778. private _wheel;
  99779. private _observer;
  99780. /**
  99781. * Attach the input controls to a specific dom element to get the input from.
  99782. * @param element Defines the element the controls should be listened from
  99783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99784. */
  99785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99786. /**
  99787. * Detach the current controls from the specified dom element.
  99788. * @param element Defines the element to stop listening the inputs from
  99789. */
  99790. detachControl(element: Nullable<HTMLElement>): void;
  99791. /**
  99792. * Gets the class name of the current intput.
  99793. * @returns the class name
  99794. */
  99795. getClassName(): string;
  99796. /**
  99797. * Get the friendly name associated with the input class.
  99798. * @returns the input friendly name
  99799. */
  99800. getSimpleName(): string;
  99801. }
  99802. }
  99803. declare module BABYLON {
  99804. /**
  99805. * Manage the pointers inputs to control an follow camera.
  99806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99807. */
  99808. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99809. /**
  99810. * Defines the camera the input is attached to.
  99811. */
  99812. camera: FollowCamera;
  99813. /**
  99814. * Gets the class name of the current input.
  99815. * @returns the class name
  99816. */
  99817. getClassName(): string;
  99818. /**
  99819. * Defines the pointer angular sensibility along the X axis or how fast is
  99820. * the camera rotating.
  99821. * A negative number will reverse the axis direction.
  99822. */
  99823. angularSensibilityX: number;
  99824. /**
  99825. * Defines the pointer angular sensibility along the Y axis or how fast is
  99826. * the camera rotating.
  99827. * A negative number will reverse the axis direction.
  99828. */
  99829. angularSensibilityY: number;
  99830. /**
  99831. * Defines the pointer pinch precision or how fast is the camera zooming.
  99832. * A negative number will reverse the axis direction.
  99833. */
  99834. pinchPrecision: number;
  99835. /**
  99836. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99837. * from 0.
  99838. * It defines the percentage of current camera.radius to use as delta when
  99839. * pinch zoom is used.
  99840. */
  99841. pinchDeltaPercentage: number;
  99842. /**
  99843. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99844. */
  99845. axisXControlRadius: boolean;
  99846. /**
  99847. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99848. */
  99849. axisXControlHeight: boolean;
  99850. /**
  99851. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99852. */
  99853. axisXControlRotation: boolean;
  99854. /**
  99855. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99856. */
  99857. axisYControlRadius: boolean;
  99858. /**
  99859. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99860. */
  99861. axisYControlHeight: boolean;
  99862. /**
  99863. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99864. */
  99865. axisYControlRotation: boolean;
  99866. /**
  99867. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99868. */
  99869. axisPinchControlRadius: boolean;
  99870. /**
  99871. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99872. */
  99873. axisPinchControlHeight: boolean;
  99874. /**
  99875. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99876. */
  99877. axisPinchControlRotation: boolean;
  99878. /**
  99879. * Log error messages if basic misconfiguration has occurred.
  99880. */
  99881. warningEnable: boolean;
  99882. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99883. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99884. private _warningCounter;
  99885. private _warning;
  99886. }
  99887. }
  99888. declare module BABYLON {
  99889. /**
  99890. * Default Inputs manager for the FollowCamera.
  99891. * It groups all the default supported inputs for ease of use.
  99892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99893. */
  99894. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99895. /**
  99896. * Instantiates a new FollowCameraInputsManager.
  99897. * @param camera Defines the camera the inputs belong to
  99898. */
  99899. constructor(camera: FollowCamera);
  99900. /**
  99901. * Add keyboard input support to the input manager.
  99902. * @returns the current input manager
  99903. */
  99904. addKeyboard(): FollowCameraInputsManager;
  99905. /**
  99906. * Add mouse wheel input support to the input manager.
  99907. * @returns the current input manager
  99908. */
  99909. addMouseWheel(): FollowCameraInputsManager;
  99910. /**
  99911. * Add pointers input support to the input manager.
  99912. * @returns the current input manager
  99913. */
  99914. addPointers(): FollowCameraInputsManager;
  99915. /**
  99916. * Add orientation input support to the input manager.
  99917. * @returns the current input manager
  99918. */
  99919. addVRDeviceOrientation(): FollowCameraInputsManager;
  99920. }
  99921. }
  99922. declare module BABYLON {
  99923. /**
  99924. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99925. * an arc rotate version arcFollowCamera are available.
  99926. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99927. */
  99928. export class FollowCamera extends TargetCamera {
  99929. /**
  99930. * Distance the follow camera should follow an object at
  99931. */
  99932. radius: number;
  99933. /**
  99934. * Minimum allowed distance of the camera to the axis of rotation
  99935. * (The camera can not get closer).
  99936. * This can help limiting how the Camera is able to move in the scene.
  99937. */
  99938. lowerRadiusLimit: Nullable<number>;
  99939. /**
  99940. * Maximum allowed distance of the camera to the axis of rotation
  99941. * (The camera can not get further).
  99942. * This can help limiting how the Camera is able to move in the scene.
  99943. */
  99944. upperRadiusLimit: Nullable<number>;
  99945. /**
  99946. * Define a rotation offset between the camera and the object it follows
  99947. */
  99948. rotationOffset: number;
  99949. /**
  99950. * Minimum allowed angle to camera position relative to target object.
  99951. * This can help limiting how the Camera is able to move in the scene.
  99952. */
  99953. lowerRotationOffsetLimit: Nullable<number>;
  99954. /**
  99955. * Maximum allowed angle to camera position relative to target object.
  99956. * This can help limiting how the Camera is able to move in the scene.
  99957. */
  99958. upperRotationOffsetLimit: Nullable<number>;
  99959. /**
  99960. * Define a height offset between the camera and the object it follows.
  99961. * It can help following an object from the top (like a car chaing a plane)
  99962. */
  99963. heightOffset: number;
  99964. /**
  99965. * Minimum allowed height of camera position relative to target object.
  99966. * This can help limiting how the Camera is able to move in the scene.
  99967. */
  99968. lowerHeightOffsetLimit: Nullable<number>;
  99969. /**
  99970. * Maximum allowed height of camera position relative to target object.
  99971. * This can help limiting how the Camera is able to move in the scene.
  99972. */
  99973. upperHeightOffsetLimit: Nullable<number>;
  99974. /**
  99975. * Define how fast the camera can accelerate to follow it s target.
  99976. */
  99977. cameraAcceleration: number;
  99978. /**
  99979. * Define the speed limit of the camera following an object.
  99980. */
  99981. maxCameraSpeed: number;
  99982. /**
  99983. * Define the target of the camera.
  99984. */
  99985. lockedTarget: Nullable<AbstractMesh>;
  99986. /**
  99987. * Defines the input associated with the camera.
  99988. */
  99989. inputs: FollowCameraInputsManager;
  99990. /**
  99991. * Instantiates the follow camera.
  99992. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99993. * @param name Define the name of the camera in the scene
  99994. * @param position Define the position of the camera
  99995. * @param scene Define the scene the camera belong to
  99996. * @param lockedTarget Define the target of the camera
  99997. */
  99998. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99999. private _follow;
  100000. /**
  100001. * Attached controls to the current camera.
  100002. * @param element Defines the element the controls should be listened from
  100003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100004. */
  100005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100006. /**
  100007. * Detach the current controls from the camera.
  100008. * The camera will stop reacting to inputs.
  100009. * @param element Defines the element to stop listening the inputs from
  100010. */
  100011. detachControl(element: HTMLElement): void;
  100012. /** @hidden */
  100013. _checkInputs(): void;
  100014. private _checkLimits;
  100015. /**
  100016. * Gets the camera class name.
  100017. * @returns the class name
  100018. */
  100019. getClassName(): string;
  100020. }
  100021. /**
  100022. * Arc Rotate version of the follow camera.
  100023. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100024. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100025. */
  100026. export class ArcFollowCamera extends TargetCamera {
  100027. /** The longitudinal angle of the camera */
  100028. alpha: number;
  100029. /** The latitudinal angle of the camera */
  100030. beta: number;
  100031. /** The radius of the camera from its target */
  100032. radius: number;
  100033. /** Define the camera target (the messh it should follow) */
  100034. target: Nullable<AbstractMesh>;
  100035. private _cartesianCoordinates;
  100036. /**
  100037. * Instantiates a new ArcFollowCamera
  100038. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100039. * @param name Define the name of the camera
  100040. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100041. * @param beta Define the rotation angle of the camera around the elevation axis
  100042. * @param radius Define the radius of the camera from its target point
  100043. * @param target Define the target of the camera
  100044. * @param scene Define the scene the camera belongs to
  100045. */
  100046. constructor(name: string,
  100047. /** The longitudinal angle of the camera */
  100048. alpha: number,
  100049. /** The latitudinal angle of the camera */
  100050. beta: number,
  100051. /** The radius of the camera from its target */
  100052. radius: number,
  100053. /** Define the camera target (the messh it should follow) */
  100054. target: Nullable<AbstractMesh>, scene: Scene);
  100055. private _follow;
  100056. /** @hidden */
  100057. _checkInputs(): void;
  100058. /**
  100059. * Returns the class name of the object.
  100060. * It is mostly used internally for serialization purposes.
  100061. */
  100062. getClassName(): string;
  100063. }
  100064. }
  100065. declare module BABYLON {
  100066. /**
  100067. * Manage the keyboard inputs to control the movement of a follow camera.
  100068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100069. */
  100070. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100071. /**
  100072. * Defines the camera the input is attached to.
  100073. */
  100074. camera: FollowCamera;
  100075. /**
  100076. * Defines the list of key codes associated with the up action (increase heightOffset)
  100077. */
  100078. keysHeightOffsetIncr: number[];
  100079. /**
  100080. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100081. */
  100082. keysHeightOffsetDecr: number[];
  100083. /**
  100084. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100085. */
  100086. keysHeightOffsetModifierAlt: boolean;
  100087. /**
  100088. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100089. */
  100090. keysHeightOffsetModifierCtrl: boolean;
  100091. /**
  100092. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100093. */
  100094. keysHeightOffsetModifierShift: boolean;
  100095. /**
  100096. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100097. */
  100098. keysRotationOffsetIncr: number[];
  100099. /**
  100100. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100101. */
  100102. keysRotationOffsetDecr: number[];
  100103. /**
  100104. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100105. */
  100106. keysRotationOffsetModifierAlt: boolean;
  100107. /**
  100108. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100109. */
  100110. keysRotationOffsetModifierCtrl: boolean;
  100111. /**
  100112. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100113. */
  100114. keysRotationOffsetModifierShift: boolean;
  100115. /**
  100116. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100117. */
  100118. keysRadiusIncr: number[];
  100119. /**
  100120. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100121. */
  100122. keysRadiusDecr: number[];
  100123. /**
  100124. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100125. */
  100126. keysRadiusModifierAlt: boolean;
  100127. /**
  100128. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100129. */
  100130. keysRadiusModifierCtrl: boolean;
  100131. /**
  100132. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100133. */
  100134. keysRadiusModifierShift: boolean;
  100135. /**
  100136. * Defines the rate of change of heightOffset.
  100137. */
  100138. heightSensibility: number;
  100139. /**
  100140. * Defines the rate of change of rotationOffset.
  100141. */
  100142. rotationSensibility: number;
  100143. /**
  100144. * Defines the rate of change of radius.
  100145. */
  100146. radiusSensibility: number;
  100147. private _keys;
  100148. private _ctrlPressed;
  100149. private _altPressed;
  100150. private _shiftPressed;
  100151. private _onCanvasBlurObserver;
  100152. private _onKeyboardObserver;
  100153. private _engine;
  100154. private _scene;
  100155. /**
  100156. * Attach the input controls to a specific dom element to get the input from.
  100157. * @param element Defines the element the controls should be listened from
  100158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100159. */
  100160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100161. /**
  100162. * Detach the current controls from the specified dom element.
  100163. * @param element Defines the element to stop listening the inputs from
  100164. */
  100165. detachControl(element: Nullable<HTMLElement>): void;
  100166. /**
  100167. * Update the current camera state depending on the inputs that have been used this frame.
  100168. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100169. */
  100170. checkInputs(): void;
  100171. /**
  100172. * Gets the class name of the current input.
  100173. * @returns the class name
  100174. */
  100175. getClassName(): string;
  100176. /**
  100177. * Get the friendly name associated with the input class.
  100178. * @returns the input friendly name
  100179. */
  100180. getSimpleName(): string;
  100181. /**
  100182. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100183. * allow modification of the heightOffset value.
  100184. */
  100185. private _modifierHeightOffset;
  100186. /**
  100187. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100188. * allow modification of the rotationOffset value.
  100189. */
  100190. private _modifierRotationOffset;
  100191. /**
  100192. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100193. * allow modification of the radius value.
  100194. */
  100195. private _modifierRadius;
  100196. }
  100197. }
  100198. declare module BABYLON {
  100199. interface FreeCameraInputsManager {
  100200. /**
  100201. * @hidden
  100202. */
  100203. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100204. /**
  100205. * Add orientation input support to the input manager.
  100206. * @returns the current input manager
  100207. */
  100208. addDeviceOrientation(): FreeCameraInputsManager;
  100209. }
  100210. /**
  100211. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100212. * Screen rotation is taken into account.
  100213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100214. */
  100215. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100216. private _camera;
  100217. private _screenOrientationAngle;
  100218. private _constantTranform;
  100219. private _screenQuaternion;
  100220. private _alpha;
  100221. private _beta;
  100222. private _gamma;
  100223. /**
  100224. * Can be used to detect if a device orientation sensor is availible on a device
  100225. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100226. * @returns a promise that will resolve on orientation change
  100227. */
  100228. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100229. /**
  100230. * @hidden
  100231. */
  100232. _onDeviceOrientationChangedObservable: Observable<void>;
  100233. /**
  100234. * Instantiates a new input
  100235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100236. */
  100237. constructor();
  100238. /**
  100239. * Define the camera controlled by the input.
  100240. */
  100241. camera: FreeCamera;
  100242. /**
  100243. * Attach the input controls to a specific dom element to get the input from.
  100244. * @param element Defines the element the controls should be listened from
  100245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100246. */
  100247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100248. private _orientationChanged;
  100249. private _deviceOrientation;
  100250. /**
  100251. * Detach the current controls from the specified dom element.
  100252. * @param element Defines the element to stop listening the inputs from
  100253. */
  100254. detachControl(element: Nullable<HTMLElement>): void;
  100255. /**
  100256. * Update the current camera state depending on the inputs that have been used this frame.
  100257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100258. */
  100259. checkInputs(): void;
  100260. /**
  100261. * Gets the class name of the current intput.
  100262. * @returns the class name
  100263. */
  100264. getClassName(): string;
  100265. /**
  100266. * Get the friendly name associated with the input class.
  100267. * @returns the input friendly name
  100268. */
  100269. getSimpleName(): string;
  100270. }
  100271. }
  100272. declare module BABYLON {
  100273. /**
  100274. * Manage the gamepad inputs to control a free camera.
  100275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100276. */
  100277. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100278. /**
  100279. * Define the camera the input is attached to.
  100280. */
  100281. camera: FreeCamera;
  100282. /**
  100283. * Define the Gamepad controlling the input
  100284. */
  100285. gamepad: Nullable<Gamepad>;
  100286. /**
  100287. * Defines the gamepad rotation sensiblity.
  100288. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100289. */
  100290. gamepadAngularSensibility: number;
  100291. /**
  100292. * Defines the gamepad move sensiblity.
  100293. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100294. */
  100295. gamepadMoveSensibility: number;
  100296. private _onGamepadConnectedObserver;
  100297. private _onGamepadDisconnectedObserver;
  100298. private _cameraTransform;
  100299. private _deltaTransform;
  100300. private _vector3;
  100301. private _vector2;
  100302. /**
  100303. * Attach the input controls to a specific dom element to get the input from.
  100304. * @param element Defines the element the controls should be listened from
  100305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100306. */
  100307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100308. /**
  100309. * Detach the current controls from the specified dom element.
  100310. * @param element Defines the element to stop listening the inputs from
  100311. */
  100312. detachControl(element: Nullable<HTMLElement>): void;
  100313. /**
  100314. * Update the current camera state depending on the inputs that have been used this frame.
  100315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100316. */
  100317. checkInputs(): void;
  100318. /**
  100319. * Gets the class name of the current intput.
  100320. * @returns the class name
  100321. */
  100322. getClassName(): string;
  100323. /**
  100324. * Get the friendly name associated with the input class.
  100325. * @returns the input friendly name
  100326. */
  100327. getSimpleName(): string;
  100328. }
  100329. }
  100330. declare module BABYLON {
  100331. /**
  100332. * Defines the potential axis of a Joystick
  100333. */
  100334. export enum JoystickAxis {
  100335. /** X axis */
  100336. X = 0,
  100337. /** Y axis */
  100338. Y = 1,
  100339. /** Z axis */
  100340. Z = 2
  100341. }
  100342. /**
  100343. * Class used to define virtual joystick (used in touch mode)
  100344. */
  100345. export class VirtualJoystick {
  100346. /**
  100347. * Gets or sets a boolean indicating that left and right values must be inverted
  100348. */
  100349. reverseLeftRight: boolean;
  100350. /**
  100351. * Gets or sets a boolean indicating that up and down values must be inverted
  100352. */
  100353. reverseUpDown: boolean;
  100354. /**
  100355. * Gets the offset value for the position (ie. the change of the position value)
  100356. */
  100357. deltaPosition: Vector3;
  100358. /**
  100359. * Gets a boolean indicating if the virtual joystick was pressed
  100360. */
  100361. pressed: boolean;
  100362. /**
  100363. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100364. */
  100365. static Canvas: Nullable<HTMLCanvasElement>;
  100366. private static _globalJoystickIndex;
  100367. private static vjCanvasContext;
  100368. private static vjCanvasWidth;
  100369. private static vjCanvasHeight;
  100370. private static halfWidth;
  100371. private _action;
  100372. private _axisTargetedByLeftAndRight;
  100373. private _axisTargetedByUpAndDown;
  100374. private _joystickSensibility;
  100375. private _inversedSensibility;
  100376. private _joystickPointerID;
  100377. private _joystickColor;
  100378. private _joystickPointerPos;
  100379. private _joystickPreviousPointerPos;
  100380. private _joystickPointerStartPos;
  100381. private _deltaJoystickVector;
  100382. private _leftJoystick;
  100383. private _touches;
  100384. private _onPointerDownHandlerRef;
  100385. private _onPointerMoveHandlerRef;
  100386. private _onPointerUpHandlerRef;
  100387. private _onResize;
  100388. /**
  100389. * Creates a new virtual joystick
  100390. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100391. */
  100392. constructor(leftJoystick?: boolean);
  100393. /**
  100394. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100395. * @param newJoystickSensibility defines the new sensibility
  100396. */
  100397. setJoystickSensibility(newJoystickSensibility: number): void;
  100398. private _onPointerDown;
  100399. private _onPointerMove;
  100400. private _onPointerUp;
  100401. /**
  100402. * Change the color of the virtual joystick
  100403. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100404. */
  100405. setJoystickColor(newColor: string): void;
  100406. /**
  100407. * Defines a callback to call when the joystick is touched
  100408. * @param action defines the callback
  100409. */
  100410. setActionOnTouch(action: () => any): void;
  100411. /**
  100412. * Defines which axis you'd like to control for left & right
  100413. * @param axis defines the axis to use
  100414. */
  100415. setAxisForLeftRight(axis: JoystickAxis): void;
  100416. /**
  100417. * Defines which axis you'd like to control for up & down
  100418. * @param axis defines the axis to use
  100419. */
  100420. setAxisForUpDown(axis: JoystickAxis): void;
  100421. private _drawVirtualJoystick;
  100422. /**
  100423. * Release internal HTML canvas
  100424. */
  100425. releaseCanvas(): void;
  100426. }
  100427. }
  100428. declare module BABYLON {
  100429. interface FreeCameraInputsManager {
  100430. /**
  100431. * Add virtual joystick input support to the input manager.
  100432. * @returns the current input manager
  100433. */
  100434. addVirtualJoystick(): FreeCameraInputsManager;
  100435. }
  100436. /**
  100437. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100439. */
  100440. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100441. /**
  100442. * Defines the camera the input is attached to.
  100443. */
  100444. camera: FreeCamera;
  100445. private _leftjoystick;
  100446. private _rightjoystick;
  100447. /**
  100448. * Gets the left stick of the virtual joystick.
  100449. * @returns The virtual Joystick
  100450. */
  100451. getLeftJoystick(): VirtualJoystick;
  100452. /**
  100453. * Gets the right stick of the virtual joystick.
  100454. * @returns The virtual Joystick
  100455. */
  100456. getRightJoystick(): VirtualJoystick;
  100457. /**
  100458. * Update the current camera state depending on the inputs that have been used this frame.
  100459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100460. */
  100461. checkInputs(): void;
  100462. /**
  100463. * Attach the input controls to a specific dom element to get the input from.
  100464. * @param element Defines the element the controls should be listened from
  100465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100466. */
  100467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100468. /**
  100469. * Detach the current controls from the specified dom element.
  100470. * @param element Defines the element to stop listening the inputs from
  100471. */
  100472. detachControl(element: Nullable<HTMLElement>): void;
  100473. /**
  100474. * Gets the class name of the current intput.
  100475. * @returns the class name
  100476. */
  100477. getClassName(): string;
  100478. /**
  100479. * Get the friendly name associated with the input class.
  100480. * @returns the input friendly name
  100481. */
  100482. getSimpleName(): string;
  100483. }
  100484. }
  100485. declare module BABYLON {
  100486. /**
  100487. * This represents a FPS type of camera controlled by touch.
  100488. * This is like a universal camera minus the Gamepad controls.
  100489. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100490. */
  100491. export class TouchCamera extends FreeCamera {
  100492. /**
  100493. * Defines the touch sensibility for rotation.
  100494. * The higher the faster.
  100495. */
  100496. touchAngularSensibility: number;
  100497. /**
  100498. * Defines the touch sensibility for move.
  100499. * The higher the faster.
  100500. */
  100501. touchMoveSensibility: number;
  100502. /**
  100503. * Instantiates a new touch camera.
  100504. * This represents a FPS type of camera controlled by touch.
  100505. * This is like a universal camera minus the Gamepad controls.
  100506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100507. * @param name Define the name of the camera in the scene
  100508. * @param position Define the start position of the camera in the scene
  100509. * @param scene Define the scene the camera belongs to
  100510. */
  100511. constructor(name: string, position: Vector3, scene: Scene);
  100512. /**
  100513. * Gets the current object class name.
  100514. * @return the class name
  100515. */
  100516. getClassName(): string;
  100517. /** @hidden */
  100518. _setupInputs(): void;
  100519. }
  100520. }
  100521. declare module BABYLON {
  100522. /**
  100523. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100524. * being tilted forward or back and left or right.
  100525. */
  100526. export class DeviceOrientationCamera extends FreeCamera {
  100527. private _initialQuaternion;
  100528. private _quaternionCache;
  100529. private _tmpDragQuaternion;
  100530. /**
  100531. * Creates a new device orientation camera
  100532. * @param name The name of the camera
  100533. * @param position The start position camera
  100534. * @param scene The scene the camera belongs to
  100535. */
  100536. constructor(name: string, position: Vector3, scene: Scene);
  100537. /**
  100538. * @hidden
  100539. * Disabled pointer input on first orientation sensor update (Default: true)
  100540. */
  100541. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100542. private _dragFactor;
  100543. /**
  100544. * Enabled turning on the y axis when the orientation sensor is active
  100545. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100546. */
  100547. enableHorizontalDragging(dragFactor?: number): void;
  100548. /**
  100549. * Gets the current instance class name ("DeviceOrientationCamera").
  100550. * This helps avoiding instanceof at run time.
  100551. * @returns the class name
  100552. */
  100553. getClassName(): string;
  100554. /**
  100555. * @hidden
  100556. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100557. */
  100558. _checkInputs(): void;
  100559. /**
  100560. * Reset the camera to its default orientation on the specified axis only.
  100561. * @param axis The axis to reset
  100562. */
  100563. resetToCurrentRotation(axis?: Axis): void;
  100564. }
  100565. }
  100566. declare module BABYLON {
  100567. /**
  100568. * Defines supported buttons for XBox360 compatible gamepads
  100569. */
  100570. export enum Xbox360Button {
  100571. /** A */
  100572. A = 0,
  100573. /** B */
  100574. B = 1,
  100575. /** X */
  100576. X = 2,
  100577. /** Y */
  100578. Y = 3,
  100579. /** Start */
  100580. Start = 4,
  100581. /** Back */
  100582. Back = 5,
  100583. /** Left button */
  100584. LB = 6,
  100585. /** Right button */
  100586. RB = 7,
  100587. /** Left stick */
  100588. LeftStick = 8,
  100589. /** Right stick */
  100590. RightStick = 9
  100591. }
  100592. /** Defines values for XBox360 DPad */
  100593. export enum Xbox360Dpad {
  100594. /** Up */
  100595. Up = 0,
  100596. /** Down */
  100597. Down = 1,
  100598. /** Left */
  100599. Left = 2,
  100600. /** Right */
  100601. Right = 3
  100602. }
  100603. /**
  100604. * Defines a XBox360 gamepad
  100605. */
  100606. export class Xbox360Pad extends Gamepad {
  100607. private _leftTrigger;
  100608. private _rightTrigger;
  100609. private _onlefttriggerchanged;
  100610. private _onrighttriggerchanged;
  100611. private _onbuttondown;
  100612. private _onbuttonup;
  100613. private _ondpaddown;
  100614. private _ondpadup;
  100615. /** Observable raised when a button is pressed */
  100616. onButtonDownObservable: Observable<Xbox360Button>;
  100617. /** Observable raised when a button is released */
  100618. onButtonUpObservable: Observable<Xbox360Button>;
  100619. /** Observable raised when a pad is pressed */
  100620. onPadDownObservable: Observable<Xbox360Dpad>;
  100621. /** Observable raised when a pad is released */
  100622. onPadUpObservable: Observable<Xbox360Dpad>;
  100623. private _buttonA;
  100624. private _buttonB;
  100625. private _buttonX;
  100626. private _buttonY;
  100627. private _buttonBack;
  100628. private _buttonStart;
  100629. private _buttonLB;
  100630. private _buttonRB;
  100631. private _buttonLeftStick;
  100632. private _buttonRightStick;
  100633. private _dPadUp;
  100634. private _dPadDown;
  100635. private _dPadLeft;
  100636. private _dPadRight;
  100637. private _isXboxOnePad;
  100638. /**
  100639. * Creates a new XBox360 gamepad object
  100640. * @param id defines the id of this gamepad
  100641. * @param index defines its index
  100642. * @param gamepad defines the internal HTML gamepad object
  100643. * @param xboxOne defines if it is a XBox One gamepad
  100644. */
  100645. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100646. /**
  100647. * Defines the callback to call when left trigger is pressed
  100648. * @param callback defines the callback to use
  100649. */
  100650. onlefttriggerchanged(callback: (value: number) => void): void;
  100651. /**
  100652. * Defines the callback to call when right trigger is pressed
  100653. * @param callback defines the callback to use
  100654. */
  100655. onrighttriggerchanged(callback: (value: number) => void): void;
  100656. /**
  100657. * Gets the left trigger value
  100658. */
  100659. /**
  100660. * Sets the left trigger value
  100661. */
  100662. leftTrigger: number;
  100663. /**
  100664. * Gets the right trigger value
  100665. */
  100666. /**
  100667. * Sets the right trigger value
  100668. */
  100669. rightTrigger: number;
  100670. /**
  100671. * Defines the callback to call when a button is pressed
  100672. * @param callback defines the callback to use
  100673. */
  100674. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100675. /**
  100676. * Defines the callback to call when a button is released
  100677. * @param callback defines the callback to use
  100678. */
  100679. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100680. /**
  100681. * Defines the callback to call when a pad is pressed
  100682. * @param callback defines the callback to use
  100683. */
  100684. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100685. /**
  100686. * Defines the callback to call when a pad is released
  100687. * @param callback defines the callback to use
  100688. */
  100689. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100690. private _setButtonValue;
  100691. private _setDPadValue;
  100692. /**
  100693. * Gets the value of the `A` button
  100694. */
  100695. /**
  100696. * Sets the value of the `A` button
  100697. */
  100698. buttonA: number;
  100699. /**
  100700. * Gets the value of the `B` button
  100701. */
  100702. /**
  100703. * Sets the value of the `B` button
  100704. */
  100705. buttonB: number;
  100706. /**
  100707. * Gets the value of the `X` button
  100708. */
  100709. /**
  100710. * Sets the value of the `X` button
  100711. */
  100712. buttonX: number;
  100713. /**
  100714. * Gets the value of the `Y` button
  100715. */
  100716. /**
  100717. * Sets the value of the `Y` button
  100718. */
  100719. buttonY: number;
  100720. /**
  100721. * Gets the value of the `Start` button
  100722. */
  100723. /**
  100724. * Sets the value of the `Start` button
  100725. */
  100726. buttonStart: number;
  100727. /**
  100728. * Gets the value of the `Back` button
  100729. */
  100730. /**
  100731. * Sets the value of the `Back` button
  100732. */
  100733. buttonBack: number;
  100734. /**
  100735. * Gets the value of the `Left` button
  100736. */
  100737. /**
  100738. * Sets the value of the `Left` button
  100739. */
  100740. buttonLB: number;
  100741. /**
  100742. * Gets the value of the `Right` button
  100743. */
  100744. /**
  100745. * Sets the value of the `Right` button
  100746. */
  100747. buttonRB: number;
  100748. /**
  100749. * Gets the value of the Left joystick
  100750. */
  100751. /**
  100752. * Sets the value of the Left joystick
  100753. */
  100754. buttonLeftStick: number;
  100755. /**
  100756. * Gets the value of the Right joystick
  100757. */
  100758. /**
  100759. * Sets the value of the Right joystick
  100760. */
  100761. buttonRightStick: number;
  100762. /**
  100763. * Gets the value of D-pad up
  100764. */
  100765. /**
  100766. * Sets the value of D-pad up
  100767. */
  100768. dPadUp: number;
  100769. /**
  100770. * Gets the value of D-pad down
  100771. */
  100772. /**
  100773. * Sets the value of D-pad down
  100774. */
  100775. dPadDown: number;
  100776. /**
  100777. * Gets the value of D-pad left
  100778. */
  100779. /**
  100780. * Sets the value of D-pad left
  100781. */
  100782. dPadLeft: number;
  100783. /**
  100784. * Gets the value of D-pad right
  100785. */
  100786. /**
  100787. * Sets the value of D-pad right
  100788. */
  100789. dPadRight: number;
  100790. /**
  100791. * Force the gamepad to synchronize with device values
  100792. */
  100793. update(): void;
  100794. /**
  100795. * Disposes the gamepad
  100796. */
  100797. dispose(): void;
  100798. }
  100799. }
  100800. declare module BABYLON {
  100801. /**
  100802. * Manager for handling gamepads
  100803. */
  100804. export class GamepadManager {
  100805. private _scene?;
  100806. private _babylonGamepads;
  100807. private _oneGamepadConnected;
  100808. /** @hidden */
  100809. _isMonitoring: boolean;
  100810. private _gamepadEventSupported;
  100811. private _gamepadSupport;
  100812. /**
  100813. * observable to be triggered when the gamepad controller has been connected
  100814. */
  100815. onGamepadConnectedObservable: Observable<Gamepad>;
  100816. /**
  100817. * observable to be triggered when the gamepad controller has been disconnected
  100818. */
  100819. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100820. private _onGamepadConnectedEvent;
  100821. private _onGamepadDisconnectedEvent;
  100822. /**
  100823. * Initializes the gamepad manager
  100824. * @param _scene BabylonJS scene
  100825. */
  100826. constructor(_scene?: Scene | undefined);
  100827. /**
  100828. * The gamepads in the game pad manager
  100829. */
  100830. readonly gamepads: Gamepad[];
  100831. /**
  100832. * Get the gamepad controllers based on type
  100833. * @param type The type of gamepad controller
  100834. * @returns Nullable gamepad
  100835. */
  100836. getGamepadByType(type?: number): Nullable<Gamepad>;
  100837. /**
  100838. * Disposes the gamepad manager
  100839. */
  100840. dispose(): void;
  100841. private _addNewGamepad;
  100842. private _startMonitoringGamepads;
  100843. private _stopMonitoringGamepads;
  100844. /** @hidden */
  100845. _checkGamepadsStatus(): void;
  100846. private _updateGamepadObjects;
  100847. }
  100848. }
  100849. declare module BABYLON {
  100850. interface Scene {
  100851. /** @hidden */
  100852. _gamepadManager: Nullable<GamepadManager>;
  100853. /**
  100854. * Gets the gamepad manager associated with the scene
  100855. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100856. */
  100857. gamepadManager: GamepadManager;
  100858. }
  100859. /**
  100860. * Interface representing a free camera inputs manager
  100861. */
  100862. interface FreeCameraInputsManager {
  100863. /**
  100864. * Adds gamepad input support to the FreeCameraInputsManager.
  100865. * @returns the FreeCameraInputsManager
  100866. */
  100867. addGamepad(): FreeCameraInputsManager;
  100868. }
  100869. /**
  100870. * Interface representing an arc rotate camera inputs manager
  100871. */
  100872. interface ArcRotateCameraInputsManager {
  100873. /**
  100874. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100875. * @returns the camera inputs manager
  100876. */
  100877. addGamepad(): ArcRotateCameraInputsManager;
  100878. }
  100879. /**
  100880. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100881. */
  100882. export class GamepadSystemSceneComponent implements ISceneComponent {
  100883. /**
  100884. * The component name helpfull to identify the component in the list of scene components.
  100885. */
  100886. readonly name: string;
  100887. /**
  100888. * The scene the component belongs to.
  100889. */
  100890. scene: Scene;
  100891. /**
  100892. * Creates a new instance of the component for the given scene
  100893. * @param scene Defines the scene to register the component in
  100894. */
  100895. constructor(scene: Scene);
  100896. /**
  100897. * Registers the component in a given scene
  100898. */
  100899. register(): void;
  100900. /**
  100901. * Rebuilds the elements related to this component in case of
  100902. * context lost for instance.
  100903. */
  100904. rebuild(): void;
  100905. /**
  100906. * Disposes the component and the associated ressources
  100907. */
  100908. dispose(): void;
  100909. private _beforeCameraUpdate;
  100910. }
  100911. }
  100912. declare module BABYLON {
  100913. /**
  100914. * 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,
  100915. * which still works and will still be found in many Playgrounds.
  100916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100917. */
  100918. export class UniversalCamera extends TouchCamera {
  100919. /**
  100920. * Defines the gamepad rotation sensiblity.
  100921. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100922. */
  100923. gamepadAngularSensibility: number;
  100924. /**
  100925. * Defines the gamepad move sensiblity.
  100926. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100927. */
  100928. gamepadMoveSensibility: number;
  100929. /**
  100930. * 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,
  100931. * which still works and will still be found in many Playgrounds.
  100932. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100933. * @param name Define the name of the camera in the scene
  100934. * @param position Define the start position of the camera in the scene
  100935. * @param scene Define the scene the camera belongs to
  100936. */
  100937. constructor(name: string, position: Vector3, scene: Scene);
  100938. /**
  100939. * Gets the current object class name.
  100940. * @return the class name
  100941. */
  100942. getClassName(): string;
  100943. }
  100944. }
  100945. declare module BABYLON {
  100946. /**
  100947. * This represents a FPS type of camera. This is only here for back compat purpose.
  100948. * Please use the UniversalCamera instead as both are identical.
  100949. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100950. */
  100951. export class GamepadCamera extends UniversalCamera {
  100952. /**
  100953. * Instantiates a new Gamepad Camera
  100954. * This represents a FPS type of camera. This is only here for back compat purpose.
  100955. * Please use the UniversalCamera instead as both are identical.
  100956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100957. * @param name Define the name of the camera in the scene
  100958. * @param position Define the start position of the camera in the scene
  100959. * @param scene Define the scene the camera belongs to
  100960. */
  100961. constructor(name: string, position: Vector3, scene: Scene);
  100962. /**
  100963. * Gets the current object class name.
  100964. * @return the class name
  100965. */
  100966. getClassName(): string;
  100967. }
  100968. }
  100969. declare module BABYLON {
  100970. /** @hidden */
  100971. export var passPixelShader: {
  100972. name: string;
  100973. shader: string;
  100974. };
  100975. }
  100976. declare module BABYLON {
  100977. /** @hidden */
  100978. export var passCubePixelShader: {
  100979. name: string;
  100980. shader: string;
  100981. };
  100982. }
  100983. declare module BABYLON {
  100984. /**
  100985. * PassPostProcess which produces an output the same as it's input
  100986. */
  100987. export class PassPostProcess extends PostProcess {
  100988. /**
  100989. * Creates the PassPostProcess
  100990. * @param name The name of the effect.
  100991. * @param options The required width/height ratio to downsize to before computing the render pass.
  100992. * @param camera The camera to apply the render pass to.
  100993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100994. * @param engine The engine which the post process will be applied. (default: current engine)
  100995. * @param reusable If the post process can be reused on the same frame. (default: false)
  100996. * @param textureType The type of texture to be used when performing the post processing.
  100997. * @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)
  100998. */
  100999. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101000. }
  101001. /**
  101002. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101003. */
  101004. export class PassCubePostProcess extends PostProcess {
  101005. private _face;
  101006. /**
  101007. * Gets or sets the cube face to display.
  101008. * * 0 is +X
  101009. * * 1 is -X
  101010. * * 2 is +Y
  101011. * * 3 is -Y
  101012. * * 4 is +Z
  101013. * * 5 is -Z
  101014. */
  101015. face: number;
  101016. /**
  101017. * Creates the PassCubePostProcess
  101018. * @param name The name of the effect.
  101019. * @param options The required width/height ratio to downsize to before computing the render pass.
  101020. * @param camera The camera to apply the render pass to.
  101021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101022. * @param engine The engine which the post process will be applied. (default: current engine)
  101023. * @param reusable If the post process can be reused on the same frame. (default: false)
  101024. * @param textureType The type of texture to be used when performing the post processing.
  101025. * @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)
  101026. */
  101027. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101028. }
  101029. }
  101030. declare module BABYLON {
  101031. /** @hidden */
  101032. export var anaglyphPixelShader: {
  101033. name: string;
  101034. shader: string;
  101035. };
  101036. }
  101037. declare module BABYLON {
  101038. /**
  101039. * Postprocess used to generate anaglyphic rendering
  101040. */
  101041. export class AnaglyphPostProcess extends PostProcess {
  101042. private _passedProcess;
  101043. /**
  101044. * Creates a new AnaglyphPostProcess
  101045. * @param name defines postprocess name
  101046. * @param options defines creation options or target ratio scale
  101047. * @param rigCameras defines cameras using this postprocess
  101048. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101049. * @param engine defines hosting engine
  101050. * @param reusable defines if the postprocess will be reused multiple times per frame
  101051. */
  101052. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101053. }
  101054. }
  101055. declare module BABYLON {
  101056. /**
  101057. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101058. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101059. */
  101060. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101061. /**
  101062. * Creates a new AnaglyphArcRotateCamera
  101063. * @param name defines camera name
  101064. * @param alpha defines alpha angle (in radians)
  101065. * @param beta defines beta angle (in radians)
  101066. * @param radius defines radius
  101067. * @param target defines camera target
  101068. * @param interaxialDistance defines distance between each color axis
  101069. * @param scene defines the hosting scene
  101070. */
  101071. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101072. /**
  101073. * Gets camera class name
  101074. * @returns AnaglyphArcRotateCamera
  101075. */
  101076. getClassName(): string;
  101077. }
  101078. }
  101079. declare module BABYLON {
  101080. /**
  101081. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101082. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101083. */
  101084. export class AnaglyphFreeCamera extends FreeCamera {
  101085. /**
  101086. * Creates a new AnaglyphFreeCamera
  101087. * @param name defines camera name
  101088. * @param position defines initial position
  101089. * @param interaxialDistance defines distance between each color axis
  101090. * @param scene defines the hosting scene
  101091. */
  101092. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101093. /**
  101094. * Gets camera class name
  101095. * @returns AnaglyphFreeCamera
  101096. */
  101097. getClassName(): string;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /**
  101102. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101103. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101104. */
  101105. export class AnaglyphGamepadCamera extends GamepadCamera {
  101106. /**
  101107. * Creates a new AnaglyphGamepadCamera
  101108. * @param name defines camera name
  101109. * @param position defines initial position
  101110. * @param interaxialDistance defines distance between each color axis
  101111. * @param scene defines the hosting scene
  101112. */
  101113. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101114. /**
  101115. * Gets camera class name
  101116. * @returns AnaglyphGamepadCamera
  101117. */
  101118. getClassName(): string;
  101119. }
  101120. }
  101121. declare module BABYLON {
  101122. /**
  101123. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101124. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101125. */
  101126. export class AnaglyphUniversalCamera extends UniversalCamera {
  101127. /**
  101128. * Creates a new AnaglyphUniversalCamera
  101129. * @param name defines camera name
  101130. * @param position defines initial position
  101131. * @param interaxialDistance defines distance between each color axis
  101132. * @param scene defines the hosting scene
  101133. */
  101134. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101135. /**
  101136. * Gets camera class name
  101137. * @returns AnaglyphUniversalCamera
  101138. */
  101139. getClassName(): string;
  101140. }
  101141. }
  101142. declare module BABYLON {
  101143. /** @hidden */
  101144. export var stereoscopicInterlacePixelShader: {
  101145. name: string;
  101146. shader: string;
  101147. };
  101148. }
  101149. declare module BABYLON {
  101150. /**
  101151. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101152. */
  101153. export class StereoscopicInterlacePostProcess extends PostProcess {
  101154. private _stepSize;
  101155. private _passedProcess;
  101156. /**
  101157. * Initializes a StereoscopicInterlacePostProcess
  101158. * @param name The name of the effect.
  101159. * @param rigCameras The rig cameras to be appled to the post process
  101160. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101162. * @param engine The engine which the post process will be applied. (default: current engine)
  101163. * @param reusable If the post process can be reused on the same frame. (default: false)
  101164. */
  101165. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101166. }
  101167. }
  101168. declare module BABYLON {
  101169. /**
  101170. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101171. * @see http://doc.babylonjs.com/features/cameras
  101172. */
  101173. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101174. /**
  101175. * Creates a new StereoscopicArcRotateCamera
  101176. * @param name defines camera name
  101177. * @param alpha defines alpha angle (in radians)
  101178. * @param beta defines beta angle (in radians)
  101179. * @param radius defines radius
  101180. * @param target defines camera target
  101181. * @param interaxialDistance defines distance between each color axis
  101182. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101183. * @param scene defines the hosting scene
  101184. */
  101185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101186. /**
  101187. * Gets camera class name
  101188. * @returns StereoscopicArcRotateCamera
  101189. */
  101190. getClassName(): string;
  101191. }
  101192. }
  101193. declare module BABYLON {
  101194. /**
  101195. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101196. * @see http://doc.babylonjs.com/features/cameras
  101197. */
  101198. export class StereoscopicFreeCamera extends FreeCamera {
  101199. /**
  101200. * Creates a new StereoscopicFreeCamera
  101201. * @param name defines camera name
  101202. * @param position defines initial position
  101203. * @param interaxialDistance defines distance between each color axis
  101204. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101205. * @param scene defines the hosting scene
  101206. */
  101207. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101208. /**
  101209. * Gets camera class name
  101210. * @returns StereoscopicFreeCamera
  101211. */
  101212. getClassName(): string;
  101213. }
  101214. }
  101215. declare module BABYLON {
  101216. /**
  101217. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101218. * @see http://doc.babylonjs.com/features/cameras
  101219. */
  101220. export class StereoscopicGamepadCamera extends GamepadCamera {
  101221. /**
  101222. * Creates a new StereoscopicGamepadCamera
  101223. * @param name defines camera name
  101224. * @param position defines initial position
  101225. * @param interaxialDistance defines distance between each color axis
  101226. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101227. * @param scene defines the hosting scene
  101228. */
  101229. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101230. /**
  101231. * Gets camera class name
  101232. * @returns StereoscopicGamepadCamera
  101233. */
  101234. getClassName(): string;
  101235. }
  101236. }
  101237. declare module BABYLON {
  101238. /**
  101239. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101240. * @see http://doc.babylonjs.com/features/cameras
  101241. */
  101242. export class StereoscopicUniversalCamera extends UniversalCamera {
  101243. /**
  101244. * Creates a new StereoscopicUniversalCamera
  101245. * @param name defines camera name
  101246. * @param position defines initial position
  101247. * @param interaxialDistance defines distance between each color axis
  101248. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101249. * @param scene defines the hosting scene
  101250. */
  101251. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101252. /**
  101253. * Gets camera class name
  101254. * @returns StereoscopicUniversalCamera
  101255. */
  101256. getClassName(): string;
  101257. }
  101258. }
  101259. declare module BABYLON {
  101260. /**
  101261. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101262. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101263. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101264. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101265. */
  101266. export class VirtualJoysticksCamera extends FreeCamera {
  101267. /**
  101268. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101269. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101270. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101271. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101272. * @param name Define the name of the camera in the scene
  101273. * @param position Define the start position of the camera in the scene
  101274. * @param scene Define the scene the camera belongs to
  101275. */
  101276. constructor(name: string, position: Vector3, scene: Scene);
  101277. /**
  101278. * Gets the current object class name.
  101279. * @return the class name
  101280. */
  101281. getClassName(): string;
  101282. }
  101283. }
  101284. declare module BABYLON {
  101285. /**
  101286. * This represents all the required metrics to create a VR camera.
  101287. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101288. */
  101289. export class VRCameraMetrics {
  101290. /**
  101291. * Define the horizontal resolution off the screen.
  101292. */
  101293. hResolution: number;
  101294. /**
  101295. * Define the vertical resolution off the screen.
  101296. */
  101297. vResolution: number;
  101298. /**
  101299. * Define the horizontal screen size.
  101300. */
  101301. hScreenSize: number;
  101302. /**
  101303. * Define the vertical screen size.
  101304. */
  101305. vScreenSize: number;
  101306. /**
  101307. * Define the vertical screen center position.
  101308. */
  101309. vScreenCenter: number;
  101310. /**
  101311. * Define the distance of the eyes to the screen.
  101312. */
  101313. eyeToScreenDistance: number;
  101314. /**
  101315. * Define the distance between both lenses
  101316. */
  101317. lensSeparationDistance: number;
  101318. /**
  101319. * Define the distance between both viewer's eyes.
  101320. */
  101321. interpupillaryDistance: number;
  101322. /**
  101323. * Define the distortion factor of the VR postprocess.
  101324. * Please, touch with care.
  101325. */
  101326. distortionK: number[];
  101327. /**
  101328. * Define the chromatic aberration correction factors for the VR post process.
  101329. */
  101330. chromaAbCorrection: number[];
  101331. /**
  101332. * Define the scale factor of the post process.
  101333. * The smaller the better but the slower.
  101334. */
  101335. postProcessScaleFactor: number;
  101336. /**
  101337. * Define an offset for the lens center.
  101338. */
  101339. lensCenterOffset: number;
  101340. /**
  101341. * Define if the current vr camera should compensate the distortion of the lense or not.
  101342. */
  101343. compensateDistortion: boolean;
  101344. /**
  101345. * Defines if multiview should be enabled when rendering (Default: false)
  101346. */
  101347. multiviewEnabled: boolean;
  101348. /**
  101349. * Gets the rendering aspect ratio based on the provided resolutions.
  101350. */
  101351. readonly aspectRatio: number;
  101352. /**
  101353. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101354. */
  101355. readonly aspectRatioFov: number;
  101356. /**
  101357. * @hidden
  101358. */
  101359. readonly leftHMatrix: Matrix;
  101360. /**
  101361. * @hidden
  101362. */
  101363. readonly rightHMatrix: Matrix;
  101364. /**
  101365. * @hidden
  101366. */
  101367. readonly leftPreViewMatrix: Matrix;
  101368. /**
  101369. * @hidden
  101370. */
  101371. readonly rightPreViewMatrix: Matrix;
  101372. /**
  101373. * Get the default VRMetrics based on the most generic setup.
  101374. * @returns the default vr metrics
  101375. */
  101376. static GetDefault(): VRCameraMetrics;
  101377. }
  101378. }
  101379. declare module BABYLON {
  101380. /** @hidden */
  101381. export var vrDistortionCorrectionPixelShader: {
  101382. name: string;
  101383. shader: string;
  101384. };
  101385. }
  101386. declare module BABYLON {
  101387. /**
  101388. * VRDistortionCorrectionPostProcess used for mobile VR
  101389. */
  101390. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101391. private _isRightEye;
  101392. private _distortionFactors;
  101393. private _postProcessScaleFactor;
  101394. private _lensCenterOffset;
  101395. private _scaleIn;
  101396. private _scaleFactor;
  101397. private _lensCenter;
  101398. /**
  101399. * Initializes the VRDistortionCorrectionPostProcess
  101400. * @param name The name of the effect.
  101401. * @param camera The camera to apply the render pass to.
  101402. * @param isRightEye If this is for the right eye distortion
  101403. * @param vrMetrics All the required metrics for the VR camera
  101404. */
  101405. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101406. }
  101407. }
  101408. declare module BABYLON {
  101409. /**
  101410. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101411. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101412. */
  101413. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101414. /**
  101415. * Creates a new VRDeviceOrientationArcRotateCamera
  101416. * @param name defines camera name
  101417. * @param alpha defines the camera rotation along the logitudinal axis
  101418. * @param beta defines the camera rotation along the latitudinal axis
  101419. * @param radius defines the camera distance from its target
  101420. * @param target defines the camera target
  101421. * @param scene defines the scene the camera belongs to
  101422. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101423. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101424. */
  101425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101426. /**
  101427. * Gets camera class name
  101428. * @returns VRDeviceOrientationArcRotateCamera
  101429. */
  101430. getClassName(): string;
  101431. }
  101432. }
  101433. declare module BABYLON {
  101434. /**
  101435. * Camera used to simulate VR rendering (based on FreeCamera)
  101436. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101437. */
  101438. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101439. /**
  101440. * Creates a new VRDeviceOrientationFreeCamera
  101441. * @param name defines camera name
  101442. * @param position defines the start position of the camera
  101443. * @param scene defines the scene the camera belongs to
  101444. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101445. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101446. */
  101447. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101448. /**
  101449. * Gets camera class name
  101450. * @returns VRDeviceOrientationFreeCamera
  101451. */
  101452. getClassName(): string;
  101453. }
  101454. }
  101455. declare module BABYLON {
  101456. /**
  101457. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101458. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101459. */
  101460. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101461. /**
  101462. * Creates a new VRDeviceOrientationGamepadCamera
  101463. * @param name defines camera name
  101464. * @param position defines the start position of the camera
  101465. * @param scene defines the scene the camera belongs to
  101466. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101467. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101468. */
  101469. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101470. /**
  101471. * Gets camera class name
  101472. * @returns VRDeviceOrientationGamepadCamera
  101473. */
  101474. getClassName(): string;
  101475. }
  101476. }
  101477. declare module BABYLON {
  101478. /**
  101479. * Base class of materials working in push mode in babylon JS
  101480. * @hidden
  101481. */
  101482. export class PushMaterial extends Material {
  101483. protected _activeEffect: Effect;
  101484. protected _normalMatrix: Matrix;
  101485. /**
  101486. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101487. * This means that the material can keep using a previous shader while a new one is being compiled.
  101488. * This is mostly used when shader parallel compilation is supported (true by default)
  101489. */
  101490. allowShaderHotSwapping: boolean;
  101491. constructor(name: string, scene: Scene);
  101492. getEffect(): Effect;
  101493. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101494. /**
  101495. * Binds the given world matrix to the active effect
  101496. *
  101497. * @param world the matrix to bind
  101498. */
  101499. bindOnlyWorldMatrix(world: Matrix): void;
  101500. /**
  101501. * Binds the given normal matrix to the active effect
  101502. *
  101503. * @param normalMatrix the matrix to bind
  101504. */
  101505. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101506. bind(world: Matrix, mesh?: Mesh): void;
  101507. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101508. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101509. }
  101510. }
  101511. declare module BABYLON {
  101512. /**
  101513. * This groups all the flags used to control the materials channel.
  101514. */
  101515. export class MaterialFlags {
  101516. private static _DiffuseTextureEnabled;
  101517. /**
  101518. * Are diffuse textures enabled in the application.
  101519. */
  101520. static DiffuseTextureEnabled: boolean;
  101521. private static _AmbientTextureEnabled;
  101522. /**
  101523. * Are ambient textures enabled in the application.
  101524. */
  101525. static AmbientTextureEnabled: boolean;
  101526. private static _OpacityTextureEnabled;
  101527. /**
  101528. * Are opacity textures enabled in the application.
  101529. */
  101530. static OpacityTextureEnabled: boolean;
  101531. private static _ReflectionTextureEnabled;
  101532. /**
  101533. * Are reflection textures enabled in the application.
  101534. */
  101535. static ReflectionTextureEnabled: boolean;
  101536. private static _EmissiveTextureEnabled;
  101537. /**
  101538. * Are emissive textures enabled in the application.
  101539. */
  101540. static EmissiveTextureEnabled: boolean;
  101541. private static _SpecularTextureEnabled;
  101542. /**
  101543. * Are specular textures enabled in the application.
  101544. */
  101545. static SpecularTextureEnabled: boolean;
  101546. private static _BumpTextureEnabled;
  101547. /**
  101548. * Are bump textures enabled in the application.
  101549. */
  101550. static BumpTextureEnabled: boolean;
  101551. private static _LightmapTextureEnabled;
  101552. /**
  101553. * Are lightmap textures enabled in the application.
  101554. */
  101555. static LightmapTextureEnabled: boolean;
  101556. private static _RefractionTextureEnabled;
  101557. /**
  101558. * Are refraction textures enabled in the application.
  101559. */
  101560. static RefractionTextureEnabled: boolean;
  101561. private static _ColorGradingTextureEnabled;
  101562. /**
  101563. * Are color grading textures enabled in the application.
  101564. */
  101565. static ColorGradingTextureEnabled: boolean;
  101566. private static _FresnelEnabled;
  101567. /**
  101568. * Are fresnels enabled in the application.
  101569. */
  101570. static FresnelEnabled: boolean;
  101571. private static _ClearCoatTextureEnabled;
  101572. /**
  101573. * Are clear coat textures enabled in the application.
  101574. */
  101575. static ClearCoatTextureEnabled: boolean;
  101576. private static _ClearCoatBumpTextureEnabled;
  101577. /**
  101578. * Are clear coat bump textures enabled in the application.
  101579. */
  101580. static ClearCoatBumpTextureEnabled: boolean;
  101581. private static _ClearCoatTintTextureEnabled;
  101582. /**
  101583. * Are clear coat tint textures enabled in the application.
  101584. */
  101585. static ClearCoatTintTextureEnabled: boolean;
  101586. private static _SheenTextureEnabled;
  101587. /**
  101588. * Are sheen textures enabled in the application.
  101589. */
  101590. static SheenTextureEnabled: boolean;
  101591. private static _AnisotropicTextureEnabled;
  101592. /**
  101593. * Are anisotropic textures enabled in the application.
  101594. */
  101595. static AnisotropicTextureEnabled: boolean;
  101596. private static _ThicknessTextureEnabled;
  101597. /**
  101598. * Are thickness textures enabled in the application.
  101599. */
  101600. static ThicknessTextureEnabled: boolean;
  101601. }
  101602. }
  101603. declare module BABYLON {
  101604. /** @hidden */
  101605. export var defaultFragmentDeclaration: {
  101606. name: string;
  101607. shader: string;
  101608. };
  101609. }
  101610. declare module BABYLON {
  101611. /** @hidden */
  101612. export var defaultUboDeclaration: {
  101613. name: string;
  101614. shader: string;
  101615. };
  101616. }
  101617. declare module BABYLON {
  101618. /** @hidden */
  101619. export var lightFragmentDeclaration: {
  101620. name: string;
  101621. shader: string;
  101622. };
  101623. }
  101624. declare module BABYLON {
  101625. /** @hidden */
  101626. export var lightUboDeclaration: {
  101627. name: string;
  101628. shader: string;
  101629. };
  101630. }
  101631. declare module BABYLON {
  101632. /** @hidden */
  101633. export var lightsFragmentFunctions: {
  101634. name: string;
  101635. shader: string;
  101636. };
  101637. }
  101638. declare module BABYLON {
  101639. /** @hidden */
  101640. export var shadowsFragmentFunctions: {
  101641. name: string;
  101642. shader: string;
  101643. };
  101644. }
  101645. declare module BABYLON {
  101646. /** @hidden */
  101647. export var fresnelFunction: {
  101648. name: string;
  101649. shader: string;
  101650. };
  101651. }
  101652. declare module BABYLON {
  101653. /** @hidden */
  101654. export var reflectionFunction: {
  101655. name: string;
  101656. shader: string;
  101657. };
  101658. }
  101659. declare module BABYLON {
  101660. /** @hidden */
  101661. export var bumpFragmentFunctions: {
  101662. name: string;
  101663. shader: string;
  101664. };
  101665. }
  101666. declare module BABYLON {
  101667. /** @hidden */
  101668. export var logDepthDeclaration: {
  101669. name: string;
  101670. shader: string;
  101671. };
  101672. }
  101673. declare module BABYLON {
  101674. /** @hidden */
  101675. export var bumpFragment: {
  101676. name: string;
  101677. shader: string;
  101678. };
  101679. }
  101680. declare module BABYLON {
  101681. /** @hidden */
  101682. export var depthPrePass: {
  101683. name: string;
  101684. shader: string;
  101685. };
  101686. }
  101687. declare module BABYLON {
  101688. /** @hidden */
  101689. export var lightFragment: {
  101690. name: string;
  101691. shader: string;
  101692. };
  101693. }
  101694. declare module BABYLON {
  101695. /** @hidden */
  101696. export var logDepthFragment: {
  101697. name: string;
  101698. shader: string;
  101699. };
  101700. }
  101701. declare module BABYLON {
  101702. /** @hidden */
  101703. export var defaultPixelShader: {
  101704. name: string;
  101705. shader: string;
  101706. };
  101707. }
  101708. declare module BABYLON {
  101709. /** @hidden */
  101710. export var defaultVertexDeclaration: {
  101711. name: string;
  101712. shader: string;
  101713. };
  101714. }
  101715. declare module BABYLON {
  101716. /** @hidden */
  101717. export var bumpVertexDeclaration: {
  101718. name: string;
  101719. shader: string;
  101720. };
  101721. }
  101722. declare module BABYLON {
  101723. /** @hidden */
  101724. export var bumpVertex: {
  101725. name: string;
  101726. shader: string;
  101727. };
  101728. }
  101729. declare module BABYLON {
  101730. /** @hidden */
  101731. export var fogVertex: {
  101732. name: string;
  101733. shader: string;
  101734. };
  101735. }
  101736. declare module BABYLON {
  101737. /** @hidden */
  101738. export var shadowsVertex: {
  101739. name: string;
  101740. shader: string;
  101741. };
  101742. }
  101743. declare module BABYLON {
  101744. /** @hidden */
  101745. export var pointCloudVertex: {
  101746. name: string;
  101747. shader: string;
  101748. };
  101749. }
  101750. declare module BABYLON {
  101751. /** @hidden */
  101752. export var logDepthVertex: {
  101753. name: string;
  101754. shader: string;
  101755. };
  101756. }
  101757. declare module BABYLON {
  101758. /** @hidden */
  101759. export var defaultVertexShader: {
  101760. name: string;
  101761. shader: string;
  101762. };
  101763. }
  101764. declare module BABYLON {
  101765. /** @hidden */
  101766. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101767. MAINUV1: boolean;
  101768. MAINUV2: boolean;
  101769. DIFFUSE: boolean;
  101770. DIFFUSEDIRECTUV: number;
  101771. AMBIENT: boolean;
  101772. AMBIENTDIRECTUV: number;
  101773. OPACITY: boolean;
  101774. OPACITYDIRECTUV: number;
  101775. OPACITYRGB: boolean;
  101776. REFLECTION: boolean;
  101777. EMISSIVE: boolean;
  101778. EMISSIVEDIRECTUV: number;
  101779. SPECULAR: boolean;
  101780. SPECULARDIRECTUV: number;
  101781. BUMP: boolean;
  101782. BUMPDIRECTUV: number;
  101783. PARALLAX: boolean;
  101784. PARALLAXOCCLUSION: boolean;
  101785. SPECULAROVERALPHA: boolean;
  101786. CLIPPLANE: boolean;
  101787. CLIPPLANE2: boolean;
  101788. CLIPPLANE3: boolean;
  101789. CLIPPLANE4: boolean;
  101790. ALPHATEST: boolean;
  101791. DEPTHPREPASS: boolean;
  101792. ALPHAFROMDIFFUSE: boolean;
  101793. POINTSIZE: boolean;
  101794. FOG: boolean;
  101795. SPECULARTERM: boolean;
  101796. DIFFUSEFRESNEL: boolean;
  101797. OPACITYFRESNEL: boolean;
  101798. REFLECTIONFRESNEL: boolean;
  101799. REFRACTIONFRESNEL: boolean;
  101800. EMISSIVEFRESNEL: boolean;
  101801. FRESNEL: boolean;
  101802. NORMAL: boolean;
  101803. UV1: boolean;
  101804. UV2: boolean;
  101805. VERTEXCOLOR: boolean;
  101806. VERTEXALPHA: boolean;
  101807. NUM_BONE_INFLUENCERS: number;
  101808. BonesPerMesh: number;
  101809. BONETEXTURE: boolean;
  101810. INSTANCES: boolean;
  101811. GLOSSINESS: boolean;
  101812. ROUGHNESS: boolean;
  101813. EMISSIVEASILLUMINATION: boolean;
  101814. LINKEMISSIVEWITHDIFFUSE: boolean;
  101815. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101816. LIGHTMAP: boolean;
  101817. LIGHTMAPDIRECTUV: number;
  101818. OBJECTSPACE_NORMALMAP: boolean;
  101819. USELIGHTMAPASSHADOWMAP: boolean;
  101820. REFLECTIONMAP_3D: boolean;
  101821. REFLECTIONMAP_SPHERICAL: boolean;
  101822. REFLECTIONMAP_PLANAR: boolean;
  101823. REFLECTIONMAP_CUBIC: boolean;
  101824. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101825. REFLECTIONMAP_PROJECTION: boolean;
  101826. REFLECTIONMAP_SKYBOX: boolean;
  101827. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101828. REFLECTIONMAP_EXPLICIT: boolean;
  101829. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101830. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101831. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101832. INVERTCUBICMAP: boolean;
  101833. LOGARITHMICDEPTH: boolean;
  101834. REFRACTION: boolean;
  101835. REFRACTIONMAP_3D: boolean;
  101836. REFLECTIONOVERALPHA: boolean;
  101837. TWOSIDEDLIGHTING: boolean;
  101838. SHADOWFLOAT: boolean;
  101839. MORPHTARGETS: boolean;
  101840. MORPHTARGETS_NORMAL: boolean;
  101841. MORPHTARGETS_TANGENT: boolean;
  101842. MORPHTARGETS_UV: boolean;
  101843. NUM_MORPH_INFLUENCERS: number;
  101844. NONUNIFORMSCALING: boolean;
  101845. PREMULTIPLYALPHA: boolean;
  101846. IMAGEPROCESSING: boolean;
  101847. VIGNETTE: boolean;
  101848. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101849. VIGNETTEBLENDMODEOPAQUE: boolean;
  101850. TONEMAPPING: boolean;
  101851. TONEMAPPING_ACES: boolean;
  101852. CONTRAST: boolean;
  101853. COLORCURVES: boolean;
  101854. COLORGRADING: boolean;
  101855. COLORGRADING3D: boolean;
  101856. SAMPLER3DGREENDEPTH: boolean;
  101857. SAMPLER3DBGRMAP: boolean;
  101858. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101859. MULTIVIEW: boolean;
  101860. /**
  101861. * If the reflection texture on this material is in linear color space
  101862. * @hidden
  101863. */
  101864. IS_REFLECTION_LINEAR: boolean;
  101865. /**
  101866. * If the refraction texture on this material is in linear color space
  101867. * @hidden
  101868. */
  101869. IS_REFRACTION_LINEAR: boolean;
  101870. EXPOSURE: boolean;
  101871. constructor();
  101872. setReflectionMode(modeToEnable: string): void;
  101873. }
  101874. /**
  101875. * This is the default material used in Babylon. It is the best trade off between quality
  101876. * and performances.
  101877. * @see http://doc.babylonjs.com/babylon101/materials
  101878. */
  101879. export class StandardMaterial extends PushMaterial {
  101880. private _diffuseTexture;
  101881. /**
  101882. * The basic texture of the material as viewed under a light.
  101883. */
  101884. diffuseTexture: Nullable<BaseTexture>;
  101885. private _ambientTexture;
  101886. /**
  101887. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101888. */
  101889. ambientTexture: Nullable<BaseTexture>;
  101890. private _opacityTexture;
  101891. /**
  101892. * Define the transparency of the material from a texture.
  101893. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101894. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101895. */
  101896. opacityTexture: Nullable<BaseTexture>;
  101897. private _reflectionTexture;
  101898. /**
  101899. * Define the texture used to display the reflection.
  101900. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101901. */
  101902. reflectionTexture: Nullable<BaseTexture>;
  101903. private _emissiveTexture;
  101904. /**
  101905. * Define texture of the material as if self lit.
  101906. * This will be mixed in the final result even in the absence of light.
  101907. */
  101908. emissiveTexture: Nullable<BaseTexture>;
  101909. private _specularTexture;
  101910. /**
  101911. * Define how the color and intensity of the highlight given by the light in the material.
  101912. */
  101913. specularTexture: Nullable<BaseTexture>;
  101914. private _bumpTexture;
  101915. /**
  101916. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101917. * 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.
  101918. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101919. */
  101920. bumpTexture: Nullable<BaseTexture>;
  101921. private _lightmapTexture;
  101922. /**
  101923. * Complex lighting can be computationally expensive to compute at runtime.
  101924. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101925. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101926. */
  101927. lightmapTexture: Nullable<BaseTexture>;
  101928. private _refractionTexture;
  101929. /**
  101930. * Define the texture used to display the refraction.
  101931. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101932. */
  101933. refractionTexture: Nullable<BaseTexture>;
  101934. /**
  101935. * The color of the material lit by the environmental background lighting.
  101936. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101937. */
  101938. ambientColor: Color3;
  101939. /**
  101940. * The basic color of the material as viewed under a light.
  101941. */
  101942. diffuseColor: Color3;
  101943. /**
  101944. * Define how the color and intensity of the highlight given by the light in the material.
  101945. */
  101946. specularColor: Color3;
  101947. /**
  101948. * Define the color of the material as if self lit.
  101949. * This will be mixed in the final result even in the absence of light.
  101950. */
  101951. emissiveColor: Color3;
  101952. /**
  101953. * Defines how sharp are the highlights in the material.
  101954. * The bigger the value the sharper giving a more glossy feeling to the result.
  101955. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101956. */
  101957. specularPower: number;
  101958. private _useAlphaFromDiffuseTexture;
  101959. /**
  101960. * Does the transparency come from the diffuse texture alpha channel.
  101961. */
  101962. useAlphaFromDiffuseTexture: boolean;
  101963. private _useEmissiveAsIllumination;
  101964. /**
  101965. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101966. */
  101967. useEmissiveAsIllumination: boolean;
  101968. private _linkEmissiveWithDiffuse;
  101969. /**
  101970. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101971. * the emissive level when the final color is close to one.
  101972. */
  101973. linkEmissiveWithDiffuse: boolean;
  101974. private _useSpecularOverAlpha;
  101975. /**
  101976. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101977. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101978. */
  101979. useSpecularOverAlpha: boolean;
  101980. private _useReflectionOverAlpha;
  101981. /**
  101982. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101983. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101984. */
  101985. useReflectionOverAlpha: boolean;
  101986. private _disableLighting;
  101987. /**
  101988. * Does lights from the scene impacts this material.
  101989. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101990. */
  101991. disableLighting: boolean;
  101992. private _useObjectSpaceNormalMap;
  101993. /**
  101994. * Allows using an object space normal map (instead of tangent space).
  101995. */
  101996. useObjectSpaceNormalMap: boolean;
  101997. private _useParallax;
  101998. /**
  101999. * Is parallax enabled or not.
  102000. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102001. */
  102002. useParallax: boolean;
  102003. private _useParallaxOcclusion;
  102004. /**
  102005. * Is parallax occlusion enabled or not.
  102006. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102007. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102008. */
  102009. useParallaxOcclusion: boolean;
  102010. /**
  102011. * 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.
  102012. */
  102013. parallaxScaleBias: number;
  102014. private _roughness;
  102015. /**
  102016. * Helps to define how blurry the reflections should appears in the material.
  102017. */
  102018. roughness: number;
  102019. /**
  102020. * In case of refraction, define the value of the index of refraction.
  102021. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102022. */
  102023. indexOfRefraction: number;
  102024. /**
  102025. * Invert the refraction texture alongside the y axis.
  102026. * It can be useful with procedural textures or probe for instance.
  102027. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102028. */
  102029. invertRefractionY: boolean;
  102030. /**
  102031. * Defines the alpha limits in alpha test mode.
  102032. */
  102033. alphaCutOff: number;
  102034. private _useLightmapAsShadowmap;
  102035. /**
  102036. * In case of light mapping, define whether the map contains light or shadow informations.
  102037. */
  102038. useLightmapAsShadowmap: boolean;
  102039. private _diffuseFresnelParameters;
  102040. /**
  102041. * Define the diffuse fresnel parameters of the material.
  102042. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102043. */
  102044. diffuseFresnelParameters: FresnelParameters;
  102045. private _opacityFresnelParameters;
  102046. /**
  102047. * Define the opacity fresnel parameters of the material.
  102048. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102049. */
  102050. opacityFresnelParameters: FresnelParameters;
  102051. private _reflectionFresnelParameters;
  102052. /**
  102053. * Define the reflection fresnel parameters of the material.
  102054. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102055. */
  102056. reflectionFresnelParameters: FresnelParameters;
  102057. private _refractionFresnelParameters;
  102058. /**
  102059. * Define the refraction fresnel parameters of the material.
  102060. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102061. */
  102062. refractionFresnelParameters: FresnelParameters;
  102063. private _emissiveFresnelParameters;
  102064. /**
  102065. * Define the emissive fresnel parameters of the material.
  102066. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102067. */
  102068. emissiveFresnelParameters: FresnelParameters;
  102069. private _useReflectionFresnelFromSpecular;
  102070. /**
  102071. * If true automatically deducts the fresnels values from the material specularity.
  102072. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102073. */
  102074. useReflectionFresnelFromSpecular: boolean;
  102075. private _useGlossinessFromSpecularMapAlpha;
  102076. /**
  102077. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102078. */
  102079. useGlossinessFromSpecularMapAlpha: boolean;
  102080. private _maxSimultaneousLights;
  102081. /**
  102082. * Defines the maximum number of lights that can be used in the material
  102083. */
  102084. maxSimultaneousLights: number;
  102085. private _invertNormalMapX;
  102086. /**
  102087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102088. */
  102089. invertNormalMapX: boolean;
  102090. private _invertNormalMapY;
  102091. /**
  102092. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102093. */
  102094. invertNormalMapY: boolean;
  102095. private _twoSidedLighting;
  102096. /**
  102097. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102098. */
  102099. twoSidedLighting: boolean;
  102100. /**
  102101. * Default configuration related to image processing available in the standard Material.
  102102. */
  102103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102104. /**
  102105. * Gets the image processing configuration used either in this material.
  102106. */
  102107. /**
  102108. * Sets the Default image processing configuration used either in the this material.
  102109. *
  102110. * If sets to null, the scene one is in use.
  102111. */
  102112. imageProcessingConfiguration: ImageProcessingConfiguration;
  102113. /**
  102114. * Keep track of the image processing observer to allow dispose and replace.
  102115. */
  102116. private _imageProcessingObserver;
  102117. /**
  102118. * Attaches a new image processing configuration to the Standard Material.
  102119. * @param configuration
  102120. */
  102121. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102122. /**
  102123. * Gets wether the color curves effect is enabled.
  102124. */
  102125. /**
  102126. * Sets wether the color curves effect is enabled.
  102127. */
  102128. cameraColorCurvesEnabled: boolean;
  102129. /**
  102130. * Gets wether the color grading effect is enabled.
  102131. */
  102132. /**
  102133. * Gets wether the color grading effect is enabled.
  102134. */
  102135. cameraColorGradingEnabled: boolean;
  102136. /**
  102137. * Gets wether tonemapping is enabled or not.
  102138. */
  102139. /**
  102140. * Sets wether tonemapping is enabled or not
  102141. */
  102142. cameraToneMappingEnabled: boolean;
  102143. /**
  102144. * The camera exposure used on this material.
  102145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102146. * This corresponds to a photographic exposure.
  102147. */
  102148. /**
  102149. * The camera exposure used on this material.
  102150. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102151. * This corresponds to a photographic exposure.
  102152. */
  102153. cameraExposure: number;
  102154. /**
  102155. * Gets The camera contrast used on this material.
  102156. */
  102157. /**
  102158. * Sets The camera contrast used on this material.
  102159. */
  102160. cameraContrast: number;
  102161. /**
  102162. * Gets the Color Grading 2D Lookup Texture.
  102163. */
  102164. /**
  102165. * Sets the Color Grading 2D Lookup Texture.
  102166. */
  102167. cameraColorGradingTexture: Nullable<BaseTexture>;
  102168. /**
  102169. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102170. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102171. * 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;
  102172. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102173. */
  102174. /**
  102175. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102176. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102177. * 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;
  102178. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102179. */
  102180. cameraColorCurves: Nullable<ColorCurves>;
  102181. /**
  102182. * Custom callback helping to override the default shader used in the material.
  102183. */
  102184. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102185. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102186. protected _worldViewProjectionMatrix: Matrix;
  102187. protected _globalAmbientColor: Color3;
  102188. protected _useLogarithmicDepth: boolean;
  102189. /**
  102190. * Instantiates a new standard material.
  102191. * This is the default material used in Babylon. It is the best trade off between quality
  102192. * and performances.
  102193. * @see http://doc.babylonjs.com/babylon101/materials
  102194. * @param name Define the name of the material in the scene
  102195. * @param scene Define the scene the material belong to
  102196. */
  102197. constructor(name: string, scene: Scene);
  102198. /**
  102199. * Gets a boolean indicating that current material needs to register RTT
  102200. */
  102201. readonly hasRenderTargetTextures: boolean;
  102202. /**
  102203. * Gets the current class name of the material e.g. "StandardMaterial"
  102204. * Mainly use in serialization.
  102205. * @returns the class name
  102206. */
  102207. getClassName(): string;
  102208. /**
  102209. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102210. * You can try switching to logarithmic depth.
  102211. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102212. */
  102213. useLogarithmicDepth: boolean;
  102214. /**
  102215. * Specifies if the material will require alpha blending
  102216. * @returns a boolean specifying if alpha blending is needed
  102217. */
  102218. needAlphaBlending(): boolean;
  102219. /**
  102220. * Specifies if this material should be rendered in alpha test mode
  102221. * @returns a boolean specifying if an alpha test is needed.
  102222. */
  102223. needAlphaTesting(): boolean;
  102224. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102225. /**
  102226. * Get the texture used for alpha test purpose.
  102227. * @returns the diffuse texture in case of the standard material.
  102228. */
  102229. getAlphaTestTexture(): Nullable<BaseTexture>;
  102230. /**
  102231. * Get if the submesh is ready to be used and all its information available.
  102232. * Child classes can use it to update shaders
  102233. * @param mesh defines the mesh to check
  102234. * @param subMesh defines which submesh to check
  102235. * @param useInstances specifies that instances should be used
  102236. * @returns a boolean indicating that the submesh is ready or not
  102237. */
  102238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102239. /**
  102240. * Builds the material UBO layouts.
  102241. * Used internally during the effect preparation.
  102242. */
  102243. buildUniformLayout(): void;
  102244. /**
  102245. * Unbinds the material from the mesh
  102246. */
  102247. unbind(): void;
  102248. /**
  102249. * Binds the submesh to this material by preparing the effect and shader to draw
  102250. * @param world defines the world transformation matrix
  102251. * @param mesh defines the mesh containing the submesh
  102252. * @param subMesh defines the submesh to bind the material to
  102253. */
  102254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102255. /**
  102256. * Get the list of animatables in the material.
  102257. * @returns the list of animatables object used in the material
  102258. */
  102259. getAnimatables(): IAnimatable[];
  102260. /**
  102261. * Gets the active textures from the material
  102262. * @returns an array of textures
  102263. */
  102264. getActiveTextures(): BaseTexture[];
  102265. /**
  102266. * Specifies if the material uses a texture
  102267. * @param texture defines the texture to check against the material
  102268. * @returns a boolean specifying if the material uses the texture
  102269. */
  102270. hasTexture(texture: BaseTexture): boolean;
  102271. /**
  102272. * Disposes the material
  102273. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102274. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102275. */
  102276. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102277. /**
  102278. * Makes a duplicate of the material, and gives it a new name
  102279. * @param name defines the new name for the duplicated material
  102280. * @returns the cloned material
  102281. */
  102282. clone(name: string): StandardMaterial;
  102283. /**
  102284. * Serializes this material in a JSON representation
  102285. * @returns the serialized material object
  102286. */
  102287. serialize(): any;
  102288. /**
  102289. * Creates a standard material from parsed material data
  102290. * @param source defines the JSON representation of the material
  102291. * @param scene defines the hosting scene
  102292. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102293. * @returns a new standard material
  102294. */
  102295. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102296. /**
  102297. * Are diffuse textures enabled in the application.
  102298. */
  102299. static DiffuseTextureEnabled: boolean;
  102300. /**
  102301. * Are ambient textures enabled in the application.
  102302. */
  102303. static AmbientTextureEnabled: boolean;
  102304. /**
  102305. * Are opacity textures enabled in the application.
  102306. */
  102307. static OpacityTextureEnabled: boolean;
  102308. /**
  102309. * Are reflection textures enabled in the application.
  102310. */
  102311. static ReflectionTextureEnabled: boolean;
  102312. /**
  102313. * Are emissive textures enabled in the application.
  102314. */
  102315. static EmissiveTextureEnabled: boolean;
  102316. /**
  102317. * Are specular textures enabled in the application.
  102318. */
  102319. static SpecularTextureEnabled: boolean;
  102320. /**
  102321. * Are bump textures enabled in the application.
  102322. */
  102323. static BumpTextureEnabled: boolean;
  102324. /**
  102325. * Are lightmap textures enabled in the application.
  102326. */
  102327. static LightmapTextureEnabled: boolean;
  102328. /**
  102329. * Are refraction textures enabled in the application.
  102330. */
  102331. static RefractionTextureEnabled: boolean;
  102332. /**
  102333. * Are color grading textures enabled in the application.
  102334. */
  102335. static ColorGradingTextureEnabled: boolean;
  102336. /**
  102337. * Are fresnels enabled in the application.
  102338. */
  102339. static FresnelEnabled: boolean;
  102340. }
  102341. }
  102342. declare module BABYLON {
  102343. /**
  102344. * A class extending Texture allowing drawing on a texture
  102345. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102346. */
  102347. export class DynamicTexture extends Texture {
  102348. private _generateMipMaps;
  102349. private _canvas;
  102350. private _context;
  102351. private _engine;
  102352. /**
  102353. * Creates a DynamicTexture
  102354. * @param name defines the name of the texture
  102355. * @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
  102356. * @param scene defines the scene where you want the texture
  102357. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102358. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102359. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102360. */
  102361. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102362. /**
  102363. * Get the current class name of the texture useful for serialization or dynamic coding.
  102364. * @returns "DynamicTexture"
  102365. */
  102366. getClassName(): string;
  102367. /**
  102368. * Gets the current state of canRescale
  102369. */
  102370. readonly canRescale: boolean;
  102371. private _recreate;
  102372. /**
  102373. * Scales the texture
  102374. * @param ratio the scale factor to apply to both width and height
  102375. */
  102376. scale(ratio: number): void;
  102377. /**
  102378. * Resizes the texture
  102379. * @param width the new width
  102380. * @param height the new height
  102381. */
  102382. scaleTo(width: number, height: number): void;
  102383. /**
  102384. * Gets the context of the canvas used by the texture
  102385. * @returns the canvas context of the dynamic texture
  102386. */
  102387. getContext(): CanvasRenderingContext2D;
  102388. /**
  102389. * Clears the texture
  102390. */
  102391. clear(): void;
  102392. /**
  102393. * Updates the texture
  102394. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102395. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102396. */
  102397. update(invertY?: boolean, premulAlpha?: boolean): void;
  102398. /**
  102399. * Draws text onto the texture
  102400. * @param text defines the text to be drawn
  102401. * @param x defines the placement of the text from the left
  102402. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102403. * @param font defines the font to be used with font-style, font-size, font-name
  102404. * @param color defines the color used for the text
  102405. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102406. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102407. * @param update defines whether texture is immediately update (default is true)
  102408. */
  102409. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102410. /**
  102411. * Clones the texture
  102412. * @returns the clone of the texture.
  102413. */
  102414. clone(): DynamicTexture;
  102415. /**
  102416. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102417. * @returns a serialized dynamic texture object
  102418. */
  102419. serialize(): any;
  102420. /** @hidden */
  102421. _rebuild(): void;
  102422. }
  102423. }
  102424. declare module BABYLON {
  102425. /** @hidden */
  102426. export var imageProcessingPixelShader: {
  102427. name: string;
  102428. shader: string;
  102429. };
  102430. }
  102431. declare module BABYLON {
  102432. /**
  102433. * ImageProcessingPostProcess
  102434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102435. */
  102436. export class ImageProcessingPostProcess extends PostProcess {
  102437. /**
  102438. * Default configuration related to image processing available in the PBR Material.
  102439. */
  102440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102441. /**
  102442. * Gets the image processing configuration used either in this material.
  102443. */
  102444. /**
  102445. * Sets the Default image processing configuration used either in the this material.
  102446. *
  102447. * If sets to null, the scene one is in use.
  102448. */
  102449. imageProcessingConfiguration: ImageProcessingConfiguration;
  102450. /**
  102451. * Keep track of the image processing observer to allow dispose and replace.
  102452. */
  102453. private _imageProcessingObserver;
  102454. /**
  102455. * Attaches a new image processing configuration to the PBR Material.
  102456. * @param configuration
  102457. */
  102458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102459. /**
  102460. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102461. */
  102462. /**
  102463. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102464. */
  102465. colorCurves: Nullable<ColorCurves>;
  102466. /**
  102467. * Gets wether the color curves effect is enabled.
  102468. */
  102469. /**
  102470. * Sets wether the color curves effect is enabled.
  102471. */
  102472. colorCurvesEnabled: boolean;
  102473. /**
  102474. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102475. */
  102476. /**
  102477. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102478. */
  102479. colorGradingTexture: Nullable<BaseTexture>;
  102480. /**
  102481. * Gets wether the color grading effect is enabled.
  102482. */
  102483. /**
  102484. * Gets wether the color grading effect is enabled.
  102485. */
  102486. colorGradingEnabled: boolean;
  102487. /**
  102488. * Gets exposure used in the effect.
  102489. */
  102490. /**
  102491. * Sets exposure used in the effect.
  102492. */
  102493. exposure: number;
  102494. /**
  102495. * Gets wether tonemapping is enabled or not.
  102496. */
  102497. /**
  102498. * Sets wether tonemapping is enabled or not
  102499. */
  102500. toneMappingEnabled: boolean;
  102501. /**
  102502. * Gets the type of tone mapping effect.
  102503. */
  102504. /**
  102505. * Sets the type of tone mapping effect.
  102506. */
  102507. toneMappingType: number;
  102508. /**
  102509. * Gets contrast used in the effect.
  102510. */
  102511. /**
  102512. * Sets contrast used in the effect.
  102513. */
  102514. contrast: number;
  102515. /**
  102516. * Gets Vignette stretch size.
  102517. */
  102518. /**
  102519. * Sets Vignette stretch size.
  102520. */
  102521. vignetteStretch: number;
  102522. /**
  102523. * Gets Vignette centre X Offset.
  102524. */
  102525. /**
  102526. * Sets Vignette centre X Offset.
  102527. */
  102528. vignetteCentreX: number;
  102529. /**
  102530. * Gets Vignette centre Y Offset.
  102531. */
  102532. /**
  102533. * Sets Vignette centre Y Offset.
  102534. */
  102535. vignetteCentreY: number;
  102536. /**
  102537. * Gets Vignette weight or intensity of the vignette effect.
  102538. */
  102539. /**
  102540. * Sets Vignette weight or intensity of the vignette effect.
  102541. */
  102542. vignetteWeight: number;
  102543. /**
  102544. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102545. * if vignetteEnabled is set to true.
  102546. */
  102547. /**
  102548. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102549. * if vignetteEnabled is set to true.
  102550. */
  102551. vignetteColor: Color4;
  102552. /**
  102553. * Gets Camera field of view used by the Vignette effect.
  102554. */
  102555. /**
  102556. * Sets Camera field of view used by the Vignette effect.
  102557. */
  102558. vignetteCameraFov: number;
  102559. /**
  102560. * Gets the vignette blend mode allowing different kind of effect.
  102561. */
  102562. /**
  102563. * Sets the vignette blend mode allowing different kind of effect.
  102564. */
  102565. vignetteBlendMode: number;
  102566. /**
  102567. * Gets wether the vignette effect is enabled.
  102568. */
  102569. /**
  102570. * Sets wether the vignette effect is enabled.
  102571. */
  102572. vignetteEnabled: boolean;
  102573. private _fromLinearSpace;
  102574. /**
  102575. * Gets wether the input of the processing is in Gamma or Linear Space.
  102576. */
  102577. /**
  102578. * Sets wether the input of the processing is in Gamma or Linear Space.
  102579. */
  102580. fromLinearSpace: boolean;
  102581. /**
  102582. * Defines cache preventing GC.
  102583. */
  102584. private _defines;
  102585. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102586. /**
  102587. * "ImageProcessingPostProcess"
  102588. * @returns "ImageProcessingPostProcess"
  102589. */
  102590. getClassName(): string;
  102591. protected _updateParameters(): void;
  102592. dispose(camera?: Camera): void;
  102593. }
  102594. }
  102595. declare module BABYLON {
  102596. /**
  102597. * Class containing static functions to help procedurally build meshes
  102598. */
  102599. export class GroundBuilder {
  102600. /**
  102601. * Creates a ground mesh
  102602. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102603. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102605. * @param name defines the name of the mesh
  102606. * @param options defines the options used to create the mesh
  102607. * @param scene defines the hosting scene
  102608. * @returns the ground mesh
  102609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102610. */
  102611. static CreateGround(name: string, options: {
  102612. width?: number;
  102613. height?: number;
  102614. subdivisions?: number;
  102615. subdivisionsX?: number;
  102616. subdivisionsY?: number;
  102617. updatable?: boolean;
  102618. }, scene: any): Mesh;
  102619. /**
  102620. * Creates a tiled ground mesh
  102621. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102622. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102623. * * 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
  102624. * * 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
  102625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102626. * @param name defines the name of the mesh
  102627. * @param options defines the options used to create the mesh
  102628. * @param scene defines the hosting scene
  102629. * @returns the tiled ground mesh
  102630. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102631. */
  102632. static CreateTiledGround(name: string, options: {
  102633. xmin: number;
  102634. zmin: number;
  102635. xmax: number;
  102636. zmax: number;
  102637. subdivisions?: {
  102638. w: number;
  102639. h: number;
  102640. };
  102641. precision?: {
  102642. w: number;
  102643. h: number;
  102644. };
  102645. updatable?: boolean;
  102646. }, scene?: Nullable<Scene>): Mesh;
  102647. /**
  102648. * Creates a ground mesh from a height map
  102649. * * The parameter `url` sets the URL of the height map image resource.
  102650. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102651. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102652. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102653. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102654. * * 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.
  102655. * * 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).
  102656. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102658. * @param name defines the name of the mesh
  102659. * @param url defines the url to the height map
  102660. * @param options defines the options used to create the mesh
  102661. * @param scene defines the hosting scene
  102662. * @returns the ground mesh
  102663. * @see https://doc.babylonjs.com/babylon101/height_map
  102664. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102665. */
  102666. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102667. width?: number;
  102668. height?: number;
  102669. subdivisions?: number;
  102670. minHeight?: number;
  102671. maxHeight?: number;
  102672. colorFilter?: Color3;
  102673. alphaFilter?: number;
  102674. updatable?: boolean;
  102675. onReady?: (mesh: GroundMesh) => void;
  102676. }, scene?: Nullable<Scene>): GroundMesh;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * Class containing static functions to help procedurally build meshes
  102682. */
  102683. export class TorusBuilder {
  102684. /**
  102685. * Creates a torus mesh
  102686. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102687. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102688. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102692. * @param name defines the name of the mesh
  102693. * @param options defines the options used to create the mesh
  102694. * @param scene defines the hosting scene
  102695. * @returns the torus mesh
  102696. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102697. */
  102698. static CreateTorus(name: string, options: {
  102699. diameter?: number;
  102700. thickness?: number;
  102701. tessellation?: number;
  102702. updatable?: boolean;
  102703. sideOrientation?: number;
  102704. frontUVs?: Vector4;
  102705. backUVs?: Vector4;
  102706. }, scene: any): Mesh;
  102707. }
  102708. }
  102709. declare module BABYLON {
  102710. /**
  102711. * Class containing static functions to help procedurally build meshes
  102712. */
  102713. export class CylinderBuilder {
  102714. /**
  102715. * Creates a cylinder or a cone mesh
  102716. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102717. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102718. * * 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.
  102719. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102720. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102721. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102722. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102723. * * 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).
  102724. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102725. * * 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).
  102726. * * 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
  102727. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102728. * * 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
  102729. * * 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.
  102730. * * If `enclose` is false, a ring surface is one element.
  102731. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102732. * * 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
  102733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102736. * @param name defines the name of the mesh
  102737. * @param options defines the options used to create the mesh
  102738. * @param scene defines the hosting scene
  102739. * @returns the cylinder mesh
  102740. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102741. */
  102742. static CreateCylinder(name: string, options: {
  102743. height?: number;
  102744. diameterTop?: number;
  102745. diameterBottom?: number;
  102746. diameter?: number;
  102747. tessellation?: number;
  102748. subdivisions?: number;
  102749. arc?: number;
  102750. faceColors?: Color4[];
  102751. faceUV?: Vector4[];
  102752. updatable?: boolean;
  102753. hasRings?: boolean;
  102754. enclose?: boolean;
  102755. cap?: number;
  102756. sideOrientation?: number;
  102757. frontUVs?: Vector4;
  102758. backUVs?: Vector4;
  102759. }, scene: any): Mesh;
  102760. }
  102761. }
  102762. declare module BABYLON {
  102763. /**
  102764. * Options to modify the vr teleportation behavior.
  102765. */
  102766. export interface VRTeleportationOptions {
  102767. /**
  102768. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102769. */
  102770. floorMeshName?: string;
  102771. /**
  102772. * A list of meshes to be used as the teleportation floor. (default: empty)
  102773. */
  102774. floorMeshes?: Mesh[];
  102775. }
  102776. /**
  102777. * Options to modify the vr experience helper's behavior.
  102778. */
  102779. export interface VRExperienceHelperOptions extends WebVROptions {
  102780. /**
  102781. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102782. */
  102783. createDeviceOrientationCamera?: boolean;
  102784. /**
  102785. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102786. */
  102787. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102788. /**
  102789. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102790. */
  102791. laserToggle?: boolean;
  102792. /**
  102793. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102794. */
  102795. floorMeshes?: Mesh[];
  102796. /**
  102797. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102798. */
  102799. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102800. }
  102801. /**
  102802. * Event containing information after VR has been entered
  102803. */
  102804. export class OnAfterEnteringVRObservableEvent {
  102805. /**
  102806. * If entering vr was successful
  102807. */
  102808. success: boolean;
  102809. }
  102810. /**
  102811. * Helps to quickly add VR support to an existing scene.
  102812. * See http://doc.babylonjs.com/how_to/webvr_helper
  102813. */
  102814. export class VRExperienceHelper {
  102815. /** Options to modify the vr experience helper's behavior. */
  102816. webVROptions: VRExperienceHelperOptions;
  102817. private _scene;
  102818. private _position;
  102819. private _btnVR;
  102820. private _btnVRDisplayed;
  102821. private _webVRsupported;
  102822. private _webVRready;
  102823. private _webVRrequesting;
  102824. private _webVRpresenting;
  102825. private _hasEnteredVR;
  102826. private _fullscreenVRpresenting;
  102827. private _canvas;
  102828. private _webVRCamera;
  102829. private _vrDeviceOrientationCamera;
  102830. private _deviceOrientationCamera;
  102831. private _existingCamera;
  102832. private _onKeyDown;
  102833. private _onVrDisplayPresentChange;
  102834. private _onVRDisplayChanged;
  102835. private _onVRRequestPresentStart;
  102836. private _onVRRequestPresentComplete;
  102837. /**
  102838. * Observable raised right before entering VR.
  102839. */
  102840. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102841. /**
  102842. * Observable raised when entering VR has completed.
  102843. */
  102844. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102845. /**
  102846. * Observable raised when exiting VR.
  102847. */
  102848. onExitingVRObservable: Observable<VRExperienceHelper>;
  102849. /**
  102850. * Observable raised when controller mesh is loaded.
  102851. */
  102852. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102853. /** Return this.onEnteringVRObservable
  102854. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102855. */
  102856. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102857. /** Return this.onExitingVRObservable
  102858. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102859. */
  102860. readonly onExitingVR: Observable<VRExperienceHelper>;
  102861. /** Return this.onControllerMeshLoadedObservable
  102862. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102863. */
  102864. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102865. private _rayLength;
  102866. private _useCustomVRButton;
  102867. private _teleportationRequested;
  102868. private _teleportActive;
  102869. private _floorMeshName;
  102870. private _floorMeshesCollection;
  102871. private _rotationAllowed;
  102872. private _teleportBackwardsVector;
  102873. private _teleportationTarget;
  102874. private _isDefaultTeleportationTarget;
  102875. private _postProcessMove;
  102876. private _teleportationFillColor;
  102877. private _teleportationBorderColor;
  102878. private _rotationAngle;
  102879. private _haloCenter;
  102880. private _cameraGazer;
  102881. private _padSensibilityUp;
  102882. private _padSensibilityDown;
  102883. private _leftController;
  102884. private _rightController;
  102885. /**
  102886. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102887. */
  102888. onNewMeshSelected: Observable<AbstractMesh>;
  102889. /**
  102890. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102891. */
  102892. onNewMeshPicked: Observable<PickingInfo>;
  102893. private _circleEase;
  102894. /**
  102895. * Observable raised before camera teleportation
  102896. */
  102897. onBeforeCameraTeleport: Observable<Vector3>;
  102898. /**
  102899. * Observable raised after camera teleportation
  102900. */
  102901. onAfterCameraTeleport: Observable<Vector3>;
  102902. /**
  102903. * Observable raised when current selected mesh gets unselected
  102904. */
  102905. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102906. private _raySelectionPredicate;
  102907. /**
  102908. * To be optionaly changed by user to define custom ray selection
  102909. */
  102910. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102911. /**
  102912. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102913. */
  102914. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102915. /**
  102916. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102917. */
  102918. teleportationEnabled: boolean;
  102919. private _defaultHeight;
  102920. private _teleportationInitialized;
  102921. private _interactionsEnabled;
  102922. private _interactionsRequested;
  102923. private _displayGaze;
  102924. private _displayLaserPointer;
  102925. /**
  102926. * The mesh used to display where the user is going to teleport.
  102927. */
  102928. /**
  102929. * Sets the mesh to be used to display where the user is going to teleport.
  102930. */
  102931. teleportationTarget: Mesh;
  102932. /**
  102933. * 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
  102934. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102935. * See http://doc.babylonjs.com/resources/baking_transformations
  102936. */
  102937. gazeTrackerMesh: Mesh;
  102938. /**
  102939. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102940. */
  102941. updateGazeTrackerScale: boolean;
  102942. /**
  102943. * If the gaze trackers color should be updated when selecting meshes
  102944. */
  102945. updateGazeTrackerColor: boolean;
  102946. /**
  102947. * The gaze tracking mesh corresponding to the left controller
  102948. */
  102949. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102950. /**
  102951. * The gaze tracking mesh corresponding to the right controller
  102952. */
  102953. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102954. /**
  102955. * If the ray of the gaze should be displayed.
  102956. */
  102957. /**
  102958. * Sets if the ray of the gaze should be displayed.
  102959. */
  102960. displayGaze: boolean;
  102961. /**
  102962. * If the ray of the LaserPointer should be displayed.
  102963. */
  102964. /**
  102965. * Sets if the ray of the LaserPointer should be displayed.
  102966. */
  102967. displayLaserPointer: boolean;
  102968. /**
  102969. * The deviceOrientationCamera used as the camera when not in VR.
  102970. */
  102971. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102972. /**
  102973. * Based on the current WebVR support, returns the current VR camera used.
  102974. */
  102975. readonly currentVRCamera: Nullable<Camera>;
  102976. /**
  102977. * The webVRCamera which is used when in VR.
  102978. */
  102979. readonly webVRCamera: WebVRFreeCamera;
  102980. /**
  102981. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102982. */
  102983. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102984. private readonly _teleportationRequestInitiated;
  102985. /**
  102986. * Defines wether or not Pointer lock should be requested when switching to
  102987. * full screen.
  102988. */
  102989. requestPointerLockOnFullScreen: boolean;
  102990. /**
  102991. * Instantiates a VRExperienceHelper.
  102992. * Helps to quickly add VR support to an existing scene.
  102993. * @param scene The scene the VRExperienceHelper belongs to.
  102994. * @param webVROptions Options to modify the vr experience helper's behavior.
  102995. */
  102996. constructor(scene: Scene,
  102997. /** Options to modify the vr experience helper's behavior. */
  102998. webVROptions?: VRExperienceHelperOptions);
  102999. private _onDefaultMeshLoaded;
  103000. private _onResize;
  103001. private _onFullscreenChange;
  103002. /**
  103003. * Gets a value indicating if we are currently in VR mode.
  103004. */
  103005. readonly isInVRMode: boolean;
  103006. private onVrDisplayPresentChange;
  103007. private onVRDisplayChanged;
  103008. private moveButtonToBottomRight;
  103009. private displayVRButton;
  103010. private updateButtonVisibility;
  103011. private _cachedAngularSensibility;
  103012. /**
  103013. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103014. * Otherwise, will use the fullscreen API.
  103015. */
  103016. enterVR(): void;
  103017. /**
  103018. * Attempt to exit VR, or fullscreen.
  103019. */
  103020. exitVR(): void;
  103021. /**
  103022. * The position of the vr experience helper.
  103023. */
  103024. /**
  103025. * Sets the position of the vr experience helper.
  103026. */
  103027. position: Vector3;
  103028. /**
  103029. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103030. */
  103031. enableInteractions(): void;
  103032. private readonly _noControllerIsActive;
  103033. private beforeRender;
  103034. private _isTeleportationFloor;
  103035. /**
  103036. * Adds a floor mesh to be used for teleportation.
  103037. * @param floorMesh the mesh to be used for teleportation.
  103038. */
  103039. addFloorMesh(floorMesh: Mesh): void;
  103040. /**
  103041. * Removes a floor mesh from being used for teleportation.
  103042. * @param floorMesh the mesh to be removed.
  103043. */
  103044. removeFloorMesh(floorMesh: Mesh): void;
  103045. /**
  103046. * Enables interactions and teleportation using the VR controllers and gaze.
  103047. * @param vrTeleportationOptions options to modify teleportation behavior.
  103048. */
  103049. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103050. private _onNewGamepadConnected;
  103051. private _tryEnableInteractionOnController;
  103052. private _onNewGamepadDisconnected;
  103053. private _enableInteractionOnController;
  103054. private _checkTeleportWithRay;
  103055. private _checkRotate;
  103056. private _checkTeleportBackwards;
  103057. private _enableTeleportationOnController;
  103058. private _createTeleportationCircles;
  103059. private _displayTeleportationTarget;
  103060. private _hideTeleportationTarget;
  103061. private _rotateCamera;
  103062. private _moveTeleportationSelectorTo;
  103063. private _workingVector;
  103064. private _workingQuaternion;
  103065. private _workingMatrix;
  103066. /**
  103067. * Teleports the users feet to the desired location
  103068. * @param location The location where the user's feet should be placed
  103069. */
  103070. teleportCamera(location: Vector3): void;
  103071. private _convertNormalToDirectionOfRay;
  103072. private _castRayAndSelectObject;
  103073. private _notifySelectedMeshUnselected;
  103074. /**
  103075. * Sets the color of the laser ray from the vr controllers.
  103076. * @param color new color for the ray.
  103077. */
  103078. changeLaserColor(color: Color3): void;
  103079. /**
  103080. * Sets the color of the ray from the vr headsets gaze.
  103081. * @param color new color for the ray.
  103082. */
  103083. changeGazeColor(color: Color3): void;
  103084. /**
  103085. * Exits VR and disposes of the vr experience helper
  103086. */
  103087. dispose(): void;
  103088. /**
  103089. * Gets the name of the VRExperienceHelper class
  103090. * @returns "VRExperienceHelper"
  103091. */
  103092. getClassName(): string;
  103093. }
  103094. }
  103095. declare module BABYLON {
  103096. /**
  103097. * Manages an XRSession to work with Babylon's engine
  103098. * @see https://doc.babylonjs.com/how_to/webxr
  103099. */
  103100. export class WebXRSessionManager implements IDisposable {
  103101. private scene;
  103102. /**
  103103. * Fires every time a new xrFrame arrives which can be used to update the camera
  103104. */
  103105. onXRFrameObservable: Observable<any>;
  103106. /**
  103107. * Fires when the xr session is ended either by the device or manually done
  103108. */
  103109. onXRSessionEnded: Observable<any>;
  103110. /**
  103111. * Underlying xr session
  103112. */
  103113. session: XRSession;
  103114. /**
  103115. * Type of reference space used when creating the session
  103116. */
  103117. referenceSpace: XRReferenceSpace;
  103118. /** @hidden */
  103119. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103120. /**
  103121. * Current XR frame
  103122. */
  103123. currentFrame: Nullable<XRFrame>;
  103124. private _xrNavigator;
  103125. private baseLayer;
  103126. /**
  103127. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103128. * @param scene The scene which the session should be created for
  103129. */
  103130. constructor(scene: Scene);
  103131. /**
  103132. * Initializes the manager
  103133. * After initialization enterXR can be called to start an XR session
  103134. * @returns Promise which resolves after it is initialized
  103135. */
  103136. initializeAsync(): Promise<void>;
  103137. /**
  103138. * Initializes an xr session
  103139. * @param xrSessionMode mode to initialize
  103140. * @returns a promise which will resolve once the session has been initialized
  103141. */
  103142. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  103143. /**
  103144. * Sets the reference space on the xr session
  103145. * @param referenceSpace space to set
  103146. * @returns a promise that will resolve once the reference space has been set
  103147. */
  103148. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  103149. /**
  103150. * Updates the render state of the session
  103151. * @param state state to set
  103152. * @returns a promise that resolves once the render state has been updated
  103153. */
  103154. updateRenderStateAsync(state: any): Promise<void>;
  103155. /**
  103156. * Starts rendering to the xr layer
  103157. * @returns a promise that will resolve once rendering has started
  103158. */
  103159. startRenderingToXRAsync(): Promise<void>;
  103160. /**
  103161. * Stops the xrSession and restores the renderloop
  103162. * @returns Promise which resolves after it exits XR
  103163. */
  103164. exitXRAsync(): Promise<void>;
  103165. /**
  103166. * Checks if a session would be supported for the creation options specified
  103167. * @param sessionMode session mode to check if supported eg. immersive-vr
  103168. * @returns true if supported
  103169. */
  103170. supportsSessionAsync(sessionMode: XRSessionMode): any;
  103171. /**
  103172. * @hidden
  103173. * Converts the render layer of xrSession to a render target
  103174. * @param session session to create render target for
  103175. * @param scene scene the new render target should be created for
  103176. */
  103177. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  103178. /**
  103179. * Disposes of the session manager
  103180. */
  103181. dispose(): void;
  103182. }
  103183. }
  103184. declare module BABYLON {
  103185. /**
  103186. * WebXR Camera which holds the views for the xrSession
  103187. * @see https://doc.babylonjs.com/how_to/webxr
  103188. */
  103189. export class WebXRCamera extends FreeCamera {
  103190. private static _TmpMatrix;
  103191. /**
  103192. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103193. * @param name the name of the camera
  103194. * @param scene the scene to add the camera to
  103195. */
  103196. constructor(name: string, scene: Scene);
  103197. private _updateNumberOfRigCameras;
  103198. /** @hidden */
  103199. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103200. /**
  103201. * Updates the cameras position from the current pose information of the XR session
  103202. * @param xrSessionManager the session containing pose information
  103203. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103204. */
  103205. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103206. }
  103207. }
  103208. declare module BABYLON {
  103209. /**
  103210. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103211. */
  103212. export class WebXRManagedOutputCanvas implements IDisposable {
  103213. private helper;
  103214. private _canvas;
  103215. /**
  103216. * xrpresent context of the canvas which can be used to display/mirror xr content
  103217. */
  103218. canvasContext: WebGLRenderingContext;
  103219. /**
  103220. * xr layer for the canvas
  103221. */
  103222. xrLayer: Nullable<XRWebGLLayer>;
  103223. /**
  103224. * Initializes the xr layer for the session
  103225. * @param xrSession xr session
  103226. * @returns a promise that will resolve once the XR Layer has been created
  103227. */
  103228. initializeXRLayerAsync(xrSession: any): any;
  103229. /**
  103230. * Initializes the canvas to be added/removed upon entering/exiting xr
  103231. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103232. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103233. */
  103234. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103235. /**
  103236. * Disposes of the object
  103237. */
  103238. dispose(): void;
  103239. private _setManagedOutputCanvas;
  103240. private _addCanvas;
  103241. private _removeCanvas;
  103242. }
  103243. }
  103244. declare module BABYLON {
  103245. /**
  103246. * States of the webXR experience
  103247. */
  103248. export enum WebXRState {
  103249. /**
  103250. * Transitioning to being in XR mode
  103251. */
  103252. ENTERING_XR = 0,
  103253. /**
  103254. * Transitioning to non XR mode
  103255. */
  103256. EXITING_XR = 1,
  103257. /**
  103258. * In XR mode and presenting
  103259. */
  103260. IN_XR = 2,
  103261. /**
  103262. * Not entered XR mode
  103263. */
  103264. NOT_IN_XR = 3
  103265. }
  103266. /**
  103267. * Helper class used to enable XR
  103268. * @see https://doc.babylonjs.com/how_to/webxr
  103269. */
  103270. export class WebXRExperienceHelper implements IDisposable {
  103271. private scene;
  103272. /**
  103273. * 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
  103274. */
  103275. container: AbstractMesh;
  103276. /**
  103277. * Camera used to render xr content
  103278. */
  103279. camera: WebXRCamera;
  103280. /**
  103281. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103282. */
  103283. state: WebXRState;
  103284. private _setState;
  103285. private static _TmpVector;
  103286. /**
  103287. * Fires when the state of the experience helper has changed
  103288. */
  103289. onStateChangedObservable: Observable<WebXRState>;
  103290. /** Session manager used to keep track of xr session */
  103291. sessionManager: WebXRSessionManager;
  103292. private _nonVRCamera;
  103293. private _originalSceneAutoClear;
  103294. private _supported;
  103295. /**
  103296. * Creates the experience helper
  103297. * @param scene the scene to attach the experience helper to
  103298. * @returns a promise for the experience helper
  103299. */
  103300. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103301. /**
  103302. * Creates a WebXRExperienceHelper
  103303. * @param scene The scene the helper should be created in
  103304. */
  103305. private constructor();
  103306. /**
  103307. * Exits XR mode and returns the scene to its original state
  103308. * @returns promise that resolves after xr mode has exited
  103309. */
  103310. exitXRAsync(): Promise<void>;
  103311. /**
  103312. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103313. * @param sessionCreationOptions options for the XR session
  103314. * @param referenceSpaceType frame of reference of the XR session
  103315. * @param outputCanvas the output canvas that will be used to enter XR mode
  103316. * @returns promise that resolves after xr mode has entered
  103317. */
  103318. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  103319. /**
  103320. * Updates the global position of the camera by moving the camera's container
  103321. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103322. * @param position The desired global position of the camera
  103323. */
  103324. setPositionOfCameraUsingContainer(position: Vector3): void;
  103325. /**
  103326. * Rotates the xr camera by rotating the camera's container around the camera's position
  103327. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103328. * @param rotation the desired quaternion rotation to apply to the camera
  103329. */
  103330. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103331. /**
  103332. * Disposes of the experience helper
  103333. */
  103334. dispose(): void;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * Button which can be used to enter a different mode of XR
  103340. */
  103341. export class WebXREnterExitUIButton {
  103342. /** button element */
  103343. element: HTMLElement;
  103344. /** XR initialization options for the button */
  103345. sessionMode: XRSessionMode;
  103346. /** Reference space type */
  103347. referenceSpaceType: XRReferenceSpaceType;
  103348. /**
  103349. * Creates a WebXREnterExitUIButton
  103350. * @param element button element
  103351. * @param sessionMode XR initialization session mode
  103352. * @param referenceSpaceType the type of reference space to be used
  103353. */
  103354. constructor(
  103355. /** button element */
  103356. element: HTMLElement,
  103357. /** XR initialization options for the button */
  103358. sessionMode: XRSessionMode,
  103359. /** Reference space type */
  103360. referenceSpaceType: XRReferenceSpaceType);
  103361. /**
  103362. * Overwritable function which can be used to update the button's visuals when the state changes
  103363. * @param activeButton the current active button in the UI
  103364. */
  103365. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103366. }
  103367. /**
  103368. * Options to create the webXR UI
  103369. */
  103370. export class WebXREnterExitUIOptions {
  103371. /**
  103372. * Context to enter xr with
  103373. */
  103374. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  103375. /**
  103376. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103377. */
  103378. customButtons?: Array<WebXREnterExitUIButton>;
  103379. }
  103380. /**
  103381. * UI to allow the user to enter/exit XR mode
  103382. */
  103383. export class WebXREnterExitUI implements IDisposable {
  103384. private scene;
  103385. private _overlay;
  103386. private _buttons;
  103387. private _activeButton;
  103388. /**
  103389. * Fired every time the active button is changed.
  103390. *
  103391. * When xr is entered via a button that launches xr that button will be the callback parameter
  103392. *
  103393. * When exiting xr the callback parameter will be null)
  103394. */
  103395. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103396. /**
  103397. * Creates UI to allow the user to enter/exit XR mode
  103398. * @param scene the scene to add the ui to
  103399. * @param helper the xr experience helper to enter/exit xr with
  103400. * @param options options to configure the UI
  103401. * @returns the created ui
  103402. */
  103403. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103404. private constructor();
  103405. private _updateButtons;
  103406. /**
  103407. * Disposes of the object
  103408. */
  103409. dispose(): void;
  103410. }
  103411. }
  103412. declare module BABYLON {
  103413. /**
  103414. * Represents an XR input
  103415. */
  103416. export class WebXRController {
  103417. private scene;
  103418. /** The underlying input source for the controller */
  103419. inputSource: XRInputSource;
  103420. private parentContainer;
  103421. /**
  103422. * 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
  103423. */
  103424. grip?: AbstractMesh;
  103425. /**
  103426. * Pointer which can be used to select objects or attach a visible laser to
  103427. */
  103428. pointer: AbstractMesh;
  103429. private _tmpMatrix;
  103430. /**
  103431. * Creates the controller
  103432. * @see https://doc.babylonjs.com/how_to/webxr
  103433. * @param scene the scene which the controller should be associated to
  103434. * @param inputSource the underlying input source for the controller
  103435. * @param parentContainer parent that the controller meshes should be children of
  103436. */
  103437. constructor(scene: Scene,
  103438. /** The underlying input source for the controller */
  103439. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  103440. /**
  103441. * Updates the controller pose based on the given XRFrame
  103442. * @param xrFrame xr frame to update the pose with
  103443. * @param referenceSpace reference space to use
  103444. */
  103445. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  103446. /**
  103447. * Disposes of the object
  103448. */
  103449. dispose(): void;
  103450. }
  103451. /**
  103452. * XR input used to track XR inputs such as controllers/rays
  103453. */
  103454. export class WebXRInput implements IDisposable {
  103455. private helper;
  103456. /**
  103457. * XR controllers being tracked
  103458. */
  103459. controllers: Array<WebXRController>;
  103460. private _frameObserver;
  103461. /**
  103462. * Event when a controller has been connected/added
  103463. */
  103464. onControllerAddedObservable: Observable<WebXRController>;
  103465. /**
  103466. * Event when a controller has been removed/disconnected
  103467. */
  103468. onControllerRemovedObservable: Observable<WebXRController>;
  103469. /**
  103470. * Initializes the WebXRInput
  103471. * @param helper experience helper which the input should be created for
  103472. */
  103473. constructor(helper: WebXRExperienceHelper);
  103474. private _onInputSourcesChange;
  103475. private _addAndRemoveControllers;
  103476. /**
  103477. * Disposes of the object
  103478. */
  103479. dispose(): void;
  103480. }
  103481. }
  103482. declare module BABYLON {
  103483. /**
  103484. * Contains an array of blocks representing the octree
  103485. */
  103486. export interface IOctreeContainer<T> {
  103487. /**
  103488. * Blocks within the octree
  103489. */
  103490. blocks: Array<OctreeBlock<T>>;
  103491. }
  103492. /**
  103493. * Class used to store a cell in an octree
  103494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103495. */
  103496. export class OctreeBlock<T> {
  103497. /**
  103498. * Gets the content of the current block
  103499. */
  103500. entries: T[];
  103501. /**
  103502. * Gets the list of block children
  103503. */
  103504. blocks: Array<OctreeBlock<T>>;
  103505. private _depth;
  103506. private _maxDepth;
  103507. private _capacity;
  103508. private _minPoint;
  103509. private _maxPoint;
  103510. private _boundingVectors;
  103511. private _creationFunc;
  103512. /**
  103513. * Creates a new block
  103514. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103515. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103516. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103517. * @param depth defines the current depth of this block in the octree
  103518. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103519. * @param creationFunc defines a callback to call when an element is added to the block
  103520. */
  103521. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103522. /**
  103523. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103524. */
  103525. readonly capacity: number;
  103526. /**
  103527. * Gets the minimum vector (in world space) of the block's bounding box
  103528. */
  103529. readonly minPoint: Vector3;
  103530. /**
  103531. * Gets the maximum vector (in world space) of the block's bounding box
  103532. */
  103533. readonly maxPoint: Vector3;
  103534. /**
  103535. * Add a new element to this block
  103536. * @param entry defines the element to add
  103537. */
  103538. addEntry(entry: T): void;
  103539. /**
  103540. * Remove an element from this block
  103541. * @param entry defines the element to remove
  103542. */
  103543. removeEntry(entry: T): void;
  103544. /**
  103545. * Add an array of elements to this block
  103546. * @param entries defines the array of elements to add
  103547. */
  103548. addEntries(entries: T[]): void;
  103549. /**
  103550. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103551. * @param frustumPlanes defines the frustum planes to test
  103552. * @param selection defines the array to store current content if selection is positive
  103553. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103554. */
  103555. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103556. /**
  103557. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103558. * @param sphereCenter defines the bounding sphere center
  103559. * @param sphereRadius defines the bounding sphere radius
  103560. * @param selection defines the array to store current content if selection is positive
  103561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103562. */
  103563. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103564. /**
  103565. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103566. * @param ray defines the ray to test with
  103567. * @param selection defines the array to store current content if selection is positive
  103568. */
  103569. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103570. /**
  103571. * Subdivide the content into child blocks (this block will then be empty)
  103572. */
  103573. createInnerBlocks(): void;
  103574. /**
  103575. * @hidden
  103576. */
  103577. 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;
  103578. }
  103579. }
  103580. declare module BABYLON {
  103581. /**
  103582. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103583. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103584. */
  103585. export class Octree<T> {
  103586. /** 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.) */
  103587. maxDepth: number;
  103588. /**
  103589. * Blocks within the octree containing objects
  103590. */
  103591. blocks: Array<OctreeBlock<T>>;
  103592. /**
  103593. * Content stored in the octree
  103594. */
  103595. dynamicContent: T[];
  103596. private _maxBlockCapacity;
  103597. private _selectionContent;
  103598. private _creationFunc;
  103599. /**
  103600. * Creates a octree
  103601. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103602. * @param creationFunc function to be used to instatiate the octree
  103603. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103604. * @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.)
  103605. */
  103606. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103607. /** 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.) */
  103608. maxDepth?: number);
  103609. /**
  103610. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103611. * @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);
  103612. * @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);
  103613. * @param entries meshes to be added to the octree blocks
  103614. */
  103615. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103616. /**
  103617. * Adds a mesh to the octree
  103618. * @param entry Mesh to add to the octree
  103619. */
  103620. addMesh(entry: T): void;
  103621. /**
  103622. * Remove an element from the octree
  103623. * @param entry defines the element to remove
  103624. */
  103625. removeMesh(entry: T): void;
  103626. /**
  103627. * Selects an array of meshes within the frustum
  103628. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103629. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103630. * @returns array of meshes within the frustum
  103631. */
  103632. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103633. /**
  103634. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103635. * @param sphereCenter defines the bounding sphere center
  103636. * @param sphereRadius defines the bounding sphere radius
  103637. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103638. * @returns an array of objects that intersect the sphere
  103639. */
  103640. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103641. /**
  103642. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103643. * @param ray defines the ray to test with
  103644. * @returns array of intersected objects
  103645. */
  103646. intersectsRay(ray: Ray): SmartArray<T>;
  103647. /**
  103648. * Adds a mesh into the octree block if it intersects the block
  103649. */
  103650. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103651. /**
  103652. * Adds a submesh into the octree block if it intersects the block
  103653. */
  103654. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103655. }
  103656. }
  103657. declare module BABYLON {
  103658. interface Scene {
  103659. /**
  103660. * @hidden
  103661. * Backing Filed
  103662. */
  103663. _selectionOctree: Octree<AbstractMesh>;
  103664. /**
  103665. * Gets the octree used to boost mesh selection (picking)
  103666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103667. */
  103668. selectionOctree: Octree<AbstractMesh>;
  103669. /**
  103670. * Creates or updates the octree used to boost selection (picking)
  103671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103672. * @param maxCapacity defines the maximum capacity per leaf
  103673. * @param maxDepth defines the maximum depth of the octree
  103674. * @returns an octree of AbstractMesh
  103675. */
  103676. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103677. }
  103678. interface AbstractMesh {
  103679. /**
  103680. * @hidden
  103681. * Backing Field
  103682. */
  103683. _submeshesOctree: Octree<SubMesh>;
  103684. /**
  103685. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103686. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103687. * @param maxCapacity defines the maximum size of each block (64 by default)
  103688. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103689. * @returns the new octree
  103690. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103692. */
  103693. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103694. }
  103695. /**
  103696. * Defines the octree scene component responsible to manage any octrees
  103697. * in a given scene.
  103698. */
  103699. export class OctreeSceneComponent {
  103700. /**
  103701. * The component name help to identify the component in the list of scene components.
  103702. */
  103703. readonly name: string;
  103704. /**
  103705. * The scene the component belongs to.
  103706. */
  103707. scene: Scene;
  103708. /**
  103709. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103710. */
  103711. readonly checksIsEnabled: boolean;
  103712. /**
  103713. * Creates a new instance of the component for the given scene
  103714. * @param scene Defines the scene to register the component in
  103715. */
  103716. constructor(scene: Scene);
  103717. /**
  103718. * Registers the component in a given scene
  103719. */
  103720. register(): void;
  103721. /**
  103722. * Return the list of active meshes
  103723. * @returns the list of active meshes
  103724. */
  103725. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103726. /**
  103727. * Return the list of active sub meshes
  103728. * @param mesh The mesh to get the candidates sub meshes from
  103729. * @returns the list of active sub meshes
  103730. */
  103731. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103732. private _tempRay;
  103733. /**
  103734. * Return the list of sub meshes intersecting with a given local ray
  103735. * @param mesh defines the mesh to find the submesh for
  103736. * @param localRay defines the ray in local space
  103737. * @returns the list of intersecting sub meshes
  103738. */
  103739. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103740. /**
  103741. * Return the list of sub meshes colliding with a collider
  103742. * @param mesh defines the mesh to find the submesh for
  103743. * @param collider defines the collider to evaluate the collision against
  103744. * @returns the list of colliding sub meshes
  103745. */
  103746. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103747. /**
  103748. * Rebuilds the elements related to this component in case of
  103749. * context lost for instance.
  103750. */
  103751. rebuild(): void;
  103752. /**
  103753. * Disposes the component and the associated ressources.
  103754. */
  103755. dispose(): void;
  103756. }
  103757. }
  103758. declare module BABYLON {
  103759. /**
  103760. * Renders a layer on top of an existing scene
  103761. */
  103762. export class UtilityLayerRenderer implements IDisposable {
  103763. /** the original scene that will be rendered on top of */
  103764. originalScene: Scene;
  103765. private _pointerCaptures;
  103766. private _lastPointerEvents;
  103767. private static _DefaultUtilityLayer;
  103768. private static _DefaultKeepDepthUtilityLayer;
  103769. private _sharedGizmoLight;
  103770. private _renderCamera;
  103771. /**
  103772. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103773. * @returns the camera that is used when rendering the utility layer
  103774. */
  103775. getRenderCamera(): Nullable<Camera>;
  103776. /**
  103777. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103778. * @param cam the camera that should be used when rendering the utility layer
  103779. */
  103780. setRenderCamera(cam: Nullable<Camera>): void;
  103781. /**
  103782. * @hidden
  103783. * Light which used by gizmos to get light shading
  103784. */
  103785. _getSharedGizmoLight(): HemisphericLight;
  103786. /**
  103787. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103788. */
  103789. pickUtilitySceneFirst: boolean;
  103790. /**
  103791. * 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)
  103792. */
  103793. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103794. /**
  103795. * 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)
  103796. */
  103797. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103798. /**
  103799. * The scene that is rendered on top of the original scene
  103800. */
  103801. utilityLayerScene: Scene;
  103802. /**
  103803. * If the utility layer should automatically be rendered on top of existing scene
  103804. */
  103805. shouldRender: boolean;
  103806. /**
  103807. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103808. */
  103809. onlyCheckPointerDownEvents: boolean;
  103810. /**
  103811. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103812. */
  103813. processAllEvents: boolean;
  103814. /**
  103815. * Observable raised when the pointer move from the utility layer scene to the main scene
  103816. */
  103817. onPointerOutObservable: Observable<number>;
  103818. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103819. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103820. private _afterRenderObserver;
  103821. private _sceneDisposeObserver;
  103822. private _originalPointerObserver;
  103823. /**
  103824. * Instantiates a UtilityLayerRenderer
  103825. * @param originalScene the original scene that will be rendered on top of
  103826. * @param handleEvents boolean indicating if the utility layer should handle events
  103827. */
  103828. constructor(
  103829. /** the original scene that will be rendered on top of */
  103830. originalScene: Scene, handleEvents?: boolean);
  103831. private _notifyObservers;
  103832. /**
  103833. * Renders the utility layers scene on top of the original scene
  103834. */
  103835. render(): void;
  103836. /**
  103837. * Disposes of the renderer
  103838. */
  103839. dispose(): void;
  103840. private _updateCamera;
  103841. }
  103842. }
  103843. declare module BABYLON {
  103844. /**
  103845. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103846. */
  103847. export class Gizmo implements IDisposable {
  103848. /** The utility layer the gizmo will be added to */
  103849. gizmoLayer: UtilityLayerRenderer;
  103850. /**
  103851. * The root mesh of the gizmo
  103852. */
  103853. _rootMesh: Mesh;
  103854. private _attachedMesh;
  103855. /**
  103856. * Ratio for the scale of the gizmo (Default: 1)
  103857. */
  103858. scaleRatio: number;
  103859. /**
  103860. * If a custom mesh has been set (Default: false)
  103861. */
  103862. protected _customMeshSet: boolean;
  103863. /**
  103864. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103865. * * When set, interactions will be enabled
  103866. */
  103867. attachedMesh: Nullable<AbstractMesh>;
  103868. /**
  103869. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103870. * @param mesh The mesh to replace the default mesh of the gizmo
  103871. */
  103872. setCustomMesh(mesh: Mesh): void;
  103873. /**
  103874. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103875. */
  103876. updateGizmoRotationToMatchAttachedMesh: boolean;
  103877. /**
  103878. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103879. */
  103880. updateGizmoPositionToMatchAttachedMesh: boolean;
  103881. /**
  103882. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103883. */
  103884. protected _updateScale: boolean;
  103885. protected _interactionsEnabled: boolean;
  103886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103887. private _beforeRenderObserver;
  103888. private _tempVector;
  103889. /**
  103890. * Creates a gizmo
  103891. * @param gizmoLayer The utility layer the gizmo will be added to
  103892. */
  103893. constructor(
  103894. /** The utility layer the gizmo will be added to */
  103895. gizmoLayer?: UtilityLayerRenderer);
  103896. /**
  103897. * Updates the gizmo to match the attached mesh's position/rotation
  103898. */
  103899. protected _update(): void;
  103900. /**
  103901. * Disposes of the gizmo
  103902. */
  103903. dispose(): void;
  103904. }
  103905. }
  103906. declare module BABYLON {
  103907. /**
  103908. * Single plane drag gizmo
  103909. */
  103910. export class PlaneDragGizmo extends Gizmo {
  103911. /**
  103912. * Drag behavior responsible for the gizmos dragging interactions
  103913. */
  103914. dragBehavior: PointerDragBehavior;
  103915. private _pointerObserver;
  103916. /**
  103917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103918. */
  103919. snapDistance: number;
  103920. /**
  103921. * Event that fires each time the gizmo snaps to a new location.
  103922. * * snapDistance is the the change in distance
  103923. */
  103924. onSnapObservable: Observable<{
  103925. snapDistance: number;
  103926. }>;
  103927. private _plane;
  103928. private _coloredMaterial;
  103929. private _hoverMaterial;
  103930. private _isEnabled;
  103931. private _parent;
  103932. /** @hidden */
  103933. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103934. /** @hidden */
  103935. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103936. /**
  103937. * Creates a PlaneDragGizmo
  103938. * @param gizmoLayer The utility layer the gizmo will be added to
  103939. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103940. * @param color The color of the gizmo
  103941. */
  103942. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103943. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103944. /**
  103945. * If the gizmo is enabled
  103946. */
  103947. isEnabled: boolean;
  103948. /**
  103949. * Disposes of the gizmo
  103950. */
  103951. dispose(): void;
  103952. }
  103953. }
  103954. declare module BABYLON {
  103955. /**
  103956. * Gizmo that enables dragging a mesh along 3 axis
  103957. */
  103958. export class PositionGizmo extends Gizmo {
  103959. /**
  103960. * Internal gizmo used for interactions on the x axis
  103961. */
  103962. xGizmo: AxisDragGizmo;
  103963. /**
  103964. * Internal gizmo used for interactions on the y axis
  103965. */
  103966. yGizmo: AxisDragGizmo;
  103967. /**
  103968. * Internal gizmo used for interactions on the z axis
  103969. */
  103970. zGizmo: AxisDragGizmo;
  103971. /**
  103972. * Internal gizmo used for interactions on the yz plane
  103973. */
  103974. xPlaneGizmo: PlaneDragGizmo;
  103975. /**
  103976. * Internal gizmo used for interactions on the xz plane
  103977. */
  103978. yPlaneGizmo: PlaneDragGizmo;
  103979. /**
  103980. * Internal gizmo used for interactions on the xy plane
  103981. */
  103982. zPlaneGizmo: PlaneDragGizmo;
  103983. /**
  103984. * private variables
  103985. */
  103986. private _meshAttached;
  103987. private _updateGizmoRotationToMatchAttachedMesh;
  103988. private _snapDistance;
  103989. private _scaleRatio;
  103990. /** Fires an event when any of it's sub gizmos are dragged */
  103991. onDragStartObservable: Observable<unknown>;
  103992. /** Fires an event when any of it's sub gizmos are released from dragging */
  103993. onDragEndObservable: Observable<unknown>;
  103994. /**
  103995. * If set to true, planar drag is enabled
  103996. */
  103997. private _planarGizmoEnabled;
  103998. attachedMesh: Nullable<AbstractMesh>;
  103999. /**
  104000. * Creates a PositionGizmo
  104001. * @param gizmoLayer The utility layer the gizmo will be added to
  104002. */
  104003. constructor(gizmoLayer?: UtilityLayerRenderer);
  104004. /**
  104005. * If the planar drag gizmo is enabled
  104006. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  104007. */
  104008. planarGizmoEnabled: boolean;
  104009. updateGizmoRotationToMatchAttachedMesh: boolean;
  104010. /**
  104011. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104012. */
  104013. snapDistance: number;
  104014. /**
  104015. * Ratio for the scale of the gizmo (Default: 1)
  104016. */
  104017. scaleRatio: number;
  104018. /**
  104019. * Disposes of the gizmo
  104020. */
  104021. dispose(): void;
  104022. /**
  104023. * CustomMeshes are not supported by this gizmo
  104024. * @param mesh The mesh to replace the default mesh of the gizmo
  104025. */
  104026. setCustomMesh(mesh: Mesh): void;
  104027. }
  104028. }
  104029. declare module BABYLON {
  104030. /**
  104031. * Single axis drag gizmo
  104032. */
  104033. export class AxisDragGizmo extends Gizmo {
  104034. /**
  104035. * Drag behavior responsible for the gizmos dragging interactions
  104036. */
  104037. dragBehavior: PointerDragBehavior;
  104038. private _pointerObserver;
  104039. /**
  104040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104041. */
  104042. snapDistance: number;
  104043. /**
  104044. * Event that fires each time the gizmo snaps to a new location.
  104045. * * snapDistance is the the change in distance
  104046. */
  104047. onSnapObservable: Observable<{
  104048. snapDistance: number;
  104049. }>;
  104050. private _isEnabled;
  104051. private _parent;
  104052. private _arrow;
  104053. private _coloredMaterial;
  104054. private _hoverMaterial;
  104055. /** @hidden */
  104056. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104057. /** @hidden */
  104058. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104059. /**
  104060. * Creates an AxisDragGizmo
  104061. * @param gizmoLayer The utility layer the gizmo will be added to
  104062. * @param dragAxis The axis which the gizmo will be able to drag on
  104063. * @param color The color of the gizmo
  104064. */
  104065. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104066. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104067. /**
  104068. * If the gizmo is enabled
  104069. */
  104070. isEnabled: boolean;
  104071. /**
  104072. * Disposes of the gizmo
  104073. */
  104074. dispose(): void;
  104075. }
  104076. }
  104077. declare module BABYLON.Debug {
  104078. /**
  104079. * The Axes viewer will show 3 axes in a specific point in space
  104080. */
  104081. export class AxesViewer {
  104082. private _xAxis;
  104083. private _yAxis;
  104084. private _zAxis;
  104085. private _scaleLinesFactor;
  104086. private _instanced;
  104087. /**
  104088. * Gets the hosting scene
  104089. */
  104090. scene: Scene;
  104091. /**
  104092. * Gets or sets a number used to scale line length
  104093. */
  104094. scaleLines: number;
  104095. /** Gets the node hierarchy used to render x-axis */
  104096. readonly xAxis: TransformNode;
  104097. /** Gets the node hierarchy used to render y-axis */
  104098. readonly yAxis: TransformNode;
  104099. /** Gets the node hierarchy used to render z-axis */
  104100. readonly zAxis: TransformNode;
  104101. /**
  104102. * Creates a new AxesViewer
  104103. * @param scene defines the hosting scene
  104104. * @param scaleLines defines a number used to scale line length (1 by default)
  104105. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104106. * @param xAxis defines the node hierarchy used to render the x-axis
  104107. * @param yAxis defines the node hierarchy used to render the y-axis
  104108. * @param zAxis defines the node hierarchy used to render the z-axis
  104109. */
  104110. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104111. /**
  104112. * Force the viewer to update
  104113. * @param position defines the position of the viewer
  104114. * @param xaxis defines the x axis of the viewer
  104115. * @param yaxis defines the y axis of the viewer
  104116. * @param zaxis defines the z axis of the viewer
  104117. */
  104118. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104119. /**
  104120. * Creates an instance of this axes viewer.
  104121. * @returns a new axes viewer with instanced meshes
  104122. */
  104123. createInstance(): AxesViewer;
  104124. /** Releases resources */
  104125. dispose(): void;
  104126. private static _SetRenderingGroupId;
  104127. }
  104128. }
  104129. declare module BABYLON.Debug {
  104130. /**
  104131. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104132. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104133. */
  104134. export class BoneAxesViewer extends AxesViewer {
  104135. /**
  104136. * Gets or sets the target mesh where to display the axes viewer
  104137. */
  104138. mesh: Nullable<Mesh>;
  104139. /**
  104140. * Gets or sets the target bone where to display the axes viewer
  104141. */
  104142. bone: Nullable<Bone>;
  104143. /** Gets current position */
  104144. pos: Vector3;
  104145. /** Gets direction of X axis */
  104146. xaxis: Vector3;
  104147. /** Gets direction of Y axis */
  104148. yaxis: Vector3;
  104149. /** Gets direction of Z axis */
  104150. zaxis: Vector3;
  104151. /**
  104152. * Creates a new BoneAxesViewer
  104153. * @param scene defines the hosting scene
  104154. * @param bone defines the target bone
  104155. * @param mesh defines the target mesh
  104156. * @param scaleLines defines a scaling factor for line length (1 by default)
  104157. */
  104158. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104159. /**
  104160. * Force the viewer to update
  104161. */
  104162. update(): void;
  104163. /** Releases resources */
  104164. dispose(): void;
  104165. }
  104166. }
  104167. declare module BABYLON {
  104168. /**
  104169. * Interface used to define scene explorer extensibility option
  104170. */
  104171. export interface IExplorerExtensibilityOption {
  104172. /**
  104173. * Define the option label
  104174. */
  104175. label: string;
  104176. /**
  104177. * Defines the action to execute on click
  104178. */
  104179. action: (entity: any) => void;
  104180. }
  104181. /**
  104182. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104183. */
  104184. export interface IExplorerExtensibilityGroup {
  104185. /**
  104186. * Defines a predicate to test if a given type mut be extended
  104187. */
  104188. predicate: (entity: any) => boolean;
  104189. /**
  104190. * Gets the list of options added to a type
  104191. */
  104192. entries: IExplorerExtensibilityOption[];
  104193. }
  104194. /**
  104195. * Interface used to define the options to use to create the Inspector
  104196. */
  104197. export interface IInspectorOptions {
  104198. /**
  104199. * Display in overlay mode (default: false)
  104200. */
  104201. overlay?: boolean;
  104202. /**
  104203. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104204. */
  104205. globalRoot?: HTMLElement;
  104206. /**
  104207. * Display the Scene explorer
  104208. */
  104209. showExplorer?: boolean;
  104210. /**
  104211. * Display the property inspector
  104212. */
  104213. showInspector?: boolean;
  104214. /**
  104215. * Display in embed mode (both panes on the right)
  104216. */
  104217. embedMode?: boolean;
  104218. /**
  104219. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104220. */
  104221. handleResize?: boolean;
  104222. /**
  104223. * Allow the panes to popup (default: true)
  104224. */
  104225. enablePopup?: boolean;
  104226. /**
  104227. * Allow the panes to be closed by users (default: true)
  104228. */
  104229. enableClose?: boolean;
  104230. /**
  104231. * Optional list of extensibility entries
  104232. */
  104233. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104234. /**
  104235. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104236. */
  104237. inspectorURL?: string;
  104238. }
  104239. interface Scene {
  104240. /**
  104241. * @hidden
  104242. * Backing field
  104243. */
  104244. _debugLayer: DebugLayer;
  104245. /**
  104246. * Gets the debug layer (aka Inspector) associated with the scene
  104247. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104248. */
  104249. debugLayer: DebugLayer;
  104250. }
  104251. /**
  104252. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104253. * what is happening in your scene
  104254. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104255. */
  104256. export class DebugLayer {
  104257. /**
  104258. * Define the url to get the inspector script from.
  104259. * By default it uses the babylonjs CDN.
  104260. * @ignoreNaming
  104261. */
  104262. static InspectorURL: string;
  104263. private _scene;
  104264. private BJSINSPECTOR;
  104265. private _onPropertyChangedObservable?;
  104266. /**
  104267. * Observable triggered when a property is changed through the inspector.
  104268. */
  104269. readonly onPropertyChangedObservable: any;
  104270. /**
  104271. * Instantiates a new debug layer.
  104272. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104273. * what is happening in your scene
  104274. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104275. * @param scene Defines the scene to inspect
  104276. */
  104277. constructor(scene: Scene);
  104278. /** Creates the inspector window. */
  104279. private _createInspector;
  104280. /**
  104281. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104282. * @param entity defines the entity to select
  104283. * @param lineContainerTitle defines the specific block to highlight
  104284. */
  104285. select(entity: any, lineContainerTitle?: string): void;
  104286. /** Get the inspector from bundle or global */
  104287. private _getGlobalInspector;
  104288. /**
  104289. * Get if the inspector is visible or not.
  104290. * @returns true if visible otherwise, false
  104291. */
  104292. isVisible(): boolean;
  104293. /**
  104294. * Hide the inspector and close its window.
  104295. */
  104296. hide(): void;
  104297. /**
  104298. * Launch the debugLayer.
  104299. * @param config Define the configuration of the inspector
  104300. * @return a promise fulfilled when the debug layer is visible
  104301. */
  104302. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104303. }
  104304. }
  104305. declare module BABYLON {
  104306. /**
  104307. * Class containing static functions to help procedurally build meshes
  104308. */
  104309. export class BoxBuilder {
  104310. /**
  104311. * Creates a box mesh
  104312. * * The parameter `size` sets the size (float) of each box side (default 1)
  104313. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104314. * * 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)
  104315. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104319. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104320. * @param name defines the name of the mesh
  104321. * @param options defines the options used to create the mesh
  104322. * @param scene defines the hosting scene
  104323. * @returns the box mesh
  104324. */
  104325. static CreateBox(name: string, options: {
  104326. size?: number;
  104327. width?: number;
  104328. height?: number;
  104329. depth?: number;
  104330. faceUV?: Vector4[];
  104331. faceColors?: Color4[];
  104332. sideOrientation?: number;
  104333. frontUVs?: Vector4;
  104334. backUVs?: Vector4;
  104335. wrap?: boolean;
  104336. topBaseAt?: number;
  104337. bottomBaseAt?: number;
  104338. updatable?: boolean;
  104339. }, scene?: Nullable<Scene>): Mesh;
  104340. }
  104341. }
  104342. declare module BABYLON {
  104343. /**
  104344. * Class containing static functions to help procedurally build meshes
  104345. */
  104346. export class SphereBuilder {
  104347. /**
  104348. * Creates a sphere mesh
  104349. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104350. * * 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`)
  104351. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104352. * * 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
  104353. * * 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)
  104354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104357. * @param name defines the name of the mesh
  104358. * @param options defines the options used to create the mesh
  104359. * @param scene defines the hosting scene
  104360. * @returns the sphere mesh
  104361. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104362. */
  104363. static CreateSphere(name: string, options: {
  104364. segments?: number;
  104365. diameter?: number;
  104366. diameterX?: number;
  104367. diameterY?: number;
  104368. diameterZ?: number;
  104369. arc?: number;
  104370. slice?: number;
  104371. sideOrientation?: number;
  104372. frontUVs?: Vector4;
  104373. backUVs?: Vector4;
  104374. updatable?: boolean;
  104375. }, scene: any): Mesh;
  104376. }
  104377. }
  104378. declare module BABYLON.Debug {
  104379. /**
  104380. * Used to show the physics impostor around the specific mesh
  104381. */
  104382. export class PhysicsViewer {
  104383. /** @hidden */
  104384. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104385. /** @hidden */
  104386. protected _meshes: Array<Nullable<AbstractMesh>>;
  104387. /** @hidden */
  104388. protected _scene: Nullable<Scene>;
  104389. /** @hidden */
  104390. protected _numMeshes: number;
  104391. /** @hidden */
  104392. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104393. private _renderFunction;
  104394. private _utilityLayer;
  104395. private _debugBoxMesh;
  104396. private _debugSphereMesh;
  104397. private _debugCylinderMesh;
  104398. private _debugMaterial;
  104399. private _debugMeshMeshes;
  104400. /**
  104401. * Creates a new PhysicsViewer
  104402. * @param scene defines the hosting scene
  104403. */
  104404. constructor(scene: Scene);
  104405. /** @hidden */
  104406. protected _updateDebugMeshes(): void;
  104407. /**
  104408. * Renders a specified physic impostor
  104409. * @param impostor defines the impostor to render
  104410. * @param targetMesh defines the mesh represented by the impostor
  104411. * @returns the new debug mesh used to render the impostor
  104412. */
  104413. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104414. /**
  104415. * Hides a specified physic impostor
  104416. * @param impostor defines the impostor to hide
  104417. */
  104418. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104419. private _getDebugMaterial;
  104420. private _getDebugBoxMesh;
  104421. private _getDebugSphereMesh;
  104422. private _getDebugCylinderMesh;
  104423. private _getDebugMeshMesh;
  104424. private _getDebugMesh;
  104425. /** Releases all resources */
  104426. dispose(): void;
  104427. }
  104428. }
  104429. declare module BABYLON {
  104430. /**
  104431. * Class containing static functions to help procedurally build meshes
  104432. */
  104433. export class LinesBuilder {
  104434. /**
  104435. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104436. * * 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
  104437. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104438. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104439. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104440. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104441. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104442. * * 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
  104443. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104446. * @param name defines the name of the new line system
  104447. * @param options defines the options used to create the line system
  104448. * @param scene defines the hosting scene
  104449. * @returns a new line system mesh
  104450. */
  104451. static CreateLineSystem(name: string, options: {
  104452. lines: Vector3[][];
  104453. updatable?: boolean;
  104454. instance?: Nullable<LinesMesh>;
  104455. colors?: Nullable<Color4[][]>;
  104456. useVertexAlpha?: boolean;
  104457. }, scene: Nullable<Scene>): LinesMesh;
  104458. /**
  104459. * Creates a line mesh
  104460. * 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
  104461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104462. * * The parameter `points` is an array successive Vector3
  104463. * * 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
  104464. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104466. * * When updating an instance, remember that only point positions can change, not the number of points
  104467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104469. * @param name defines the name of the new line system
  104470. * @param options defines the options used to create the line system
  104471. * @param scene defines the hosting scene
  104472. * @returns a new line mesh
  104473. */
  104474. static CreateLines(name: string, options: {
  104475. points: Vector3[];
  104476. updatable?: boolean;
  104477. instance?: Nullable<LinesMesh>;
  104478. colors?: Color4[];
  104479. useVertexAlpha?: boolean;
  104480. }, scene?: Nullable<Scene>): LinesMesh;
  104481. /**
  104482. * Creates a dashed line mesh
  104483. * * 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
  104484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104485. * * The parameter `points` is an array successive Vector3
  104486. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104487. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104488. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104489. * * 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
  104490. * * When updating an instance, remember that only point positions can change, not the number of points
  104491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104492. * @param name defines the name of the mesh
  104493. * @param options defines the options used to create the mesh
  104494. * @param scene defines the hosting scene
  104495. * @returns the dashed line mesh
  104496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104497. */
  104498. static CreateDashedLines(name: string, options: {
  104499. points: Vector3[];
  104500. dashSize?: number;
  104501. gapSize?: number;
  104502. dashNb?: number;
  104503. updatable?: boolean;
  104504. instance?: LinesMesh;
  104505. }, scene?: Nullable<Scene>): LinesMesh;
  104506. }
  104507. }
  104508. declare module BABYLON {
  104509. /**
  104510. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104511. * in order to better appreciate the issue one might have.
  104512. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104513. */
  104514. export class RayHelper {
  104515. /**
  104516. * Defines the ray we are currently tryin to visualize.
  104517. */
  104518. ray: Nullable<Ray>;
  104519. private _renderPoints;
  104520. private _renderLine;
  104521. private _renderFunction;
  104522. private _scene;
  104523. private _updateToMeshFunction;
  104524. private _attachedToMesh;
  104525. private _meshSpaceDirection;
  104526. private _meshSpaceOrigin;
  104527. /**
  104528. * Helper function to create a colored helper in a scene in one line.
  104529. * @param ray Defines the ray we are currently tryin to visualize
  104530. * @param scene Defines the scene the ray is used in
  104531. * @param color Defines the color we want to see the ray in
  104532. * @returns The newly created ray helper.
  104533. */
  104534. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104535. /**
  104536. * Instantiate a new ray helper.
  104537. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104538. * in order to better appreciate the issue one might have.
  104539. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104540. * @param ray Defines the ray we are currently tryin to visualize
  104541. */
  104542. constructor(ray: Ray);
  104543. /**
  104544. * Shows the ray we are willing to debug.
  104545. * @param scene Defines the scene the ray needs to be rendered in
  104546. * @param color Defines the color the ray needs to be rendered in
  104547. */
  104548. show(scene: Scene, color?: Color3): void;
  104549. /**
  104550. * Hides the ray we are debugging.
  104551. */
  104552. hide(): void;
  104553. private _render;
  104554. /**
  104555. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104556. * @param mesh Defines the mesh we want the helper attached to
  104557. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104558. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104559. * @param length Defines the length of the ray
  104560. */
  104561. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104562. /**
  104563. * Detach the ray helper from the mesh it has previously been attached to.
  104564. */
  104565. detachFromMesh(): void;
  104566. private _updateToMesh;
  104567. /**
  104568. * Dispose the helper and release its associated resources.
  104569. */
  104570. dispose(): void;
  104571. }
  104572. }
  104573. declare module BABYLON.Debug {
  104574. /**
  104575. * Class used to render a debug view of a given skeleton
  104576. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104577. */
  104578. export class SkeletonViewer {
  104579. /** defines the skeleton to render */
  104580. skeleton: Skeleton;
  104581. /** defines the mesh attached to the skeleton */
  104582. mesh: AbstractMesh;
  104583. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104584. autoUpdateBonesMatrices: boolean;
  104585. /** defines the rendering group id to use with the viewer */
  104586. renderingGroupId: number;
  104587. /** Gets or sets the color used to render the skeleton */
  104588. color: Color3;
  104589. private _scene;
  104590. private _debugLines;
  104591. private _debugMesh;
  104592. private _isEnabled;
  104593. private _renderFunction;
  104594. private _utilityLayer;
  104595. /**
  104596. * Returns the mesh used to render the bones
  104597. */
  104598. readonly debugMesh: Nullable<LinesMesh>;
  104599. /**
  104600. * Creates a new SkeletonViewer
  104601. * @param skeleton defines the skeleton to render
  104602. * @param mesh defines the mesh attached to the skeleton
  104603. * @param scene defines the hosting scene
  104604. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104605. * @param renderingGroupId defines the rendering group id to use with the viewer
  104606. */
  104607. constructor(
  104608. /** defines the skeleton to render */
  104609. skeleton: Skeleton,
  104610. /** defines the mesh attached to the skeleton */
  104611. mesh: AbstractMesh, scene: Scene,
  104612. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104613. autoUpdateBonesMatrices?: boolean,
  104614. /** defines the rendering group id to use with the viewer */
  104615. renderingGroupId?: number);
  104616. /** Gets or sets a boolean indicating if the viewer is enabled */
  104617. isEnabled: boolean;
  104618. private _getBonePosition;
  104619. private _getLinesForBonesWithLength;
  104620. private _getLinesForBonesNoLength;
  104621. /** Update the viewer to sync with current skeleton state */
  104622. update(): void;
  104623. /** Release associated resources */
  104624. dispose(): void;
  104625. }
  104626. }
  104627. declare module BABYLON {
  104628. /**
  104629. * Options to create the null engine
  104630. */
  104631. export class NullEngineOptions {
  104632. /**
  104633. * Render width (Default: 512)
  104634. */
  104635. renderWidth: number;
  104636. /**
  104637. * Render height (Default: 256)
  104638. */
  104639. renderHeight: number;
  104640. /**
  104641. * Texture size (Default: 512)
  104642. */
  104643. textureSize: number;
  104644. /**
  104645. * If delta time between frames should be constant
  104646. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104647. */
  104648. deterministicLockstep: boolean;
  104649. /**
  104650. * Maximum about of steps between frames (Default: 4)
  104651. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104652. */
  104653. lockstepMaxSteps: number;
  104654. }
  104655. /**
  104656. * The null engine class provides support for headless version of babylon.js.
  104657. * This can be used in server side scenario or for testing purposes
  104658. */
  104659. export class NullEngine extends Engine {
  104660. private _options;
  104661. /**
  104662. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104663. */
  104664. isDeterministicLockStep(): boolean;
  104665. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104666. getLockstepMaxSteps(): number;
  104667. /**
  104668. * Sets hardware scaling, used to save performance if needed
  104669. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104670. */
  104671. getHardwareScalingLevel(): number;
  104672. constructor(options?: NullEngineOptions);
  104673. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104674. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104675. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104676. getRenderWidth(useScreen?: boolean): number;
  104677. getRenderHeight(useScreen?: boolean): number;
  104678. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104679. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104680. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104682. bindSamplers(effect: Effect): void;
  104683. enableEffect(effect: Effect): void;
  104684. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104685. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104686. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104687. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104688. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104689. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104690. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104691. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104692. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104693. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104694. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104695. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104696. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104697. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104698. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104699. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104700. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104701. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104702. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104703. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104704. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104705. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104706. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104707. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104708. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104709. bindBuffers(vertexBuffers: {
  104710. [key: string]: VertexBuffer;
  104711. }, indexBuffer: DataBuffer, effect: Effect): void;
  104712. wipeCaches(bruteForce?: boolean): void;
  104713. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104714. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104715. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104716. /** @hidden */
  104717. _createTexture(): WebGLTexture;
  104718. /** @hidden */
  104719. _releaseTexture(texture: InternalTexture): void;
  104720. 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;
  104721. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104722. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104723. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104724. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104725. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104726. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104727. areAllEffectsReady(): boolean;
  104728. /**
  104729. * @hidden
  104730. * Get the current error code of the webGL context
  104731. * @returns the error code
  104732. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104733. */
  104734. getError(): number;
  104735. /** @hidden */
  104736. _getUnpackAlignement(): number;
  104737. /** @hidden */
  104738. _unpackFlipY(value: boolean): void;
  104739. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104740. /**
  104741. * Updates a dynamic vertex buffer.
  104742. * @param vertexBuffer the vertex buffer to update
  104743. * @param data the data used to update the vertex buffer
  104744. * @param byteOffset the byte offset of the data (optional)
  104745. * @param byteLength the byte length of the data (optional)
  104746. */
  104747. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104748. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104749. /** @hidden */
  104750. _bindTexture(channel: number, texture: InternalTexture): void;
  104751. /** @hidden */
  104752. _releaseBuffer(buffer: DataBuffer): boolean;
  104753. releaseEffects(): void;
  104754. displayLoadingUI(): void;
  104755. hideLoadingUI(): void;
  104756. /** @hidden */
  104757. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104758. /** @hidden */
  104759. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104760. /** @hidden */
  104761. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104762. /** @hidden */
  104763. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104764. }
  104765. }
  104766. declare module BABYLON {
  104767. /** @hidden */
  104768. export class _OcclusionDataStorage {
  104769. /** @hidden */
  104770. occlusionInternalRetryCounter: number;
  104771. /** @hidden */
  104772. isOcclusionQueryInProgress: boolean;
  104773. /** @hidden */
  104774. isOccluded: boolean;
  104775. /** @hidden */
  104776. occlusionRetryCount: number;
  104777. /** @hidden */
  104778. occlusionType: number;
  104779. /** @hidden */
  104780. occlusionQueryAlgorithmType: number;
  104781. }
  104782. interface Engine {
  104783. /**
  104784. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104785. * @return the new query
  104786. */
  104787. createQuery(): WebGLQuery;
  104788. /**
  104789. * Delete and release a webGL query
  104790. * @param query defines the query to delete
  104791. * @return the current engine
  104792. */
  104793. deleteQuery(query: WebGLQuery): Engine;
  104794. /**
  104795. * Check if a given query has resolved and got its value
  104796. * @param query defines the query to check
  104797. * @returns true if the query got its value
  104798. */
  104799. isQueryResultAvailable(query: WebGLQuery): boolean;
  104800. /**
  104801. * Gets the value of a given query
  104802. * @param query defines the query to check
  104803. * @returns the value of the query
  104804. */
  104805. getQueryResult(query: WebGLQuery): number;
  104806. /**
  104807. * Initiates an occlusion query
  104808. * @param algorithmType defines the algorithm to use
  104809. * @param query defines the query to use
  104810. * @returns the current engine
  104811. * @see http://doc.babylonjs.com/features/occlusionquery
  104812. */
  104813. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104814. /**
  104815. * Ends an occlusion query
  104816. * @see http://doc.babylonjs.com/features/occlusionquery
  104817. * @param algorithmType defines the algorithm to use
  104818. * @returns the current engine
  104819. */
  104820. endOcclusionQuery(algorithmType: number): Engine;
  104821. /**
  104822. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104823. * Please note that only one query can be issued at a time
  104824. * @returns a time token used to track the time span
  104825. */
  104826. startTimeQuery(): Nullable<_TimeToken>;
  104827. /**
  104828. * Ends a time query
  104829. * @param token defines the token used to measure the time span
  104830. * @returns the time spent (in ns)
  104831. */
  104832. endTimeQuery(token: _TimeToken): int;
  104833. /** @hidden */
  104834. _currentNonTimestampToken: Nullable<_TimeToken>;
  104835. /** @hidden */
  104836. _createTimeQuery(): WebGLQuery;
  104837. /** @hidden */
  104838. _deleteTimeQuery(query: WebGLQuery): void;
  104839. /** @hidden */
  104840. _getGlAlgorithmType(algorithmType: number): number;
  104841. /** @hidden */
  104842. _getTimeQueryResult(query: WebGLQuery): any;
  104843. /** @hidden */
  104844. _getTimeQueryAvailability(query: WebGLQuery): any;
  104845. }
  104846. interface AbstractMesh {
  104847. /**
  104848. * Backing filed
  104849. * @hidden
  104850. */
  104851. __occlusionDataStorage: _OcclusionDataStorage;
  104852. /**
  104853. * Access property
  104854. * @hidden
  104855. */
  104856. _occlusionDataStorage: _OcclusionDataStorage;
  104857. /**
  104858. * 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.
  104859. * The default value is -1 which means don't break the query and wait till the result
  104860. * @see http://doc.babylonjs.com/features/occlusionquery
  104861. */
  104862. occlusionRetryCount: number;
  104863. /**
  104864. * 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:
  104865. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104866. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104867. * * 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.
  104868. * @see http://doc.babylonjs.com/features/occlusionquery
  104869. */
  104870. occlusionType: number;
  104871. /**
  104872. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104873. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104874. * * 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.
  104875. * @see http://doc.babylonjs.com/features/occlusionquery
  104876. */
  104877. occlusionQueryAlgorithmType: number;
  104878. /**
  104879. * 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
  104880. * @see http://doc.babylonjs.com/features/occlusionquery
  104881. */
  104882. isOccluded: boolean;
  104883. /**
  104884. * Flag to check the progress status of the query
  104885. * @see http://doc.babylonjs.com/features/occlusionquery
  104886. */
  104887. isOcclusionQueryInProgress: boolean;
  104888. }
  104889. }
  104890. declare module BABYLON {
  104891. /** @hidden */
  104892. export var _forceTransformFeedbackToBundle: boolean;
  104893. interface Engine {
  104894. /**
  104895. * Creates a webGL transform feedback object
  104896. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104897. * @returns the webGL transform feedback object
  104898. */
  104899. createTransformFeedback(): WebGLTransformFeedback;
  104900. /**
  104901. * Delete a webGL transform feedback object
  104902. * @param value defines the webGL transform feedback object to delete
  104903. */
  104904. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104905. /**
  104906. * Bind a webGL transform feedback object to the webgl context
  104907. * @param value defines the webGL transform feedback object to bind
  104908. */
  104909. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104910. /**
  104911. * Begins a transform feedback operation
  104912. * @param usePoints defines if points or triangles must be used
  104913. */
  104914. beginTransformFeedback(usePoints: boolean): void;
  104915. /**
  104916. * Ends a transform feedback operation
  104917. */
  104918. endTransformFeedback(): void;
  104919. /**
  104920. * Specify the varyings to use with transform feedback
  104921. * @param program defines the associated webGL program
  104922. * @param value defines the list of strings representing the varying names
  104923. */
  104924. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104925. /**
  104926. * Bind a webGL buffer for a transform feedback operation
  104927. * @param value defines the webGL buffer to bind
  104928. */
  104929. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104930. }
  104931. }
  104932. declare module BABYLON {
  104933. /**
  104934. * Creation options of the multi render target texture.
  104935. */
  104936. export interface IMultiRenderTargetOptions {
  104937. /**
  104938. * Define if the texture needs to create mip maps after render.
  104939. */
  104940. generateMipMaps?: boolean;
  104941. /**
  104942. * Define the types of all the draw buffers we want to create
  104943. */
  104944. types?: number[];
  104945. /**
  104946. * Define the sampling modes of all the draw buffers we want to create
  104947. */
  104948. samplingModes?: number[];
  104949. /**
  104950. * Define if a depth buffer is required
  104951. */
  104952. generateDepthBuffer?: boolean;
  104953. /**
  104954. * Define if a stencil buffer is required
  104955. */
  104956. generateStencilBuffer?: boolean;
  104957. /**
  104958. * Define if a depth texture is required instead of a depth buffer
  104959. */
  104960. generateDepthTexture?: boolean;
  104961. /**
  104962. * Define the number of desired draw buffers
  104963. */
  104964. textureCount?: number;
  104965. /**
  104966. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104967. */
  104968. doNotChangeAspectRatio?: boolean;
  104969. /**
  104970. * Define the default type of the buffers we are creating
  104971. */
  104972. defaultType?: number;
  104973. }
  104974. /**
  104975. * A multi render target, like a render target provides the ability to render to a texture.
  104976. * Unlike the render target, it can render to several draw buffers in one draw.
  104977. * This is specially interesting in deferred rendering or for any effects requiring more than
  104978. * just one color from a single pass.
  104979. */
  104980. export class MultiRenderTarget extends RenderTargetTexture {
  104981. private _internalTextures;
  104982. private _textures;
  104983. private _multiRenderTargetOptions;
  104984. /**
  104985. * Get if draw buffers are currently supported by the used hardware and browser.
  104986. */
  104987. readonly isSupported: boolean;
  104988. /**
  104989. * Get the list of textures generated by the multi render target.
  104990. */
  104991. readonly textures: Texture[];
  104992. /**
  104993. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104994. */
  104995. readonly depthTexture: Texture;
  104996. /**
  104997. * Set the wrapping mode on U of all the textures we are rendering to.
  104998. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104999. */
  105000. wrapU: number;
  105001. /**
  105002. * Set the wrapping mode on V of all the textures we are rendering to.
  105003. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  105004. */
  105005. wrapV: number;
  105006. /**
  105007. * Instantiate a new multi render target texture.
  105008. * A multi render target, like a render target provides the ability to render to a texture.
  105009. * Unlike the render target, it can render to several draw buffers in one draw.
  105010. * This is specially interesting in deferred rendering or for any effects requiring more than
  105011. * just one color from a single pass.
  105012. * @param name Define the name of the texture
  105013. * @param size Define the size of the buffers to render to
  105014. * @param count Define the number of target we are rendering into
  105015. * @param scene Define the scene the texture belongs to
  105016. * @param options Define the options used to create the multi render target
  105017. */
  105018. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  105019. /** @hidden */
  105020. _rebuild(): void;
  105021. private _createInternalTextures;
  105022. private _createTextures;
  105023. /**
  105024. * Define the number of samples used if MSAA is enabled.
  105025. */
  105026. samples: number;
  105027. /**
  105028. * Resize all the textures in the multi render target.
  105029. * Be carrefull as it will recreate all the data in the new texture.
  105030. * @param size Define the new size
  105031. */
  105032. resize(size: any): void;
  105033. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  105034. /**
  105035. * Dispose the render targets and their associated resources
  105036. */
  105037. dispose(): void;
  105038. /**
  105039. * Release all the underlying texture used as draw buffers.
  105040. */
  105041. releaseInternalTextures(): void;
  105042. }
  105043. }
  105044. declare module BABYLON {
  105045. interface Engine {
  105046. /**
  105047. * Unbind a list of render target textures from the webGL context
  105048. * This is used only when drawBuffer extension or webGL2 are active
  105049. * @param textures defines the render target textures to unbind
  105050. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105051. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105052. */
  105053. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105054. /**
  105055. * Create a multi render target texture
  105056. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105057. * @param size defines the size of the texture
  105058. * @param options defines the creation options
  105059. * @returns the cube texture as an InternalTexture
  105060. */
  105061. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105062. /**
  105063. * Update the sample count for a given multiple render target texture
  105064. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105065. * @param textures defines the textures to update
  105066. * @param samples defines the sample count to set
  105067. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105068. */
  105069. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105070. }
  105071. }
  105072. declare module BABYLON {
  105073. /**
  105074. * Gather the list of clipboard event types as constants.
  105075. */
  105076. export class ClipboardEventTypes {
  105077. /**
  105078. * The clipboard event is fired when a copy command is active (pressed).
  105079. */
  105080. static readonly COPY: number;
  105081. /**
  105082. * The clipboard event is fired when a cut command is active (pressed).
  105083. */
  105084. static readonly CUT: number;
  105085. /**
  105086. * The clipboard event is fired when a paste command is active (pressed).
  105087. */
  105088. static readonly PASTE: number;
  105089. }
  105090. /**
  105091. * This class is used to store clipboard related info for the onClipboardObservable event.
  105092. */
  105093. export class ClipboardInfo {
  105094. /**
  105095. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105096. */
  105097. type: number;
  105098. /**
  105099. * Defines the related dom event
  105100. */
  105101. event: ClipboardEvent;
  105102. /**
  105103. *Creates an instance of ClipboardInfo.
  105104. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105105. * @param event Defines the related dom event
  105106. */
  105107. constructor(
  105108. /**
  105109. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105110. */
  105111. type: number,
  105112. /**
  105113. * Defines the related dom event
  105114. */
  105115. event: ClipboardEvent);
  105116. /**
  105117. * Get the clipboard event's type from the keycode.
  105118. * @param keyCode Defines the keyCode for the current keyboard event.
  105119. * @return {number}
  105120. */
  105121. static GetTypeFromCharacter(keyCode: number): number;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. /**
  105126. * Class used to represent data loading progression
  105127. */
  105128. export class SceneLoaderProgressEvent {
  105129. /** defines if data length to load can be evaluated */
  105130. readonly lengthComputable: boolean;
  105131. /** defines the loaded data length */
  105132. readonly loaded: number;
  105133. /** defines the data length to load */
  105134. readonly total: number;
  105135. /**
  105136. * Create a new progress event
  105137. * @param lengthComputable defines if data length to load can be evaluated
  105138. * @param loaded defines the loaded data length
  105139. * @param total defines the data length to load
  105140. */
  105141. constructor(
  105142. /** defines if data length to load can be evaluated */
  105143. lengthComputable: boolean,
  105144. /** defines the loaded data length */
  105145. loaded: number,
  105146. /** defines the data length to load */
  105147. total: number);
  105148. /**
  105149. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105150. * @param event defines the source event
  105151. * @returns a new SceneLoaderProgressEvent
  105152. */
  105153. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105154. }
  105155. /**
  105156. * Interface used by SceneLoader plugins to define supported file extensions
  105157. */
  105158. export interface ISceneLoaderPluginExtensions {
  105159. /**
  105160. * Defines the list of supported extensions
  105161. */
  105162. [extension: string]: {
  105163. isBinary: boolean;
  105164. };
  105165. }
  105166. /**
  105167. * Interface used by SceneLoader plugin factory
  105168. */
  105169. export interface ISceneLoaderPluginFactory {
  105170. /**
  105171. * Defines the name of the factory
  105172. */
  105173. name: string;
  105174. /**
  105175. * Function called to create a new plugin
  105176. * @return the new plugin
  105177. */
  105178. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105179. /**
  105180. * Boolean indicating if the plugin can direct load specific data
  105181. */
  105182. canDirectLoad?: (data: string) => boolean;
  105183. }
  105184. /**
  105185. * Interface used to define a SceneLoader plugin
  105186. */
  105187. export interface ISceneLoaderPlugin {
  105188. /**
  105189. * The friendly name of this plugin.
  105190. */
  105191. name: string;
  105192. /**
  105193. * The file extensions supported by this plugin.
  105194. */
  105195. extensions: string | ISceneLoaderPluginExtensions;
  105196. /**
  105197. * Import meshes into a scene.
  105198. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105199. * @param scene The scene to import into
  105200. * @param data The data to import
  105201. * @param rootUrl The root url for scene and resources
  105202. * @param meshes The meshes array to import into
  105203. * @param particleSystems The particle systems array to import into
  105204. * @param skeletons The skeletons array to import into
  105205. * @param onError The callback when import fails
  105206. * @returns True if successful or false otherwise
  105207. */
  105208. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105209. /**
  105210. * Load into a scene.
  105211. * @param scene The scene to load into
  105212. * @param data The data to import
  105213. * @param rootUrl The root url for scene and resources
  105214. * @param onError The callback when import fails
  105215. * @returns true if successful or false otherwise
  105216. */
  105217. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105218. /**
  105219. * The callback that returns true if the data can be directly loaded.
  105220. */
  105221. canDirectLoad?: (data: string) => boolean;
  105222. /**
  105223. * The callback that allows custom handling of the root url based on the response url.
  105224. */
  105225. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105226. /**
  105227. * Load into an asset container.
  105228. * @param scene The scene to load into
  105229. * @param data The data to import
  105230. * @param rootUrl The root url for scene and resources
  105231. * @param onError The callback when import fails
  105232. * @returns The loaded asset container
  105233. */
  105234. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105235. }
  105236. /**
  105237. * Interface used to define an async SceneLoader plugin
  105238. */
  105239. export interface ISceneLoaderPluginAsync {
  105240. /**
  105241. * The friendly name of this plugin.
  105242. */
  105243. name: string;
  105244. /**
  105245. * The file extensions supported by this plugin.
  105246. */
  105247. extensions: string | ISceneLoaderPluginExtensions;
  105248. /**
  105249. * Import meshes into a scene.
  105250. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105251. * @param scene The scene to import into
  105252. * @param data The data to import
  105253. * @param rootUrl The root url for scene and resources
  105254. * @param onProgress The callback when the load progresses
  105255. * @param fileName Defines the name of the file to load
  105256. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105257. */
  105258. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105259. meshes: AbstractMesh[];
  105260. particleSystems: IParticleSystem[];
  105261. skeletons: Skeleton[];
  105262. animationGroups: AnimationGroup[];
  105263. }>;
  105264. /**
  105265. * Load into a scene.
  105266. * @param scene The scene to load into
  105267. * @param data The data to import
  105268. * @param rootUrl The root url for scene and resources
  105269. * @param onProgress The callback when the load progresses
  105270. * @param fileName Defines the name of the file to load
  105271. * @returns Nothing
  105272. */
  105273. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105274. /**
  105275. * The callback that returns true if the data can be directly loaded.
  105276. */
  105277. canDirectLoad?: (data: string) => boolean;
  105278. /**
  105279. * The callback that allows custom handling of the root url based on the response url.
  105280. */
  105281. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105282. /**
  105283. * Load into an asset container.
  105284. * @param scene The scene to load into
  105285. * @param data The data to import
  105286. * @param rootUrl The root url for scene and resources
  105287. * @param onProgress The callback when the load progresses
  105288. * @param fileName Defines the name of the file to load
  105289. * @returns The loaded asset container
  105290. */
  105291. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105292. }
  105293. /**
  105294. * Class used to load scene from various file formats using registered plugins
  105295. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105296. */
  105297. export class SceneLoader {
  105298. /**
  105299. * No logging while loading
  105300. */
  105301. static readonly NO_LOGGING: number;
  105302. /**
  105303. * Minimal logging while loading
  105304. */
  105305. static readonly MINIMAL_LOGGING: number;
  105306. /**
  105307. * Summary logging while loading
  105308. */
  105309. static readonly SUMMARY_LOGGING: number;
  105310. /**
  105311. * Detailled logging while loading
  105312. */
  105313. static readonly DETAILED_LOGGING: number;
  105314. /**
  105315. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105316. */
  105317. static ForceFullSceneLoadingForIncremental: boolean;
  105318. /**
  105319. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105320. */
  105321. static ShowLoadingScreen: boolean;
  105322. /**
  105323. * Defines the current logging level (while loading the scene)
  105324. * @ignorenaming
  105325. */
  105326. static loggingLevel: number;
  105327. /**
  105328. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105329. */
  105330. static CleanBoneMatrixWeights: boolean;
  105331. /**
  105332. * Event raised when a plugin is used to load a scene
  105333. */
  105334. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105335. private static _registeredPlugins;
  105336. private static _getDefaultPlugin;
  105337. private static _getPluginForExtension;
  105338. private static _getPluginForDirectLoad;
  105339. private static _getPluginForFilename;
  105340. private static _getDirectLoad;
  105341. private static _loadData;
  105342. private static _getFileInfo;
  105343. /**
  105344. * Gets a plugin that can load the given extension
  105345. * @param extension defines the extension to load
  105346. * @returns a plugin or null if none works
  105347. */
  105348. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105349. /**
  105350. * Gets a boolean indicating that the given extension can be loaded
  105351. * @param extension defines the extension to load
  105352. * @returns true if the extension is supported
  105353. */
  105354. static IsPluginForExtensionAvailable(extension: string): boolean;
  105355. /**
  105356. * Adds a new plugin to the list of registered plugins
  105357. * @param plugin defines the plugin to add
  105358. */
  105359. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105360. /**
  105361. * Import meshes into a scene
  105362. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105363. * @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)
  105364. * @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)
  105365. * @param scene the instance of BABYLON.Scene to append to
  105366. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105367. * @param onProgress a callback with a progress event for each file being loaded
  105368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105369. * @param pluginExtension the extension used to determine the plugin
  105370. * @returns The loaded plugin
  105371. */
  105372. 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>;
  105373. /**
  105374. * Import meshes into a scene
  105375. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105376. * @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)
  105377. * @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)
  105378. * @param scene the instance of BABYLON.Scene to append to
  105379. * @param onProgress a callback with a progress event for each file being loaded
  105380. * @param pluginExtension the extension used to determine the plugin
  105381. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105382. */
  105383. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105384. meshes: AbstractMesh[];
  105385. particleSystems: IParticleSystem[];
  105386. skeletons: Skeleton[];
  105387. animationGroups: AnimationGroup[];
  105388. }>;
  105389. /**
  105390. * Load a scene
  105391. * @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)
  105392. * @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)
  105393. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105394. * @param onSuccess a callback with the scene when import succeeds
  105395. * @param onProgress a callback with a progress event for each file being loaded
  105396. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105397. * @param pluginExtension the extension used to determine the plugin
  105398. * @returns The loaded plugin
  105399. */
  105400. 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>;
  105401. /**
  105402. * Load a scene
  105403. * @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)
  105404. * @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)
  105405. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105406. * @param onProgress a callback with a progress event for each file being loaded
  105407. * @param pluginExtension the extension used to determine the plugin
  105408. * @returns The loaded scene
  105409. */
  105410. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105411. /**
  105412. * Append a scene
  105413. * @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)
  105414. * @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)
  105415. * @param scene is the instance of BABYLON.Scene to append to
  105416. * @param onSuccess a callback with the scene when import succeeds
  105417. * @param onProgress a callback with a progress event for each file being loaded
  105418. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105419. * @param pluginExtension the extension used to determine the plugin
  105420. * @returns The loaded plugin
  105421. */
  105422. 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>;
  105423. /**
  105424. * Append a scene
  105425. * @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)
  105426. * @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)
  105427. * @param scene is the instance of BABYLON.Scene to append to
  105428. * @param onProgress a callback with a progress event for each file being loaded
  105429. * @param pluginExtension the extension used to determine the plugin
  105430. * @returns The given scene
  105431. */
  105432. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105433. /**
  105434. * Load a scene into an asset container
  105435. * @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)
  105436. * @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)
  105437. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105438. * @param onSuccess a callback with the scene when import succeeds
  105439. * @param onProgress a callback with a progress event for each file being loaded
  105440. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105441. * @param pluginExtension the extension used to determine the plugin
  105442. * @returns The loaded plugin
  105443. */
  105444. 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>;
  105445. /**
  105446. * Load a scene into an asset container
  105447. * @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)
  105448. * @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)
  105449. * @param scene is the instance of Scene to append to
  105450. * @param onProgress a callback with a progress event for each file being loaded
  105451. * @param pluginExtension the extension used to determine the plugin
  105452. * @returns The loaded asset container
  105453. */
  105454. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105455. }
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * Google Daydream controller
  105460. */
  105461. export class DaydreamController extends WebVRController {
  105462. /**
  105463. * Base Url for the controller model.
  105464. */
  105465. static MODEL_BASE_URL: string;
  105466. /**
  105467. * File name for the controller model.
  105468. */
  105469. static MODEL_FILENAME: string;
  105470. /**
  105471. * Gamepad Id prefix used to identify Daydream Controller.
  105472. */
  105473. static readonly GAMEPAD_ID_PREFIX: string;
  105474. /**
  105475. * Creates a new DaydreamController from a gamepad
  105476. * @param vrGamepad the gamepad that the controller should be created from
  105477. */
  105478. constructor(vrGamepad: any);
  105479. /**
  105480. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105481. * @param scene scene in which to add meshes
  105482. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105483. */
  105484. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105485. /**
  105486. * Called once for each button that changed state since the last frame
  105487. * @param buttonIdx Which button index changed
  105488. * @param state New state of the button
  105489. * @param changes Which properties on the state changed since last frame
  105490. */
  105491. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105492. }
  105493. }
  105494. declare module BABYLON {
  105495. /**
  105496. * Gear VR Controller
  105497. */
  105498. export class GearVRController extends WebVRController {
  105499. /**
  105500. * Base Url for the controller model.
  105501. */
  105502. static MODEL_BASE_URL: string;
  105503. /**
  105504. * File name for the controller model.
  105505. */
  105506. static MODEL_FILENAME: string;
  105507. /**
  105508. * Gamepad Id prefix used to identify this controller.
  105509. */
  105510. static readonly GAMEPAD_ID_PREFIX: string;
  105511. private readonly _buttonIndexToObservableNameMap;
  105512. /**
  105513. * Creates a new GearVRController from a gamepad
  105514. * @param vrGamepad the gamepad that the controller should be created from
  105515. */
  105516. constructor(vrGamepad: any);
  105517. /**
  105518. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105519. * @param scene scene in which to add meshes
  105520. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105521. */
  105522. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105523. /**
  105524. * Called once for each button that changed state since the last frame
  105525. * @param buttonIdx Which button index changed
  105526. * @param state New state of the button
  105527. * @param changes Which properties on the state changed since last frame
  105528. */
  105529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105530. }
  105531. }
  105532. declare module BABYLON {
  105533. /**
  105534. * Generic Controller
  105535. */
  105536. export class GenericController extends WebVRController {
  105537. /**
  105538. * Base Url for the controller model.
  105539. */
  105540. static readonly MODEL_BASE_URL: string;
  105541. /**
  105542. * File name for the controller model.
  105543. */
  105544. static readonly MODEL_FILENAME: string;
  105545. /**
  105546. * Creates a new GenericController from a gamepad
  105547. * @param vrGamepad the gamepad that the controller should be created from
  105548. */
  105549. constructor(vrGamepad: any);
  105550. /**
  105551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105552. * @param scene scene in which to add meshes
  105553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105554. */
  105555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105556. /**
  105557. * Called once for each button that changed state since the last frame
  105558. * @param buttonIdx Which button index changed
  105559. * @param state New state of the button
  105560. * @param changes Which properties on the state changed since last frame
  105561. */
  105562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105563. }
  105564. }
  105565. declare module BABYLON {
  105566. /**
  105567. * Oculus Touch Controller
  105568. */
  105569. export class OculusTouchController extends WebVRController {
  105570. /**
  105571. * Base Url for the controller model.
  105572. */
  105573. static MODEL_BASE_URL: string;
  105574. /**
  105575. * File name for the left controller model.
  105576. */
  105577. static MODEL_LEFT_FILENAME: string;
  105578. /**
  105579. * File name for the right controller model.
  105580. */
  105581. static MODEL_RIGHT_FILENAME: string;
  105582. /**
  105583. * Base Url for the Quest controller model.
  105584. */
  105585. static QUEST_MODEL_BASE_URL: string;
  105586. /**
  105587. * @hidden
  105588. * If the controllers are running on a device that needs the updated Quest controller models
  105589. */
  105590. static _IsQuest: boolean;
  105591. /**
  105592. * Fired when the secondary trigger on this controller is modified
  105593. */
  105594. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105595. /**
  105596. * Fired when the thumb rest on this controller is modified
  105597. */
  105598. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105599. /**
  105600. * Creates a new OculusTouchController from a gamepad
  105601. * @param vrGamepad the gamepad that the controller should be created from
  105602. */
  105603. constructor(vrGamepad: any);
  105604. /**
  105605. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105606. * @param scene scene in which to add meshes
  105607. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105608. */
  105609. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105610. /**
  105611. * Fired when the A button on this controller is modified
  105612. */
  105613. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105614. /**
  105615. * Fired when the B button on this controller is modified
  105616. */
  105617. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105618. /**
  105619. * Fired when the X button on this controller is modified
  105620. */
  105621. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105622. /**
  105623. * Fired when the Y button on this controller is modified
  105624. */
  105625. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105626. /**
  105627. * Called once for each button that changed state since the last frame
  105628. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105629. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105630. * 2) secondary trigger (same)
  105631. * 3) A (right) X (left), touch, pressed = value
  105632. * 4) B / Y
  105633. * 5) thumb rest
  105634. * @param buttonIdx Which button index changed
  105635. * @param state New state of the button
  105636. * @param changes Which properties on the state changed since last frame
  105637. */
  105638. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105639. }
  105640. }
  105641. declare module BABYLON {
  105642. /**
  105643. * Vive Controller
  105644. */
  105645. export class ViveController extends WebVRController {
  105646. /**
  105647. * Base Url for the controller model.
  105648. */
  105649. static MODEL_BASE_URL: string;
  105650. /**
  105651. * File name for the controller model.
  105652. */
  105653. static MODEL_FILENAME: string;
  105654. /**
  105655. * Creates a new ViveController from a gamepad
  105656. * @param vrGamepad the gamepad that the controller should be created from
  105657. */
  105658. constructor(vrGamepad: any);
  105659. /**
  105660. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105661. * @param scene scene in which to add meshes
  105662. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105663. */
  105664. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105665. /**
  105666. * Fired when the left button on this controller is modified
  105667. */
  105668. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105669. /**
  105670. * Fired when the right button on this controller is modified
  105671. */
  105672. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105673. /**
  105674. * Fired when the menu button on this controller is modified
  105675. */
  105676. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105677. /**
  105678. * Called once for each button that changed state since the last frame
  105679. * Vive mapping:
  105680. * 0: touchpad
  105681. * 1: trigger
  105682. * 2: left AND right buttons
  105683. * 3: menu button
  105684. * @param buttonIdx Which button index changed
  105685. * @param state New state of the button
  105686. * @param changes Which properties on the state changed since last frame
  105687. */
  105688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105689. }
  105690. }
  105691. declare module BABYLON {
  105692. /**
  105693. * Defines the WindowsMotionController object that the state of the windows motion controller
  105694. */
  105695. export class WindowsMotionController extends WebVRController {
  105696. /**
  105697. * The base url used to load the left and right controller models
  105698. */
  105699. static MODEL_BASE_URL: string;
  105700. /**
  105701. * The name of the left controller model file
  105702. */
  105703. static MODEL_LEFT_FILENAME: string;
  105704. /**
  105705. * The name of the right controller model file
  105706. */
  105707. static MODEL_RIGHT_FILENAME: string;
  105708. /**
  105709. * The controller name prefix for this controller type
  105710. */
  105711. static readonly GAMEPAD_ID_PREFIX: string;
  105712. /**
  105713. * The controller id pattern for this controller type
  105714. */
  105715. private static readonly GAMEPAD_ID_PATTERN;
  105716. private _loadedMeshInfo;
  105717. private readonly _mapping;
  105718. /**
  105719. * Fired when the trackpad on this controller is clicked
  105720. */
  105721. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105722. /**
  105723. * Fired when the trackpad on this controller is modified
  105724. */
  105725. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105726. /**
  105727. * The current x and y values of this controller's trackpad
  105728. */
  105729. trackpad: StickValues;
  105730. /**
  105731. * Creates a new WindowsMotionController from a gamepad
  105732. * @param vrGamepad the gamepad that the controller should be created from
  105733. */
  105734. constructor(vrGamepad: any);
  105735. /**
  105736. * Fired when the trigger on this controller is modified
  105737. */
  105738. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105739. /**
  105740. * Fired when the menu button on this controller is modified
  105741. */
  105742. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105743. /**
  105744. * Fired when the grip button on this controller is modified
  105745. */
  105746. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105747. /**
  105748. * Fired when the thumbstick button on this controller is modified
  105749. */
  105750. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105751. /**
  105752. * Fired when the touchpad button on this controller is modified
  105753. */
  105754. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105755. /**
  105756. * Fired when the touchpad values on this controller are modified
  105757. */
  105758. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105759. private _updateTrackpad;
  105760. /**
  105761. * Called once per frame by the engine.
  105762. */
  105763. update(): void;
  105764. /**
  105765. * Called once for each button that changed state since the last frame
  105766. * @param buttonIdx Which button index changed
  105767. * @param state New state of the button
  105768. * @param changes Which properties on the state changed since last frame
  105769. */
  105770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105771. /**
  105772. * Moves the buttons on the controller mesh based on their current state
  105773. * @param buttonName the name of the button to move
  105774. * @param buttonValue the value of the button which determines the buttons new position
  105775. */
  105776. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105777. /**
  105778. * Moves the axis on the controller mesh based on its current state
  105779. * @param axis the index of the axis
  105780. * @param axisValue the value of the axis which determines the meshes new position
  105781. * @hidden
  105782. */
  105783. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105784. /**
  105785. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105786. * @param scene scene in which to add meshes
  105787. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105788. */
  105789. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105790. /**
  105791. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105792. * can be transformed by button presses and axes values, based on this._mapping.
  105793. *
  105794. * @param scene scene in which the meshes exist
  105795. * @param meshes list of meshes that make up the controller model to process
  105796. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105797. */
  105798. private processModel;
  105799. private createMeshInfo;
  105800. /**
  105801. * Gets the ray of the controller in the direction the controller is pointing
  105802. * @param length the length the resulting ray should be
  105803. * @returns a ray in the direction the controller is pointing
  105804. */
  105805. getForwardRay(length?: number): Ray;
  105806. /**
  105807. * Disposes of the controller
  105808. */
  105809. dispose(): void;
  105810. }
  105811. }
  105812. declare module BABYLON {
  105813. /**
  105814. * Class containing static functions to help procedurally build meshes
  105815. */
  105816. export class PolyhedronBuilder {
  105817. /**
  105818. * Creates a polyhedron mesh
  105819. * * 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
  105820. * * The parameter `size` (positive float, default 1) sets the polygon size
  105821. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105822. * * 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`
  105823. * * 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
  105824. * * 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)`)
  105825. * * 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
  105826. * * 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
  105827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105830. * @param name defines the name of the mesh
  105831. * @param options defines the options used to create the mesh
  105832. * @param scene defines the hosting scene
  105833. * @returns the polyhedron mesh
  105834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105835. */
  105836. static CreatePolyhedron(name: string, options: {
  105837. type?: number;
  105838. size?: number;
  105839. sizeX?: number;
  105840. sizeY?: number;
  105841. sizeZ?: number;
  105842. custom?: any;
  105843. faceUV?: Vector4[];
  105844. faceColors?: Color4[];
  105845. flat?: boolean;
  105846. updatable?: boolean;
  105847. sideOrientation?: number;
  105848. frontUVs?: Vector4;
  105849. backUVs?: Vector4;
  105850. }, scene?: Nullable<Scene>): Mesh;
  105851. }
  105852. }
  105853. declare module BABYLON {
  105854. /**
  105855. * Gizmo that enables scaling a mesh along 3 axis
  105856. */
  105857. export class ScaleGizmo extends Gizmo {
  105858. /**
  105859. * Internal gizmo used for interactions on the x axis
  105860. */
  105861. xGizmo: AxisScaleGizmo;
  105862. /**
  105863. * Internal gizmo used for interactions on the y axis
  105864. */
  105865. yGizmo: AxisScaleGizmo;
  105866. /**
  105867. * Internal gizmo used for interactions on the z axis
  105868. */
  105869. zGizmo: AxisScaleGizmo;
  105870. /**
  105871. * Internal gizmo used to scale all axis equally
  105872. */
  105873. uniformScaleGizmo: AxisScaleGizmo;
  105874. private _meshAttached;
  105875. private _updateGizmoRotationToMatchAttachedMesh;
  105876. private _snapDistance;
  105877. private _scaleRatio;
  105878. private _uniformScalingMesh;
  105879. private _octahedron;
  105880. /** Fires an event when any of it's sub gizmos are dragged */
  105881. onDragStartObservable: Observable<unknown>;
  105882. /** Fires an event when any of it's sub gizmos are released from dragging */
  105883. onDragEndObservable: Observable<unknown>;
  105884. attachedMesh: Nullable<AbstractMesh>;
  105885. /**
  105886. * Creates a ScaleGizmo
  105887. * @param gizmoLayer The utility layer the gizmo will be added to
  105888. */
  105889. constructor(gizmoLayer?: UtilityLayerRenderer);
  105890. updateGizmoRotationToMatchAttachedMesh: boolean;
  105891. /**
  105892. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105893. */
  105894. snapDistance: number;
  105895. /**
  105896. * Ratio for the scale of the gizmo (Default: 1)
  105897. */
  105898. scaleRatio: number;
  105899. /**
  105900. * Disposes of the gizmo
  105901. */
  105902. dispose(): void;
  105903. }
  105904. }
  105905. declare module BABYLON {
  105906. /**
  105907. * Single axis scale gizmo
  105908. */
  105909. export class AxisScaleGizmo extends Gizmo {
  105910. /**
  105911. * Drag behavior responsible for the gizmos dragging interactions
  105912. */
  105913. dragBehavior: PointerDragBehavior;
  105914. private _pointerObserver;
  105915. /**
  105916. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105917. */
  105918. snapDistance: number;
  105919. /**
  105920. * Event that fires each time the gizmo snaps to a new location.
  105921. * * snapDistance is the the change in distance
  105922. */
  105923. onSnapObservable: Observable<{
  105924. snapDistance: number;
  105925. }>;
  105926. /**
  105927. * If the scaling operation should be done on all axis (default: false)
  105928. */
  105929. uniformScaling: boolean;
  105930. private _isEnabled;
  105931. private _parent;
  105932. private _arrow;
  105933. private _coloredMaterial;
  105934. private _hoverMaterial;
  105935. /**
  105936. * Creates an AxisScaleGizmo
  105937. * @param gizmoLayer The utility layer the gizmo will be added to
  105938. * @param dragAxis The axis which the gizmo will be able to scale on
  105939. * @param color The color of the gizmo
  105940. */
  105941. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105942. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105943. /**
  105944. * If the gizmo is enabled
  105945. */
  105946. isEnabled: boolean;
  105947. /**
  105948. * Disposes of the gizmo
  105949. */
  105950. dispose(): void;
  105951. /**
  105952. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105953. * @param mesh The mesh to replace the default mesh of the gizmo
  105954. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105955. */
  105956. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105957. }
  105958. }
  105959. declare module BABYLON {
  105960. /**
  105961. * Bounding box gizmo
  105962. */
  105963. export class BoundingBoxGizmo extends Gizmo {
  105964. private _lineBoundingBox;
  105965. private _rotateSpheresParent;
  105966. private _scaleBoxesParent;
  105967. private _boundingDimensions;
  105968. private _renderObserver;
  105969. private _pointerObserver;
  105970. private _scaleDragSpeed;
  105971. private _tmpQuaternion;
  105972. private _tmpVector;
  105973. private _tmpRotationMatrix;
  105974. /**
  105975. * 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)
  105976. */
  105977. ignoreChildren: boolean;
  105978. /**
  105979. * 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)
  105980. */
  105981. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105982. /**
  105983. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105984. */
  105985. rotationSphereSize: number;
  105986. /**
  105987. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105988. */
  105989. scaleBoxSize: number;
  105990. /**
  105991. * 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)
  105992. */
  105993. fixedDragMeshScreenSize: boolean;
  105994. /**
  105995. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105996. */
  105997. fixedDragMeshScreenSizeDistanceFactor: number;
  105998. /**
  105999. * Fired when a rotation sphere or scale box is dragged
  106000. */
  106001. onDragStartObservable: Observable<{}>;
  106002. /**
  106003. * Fired when a scale box is dragged
  106004. */
  106005. onScaleBoxDragObservable: Observable<{}>;
  106006. /**
  106007. * Fired when a scale box drag is ended
  106008. */
  106009. onScaleBoxDragEndObservable: Observable<{}>;
  106010. /**
  106011. * Fired when a rotation sphere is dragged
  106012. */
  106013. onRotationSphereDragObservable: Observable<{}>;
  106014. /**
  106015. * Fired when a rotation sphere drag is ended
  106016. */
  106017. onRotationSphereDragEndObservable: Observable<{}>;
  106018. /**
  106019. * 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)
  106020. */
  106021. scalePivot: Nullable<Vector3>;
  106022. /**
  106023. * Mesh used as a pivot to rotate the attached mesh
  106024. */
  106025. private _anchorMesh;
  106026. private _existingMeshScale;
  106027. private _dragMesh;
  106028. private pointerDragBehavior;
  106029. private coloredMaterial;
  106030. private hoverColoredMaterial;
  106031. /**
  106032. * Sets the color of the bounding box gizmo
  106033. * @param color the color to set
  106034. */
  106035. setColor(color: Color3): void;
  106036. /**
  106037. * Creates an BoundingBoxGizmo
  106038. * @param gizmoLayer The utility layer the gizmo will be added to
  106039. * @param color The color of the gizmo
  106040. */
  106041. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106043. private _selectNode;
  106044. /**
  106045. * Updates the bounding box information for the Gizmo
  106046. */
  106047. updateBoundingBox(): void;
  106048. private _updateRotationSpheres;
  106049. private _updateScaleBoxes;
  106050. /**
  106051. * Enables rotation on the specified axis and disables rotation on the others
  106052. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106053. */
  106054. setEnabledRotationAxis(axis: string): void;
  106055. /**
  106056. * Enables/disables scaling
  106057. * @param enable if scaling should be enabled
  106058. */
  106059. setEnabledScaling(enable: boolean): void;
  106060. private _updateDummy;
  106061. /**
  106062. * Enables a pointer drag behavior on the bounding box of the gizmo
  106063. */
  106064. enableDragBehavior(): void;
  106065. /**
  106066. * Disposes of the gizmo
  106067. */
  106068. dispose(): void;
  106069. /**
  106070. * 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)
  106071. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106072. * @returns the bounding box mesh with the passed in mesh as a child
  106073. */
  106074. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106075. /**
  106076. * CustomMeshes are not supported by this gizmo
  106077. * @param mesh The mesh to replace the default mesh of the gizmo
  106078. */
  106079. setCustomMesh(mesh: Mesh): void;
  106080. }
  106081. }
  106082. declare module BABYLON {
  106083. /**
  106084. * Single plane rotation gizmo
  106085. */
  106086. export class PlaneRotationGizmo extends Gizmo {
  106087. /**
  106088. * Drag behavior responsible for the gizmos dragging interactions
  106089. */
  106090. dragBehavior: PointerDragBehavior;
  106091. private _pointerObserver;
  106092. /**
  106093. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106094. */
  106095. snapDistance: number;
  106096. /**
  106097. * Event that fires each time the gizmo snaps to a new location.
  106098. * * snapDistance is the the change in distance
  106099. */
  106100. onSnapObservable: Observable<{
  106101. snapDistance: number;
  106102. }>;
  106103. private _isEnabled;
  106104. private _parent;
  106105. /**
  106106. * Creates a PlaneRotationGizmo
  106107. * @param gizmoLayer The utility layer the gizmo will be added to
  106108. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106109. * @param color The color of the gizmo
  106110. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106111. */
  106112. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106113. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106114. /**
  106115. * If the gizmo is enabled
  106116. */
  106117. isEnabled: boolean;
  106118. /**
  106119. * Disposes of the gizmo
  106120. */
  106121. dispose(): void;
  106122. }
  106123. }
  106124. declare module BABYLON {
  106125. /**
  106126. * Gizmo that enables rotating a mesh along 3 axis
  106127. */
  106128. export class RotationGizmo extends Gizmo {
  106129. /**
  106130. * Internal gizmo used for interactions on the x axis
  106131. */
  106132. xGizmo: PlaneRotationGizmo;
  106133. /**
  106134. * Internal gizmo used for interactions on the y axis
  106135. */
  106136. yGizmo: PlaneRotationGizmo;
  106137. /**
  106138. * Internal gizmo used for interactions on the z axis
  106139. */
  106140. zGizmo: PlaneRotationGizmo;
  106141. /** Fires an event when any of it's sub gizmos are dragged */
  106142. onDragStartObservable: Observable<unknown>;
  106143. /** Fires an event when any of it's sub gizmos are released from dragging */
  106144. onDragEndObservable: Observable<unknown>;
  106145. private _meshAttached;
  106146. attachedMesh: Nullable<AbstractMesh>;
  106147. /**
  106148. * Creates a RotationGizmo
  106149. * @param gizmoLayer The utility layer the gizmo will be added to
  106150. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106151. */
  106152. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106153. updateGizmoRotationToMatchAttachedMesh: boolean;
  106154. /**
  106155. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106156. */
  106157. snapDistance: number;
  106158. /**
  106159. * Ratio for the scale of the gizmo (Default: 1)
  106160. */
  106161. scaleRatio: number;
  106162. /**
  106163. * Disposes of the gizmo
  106164. */
  106165. dispose(): void;
  106166. /**
  106167. * CustomMeshes are not supported by this gizmo
  106168. * @param mesh The mesh to replace the default mesh of the gizmo
  106169. */
  106170. setCustomMesh(mesh: Mesh): void;
  106171. }
  106172. }
  106173. declare module BABYLON {
  106174. /**
  106175. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106176. */
  106177. export class GizmoManager implements IDisposable {
  106178. private scene;
  106179. /**
  106180. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106181. */
  106182. gizmos: {
  106183. positionGizmo: Nullable<PositionGizmo>;
  106184. rotationGizmo: Nullable<RotationGizmo>;
  106185. scaleGizmo: Nullable<ScaleGizmo>;
  106186. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106187. };
  106188. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106189. clearGizmoOnEmptyPointerEvent: boolean;
  106190. /** Fires an event when the manager is attached to a mesh */
  106191. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106192. private _gizmosEnabled;
  106193. private _pointerObserver;
  106194. private _attachedMesh;
  106195. private _boundingBoxColor;
  106196. private _defaultUtilityLayer;
  106197. private _defaultKeepDepthUtilityLayer;
  106198. /**
  106199. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106200. */
  106201. boundingBoxDragBehavior: SixDofDragBehavior;
  106202. /**
  106203. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106204. */
  106205. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106206. /**
  106207. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106208. */
  106209. usePointerToAttachGizmos: boolean;
  106210. /**
  106211. * Utility layer that the bounding box gizmo belongs to
  106212. */
  106213. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106214. /**
  106215. * Utility layer that all gizmos besides bounding box belong to
  106216. */
  106217. readonly utilityLayer: UtilityLayerRenderer;
  106218. /**
  106219. * Instatiates a gizmo manager
  106220. * @param scene the scene to overlay the gizmos on top of
  106221. */
  106222. constructor(scene: Scene);
  106223. /**
  106224. * Attaches a set of gizmos to the specified mesh
  106225. * @param mesh The mesh the gizmo's should be attached to
  106226. */
  106227. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106228. /**
  106229. * If the position gizmo is enabled
  106230. */
  106231. positionGizmoEnabled: boolean;
  106232. /**
  106233. * If the rotation gizmo is enabled
  106234. */
  106235. rotationGizmoEnabled: boolean;
  106236. /**
  106237. * If the scale gizmo is enabled
  106238. */
  106239. scaleGizmoEnabled: boolean;
  106240. /**
  106241. * If the boundingBox gizmo is enabled
  106242. */
  106243. boundingBoxGizmoEnabled: boolean;
  106244. /**
  106245. * Disposes of the gizmo manager
  106246. */
  106247. dispose(): void;
  106248. }
  106249. }
  106250. declare module BABYLON {
  106251. /**
  106252. * A directional light is defined by a direction (what a surprise!).
  106253. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106254. * 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.
  106255. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106256. */
  106257. export class DirectionalLight extends ShadowLight {
  106258. private _shadowFrustumSize;
  106259. /**
  106260. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106261. */
  106262. /**
  106263. * Specifies a fix frustum size for the shadow generation.
  106264. */
  106265. shadowFrustumSize: number;
  106266. private _shadowOrthoScale;
  106267. /**
  106268. * Gets the shadow projection scale against the optimal computed one.
  106269. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106270. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106271. */
  106272. /**
  106273. * Sets the shadow projection scale against the optimal computed one.
  106274. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106275. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106276. */
  106277. shadowOrthoScale: number;
  106278. /**
  106279. * Automatically compute the projection matrix to best fit (including all the casters)
  106280. * on each frame.
  106281. */
  106282. autoUpdateExtends: boolean;
  106283. private _orthoLeft;
  106284. private _orthoRight;
  106285. private _orthoTop;
  106286. private _orthoBottom;
  106287. /**
  106288. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106289. * The directional light is emitted from everywhere in the given direction.
  106290. * It can cast shadows.
  106291. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106292. * @param name The friendly name of the light
  106293. * @param direction The direction of the light
  106294. * @param scene The scene the light belongs to
  106295. */
  106296. constructor(name: string, direction: Vector3, scene: Scene);
  106297. /**
  106298. * Returns the string "DirectionalLight".
  106299. * @return The class name
  106300. */
  106301. getClassName(): string;
  106302. /**
  106303. * Returns the integer 1.
  106304. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106305. */
  106306. getTypeID(): number;
  106307. /**
  106308. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106309. * Returns the DirectionalLight Shadow projection matrix.
  106310. */
  106311. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106312. /**
  106313. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106314. * Returns the DirectionalLight Shadow projection matrix.
  106315. */
  106316. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106317. /**
  106318. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106319. * Returns the DirectionalLight Shadow projection matrix.
  106320. */
  106321. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106322. protected _buildUniformLayout(): void;
  106323. /**
  106324. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106325. * @param effect The effect to update
  106326. * @param lightIndex The index of the light in the effect to update
  106327. * @returns The directional light
  106328. */
  106329. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106330. /**
  106331. * Gets the minZ used for shadow according to both the scene and the light.
  106332. *
  106333. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106334. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106335. * @param activeCamera The camera we are returning the min for
  106336. * @returns the depth min z
  106337. */
  106338. getDepthMinZ(activeCamera: Camera): number;
  106339. /**
  106340. * Gets the maxZ used for shadow according to both the scene and the light.
  106341. *
  106342. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106343. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106344. * @param activeCamera The camera we are returning the max for
  106345. * @returns the depth max z
  106346. */
  106347. getDepthMaxZ(activeCamera: Camera): number;
  106348. /**
  106349. * Prepares the list of defines specific to the light type.
  106350. * @param defines the list of defines
  106351. * @param lightIndex defines the index of the light for the effect
  106352. */
  106353. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106354. }
  106355. }
  106356. declare module BABYLON {
  106357. /**
  106358. * Class containing static functions to help procedurally build meshes
  106359. */
  106360. export class HemisphereBuilder {
  106361. /**
  106362. * Creates a hemisphere mesh
  106363. * @param name defines the name of the mesh
  106364. * @param options defines the options used to create the mesh
  106365. * @param scene defines the hosting scene
  106366. * @returns the hemisphere mesh
  106367. */
  106368. static CreateHemisphere(name: string, options: {
  106369. segments?: number;
  106370. diameter?: number;
  106371. sideOrientation?: number;
  106372. }, scene: any): Mesh;
  106373. }
  106374. }
  106375. declare module BABYLON {
  106376. /**
  106377. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106378. * These values define a cone of light starting from the position, emitting toward the direction.
  106379. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106380. * and the exponent defines the speed of the decay of the light with distance (reach).
  106381. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106382. */
  106383. export class SpotLight extends ShadowLight {
  106384. private _angle;
  106385. private _innerAngle;
  106386. private _cosHalfAngle;
  106387. private _lightAngleScale;
  106388. private _lightAngleOffset;
  106389. /**
  106390. * Gets the cone angle of the spot light in Radians.
  106391. */
  106392. /**
  106393. * Sets the cone angle of the spot light in Radians.
  106394. */
  106395. angle: number;
  106396. /**
  106397. * Only used in gltf falloff mode, this defines the angle where
  106398. * the directional falloff will start before cutting at angle which could be seen
  106399. * as outer angle.
  106400. */
  106401. /**
  106402. * Only used in gltf falloff mode, this defines the angle where
  106403. * the directional falloff will start before cutting at angle which could be seen
  106404. * as outer angle.
  106405. */
  106406. innerAngle: number;
  106407. private _shadowAngleScale;
  106408. /**
  106409. * Allows scaling the angle of the light for shadow generation only.
  106410. */
  106411. /**
  106412. * Allows scaling the angle of the light for shadow generation only.
  106413. */
  106414. shadowAngleScale: number;
  106415. /**
  106416. * The light decay speed with the distance from the emission spot.
  106417. */
  106418. exponent: number;
  106419. private _projectionTextureMatrix;
  106420. /**
  106421. * Allows reading the projecton texture
  106422. */
  106423. readonly projectionTextureMatrix: Matrix;
  106424. protected _projectionTextureLightNear: number;
  106425. /**
  106426. * Gets the near clip of the Spotlight for texture projection.
  106427. */
  106428. /**
  106429. * Sets the near clip of the Spotlight for texture projection.
  106430. */
  106431. projectionTextureLightNear: number;
  106432. protected _projectionTextureLightFar: number;
  106433. /**
  106434. * Gets the far clip of the Spotlight for texture projection.
  106435. */
  106436. /**
  106437. * Sets the far clip of the Spotlight for texture projection.
  106438. */
  106439. projectionTextureLightFar: number;
  106440. protected _projectionTextureUpDirection: Vector3;
  106441. /**
  106442. * Gets the Up vector of the Spotlight for texture projection.
  106443. */
  106444. /**
  106445. * Sets the Up vector of the Spotlight for texture projection.
  106446. */
  106447. projectionTextureUpDirection: Vector3;
  106448. private _projectionTexture;
  106449. /**
  106450. * Gets the projection texture of the light.
  106451. */
  106452. /**
  106453. * Sets the projection texture of the light.
  106454. */
  106455. projectionTexture: Nullable<BaseTexture>;
  106456. private _projectionTextureViewLightDirty;
  106457. private _projectionTextureProjectionLightDirty;
  106458. private _projectionTextureDirty;
  106459. private _projectionTextureViewTargetVector;
  106460. private _projectionTextureViewLightMatrix;
  106461. private _projectionTextureProjectionLightMatrix;
  106462. private _projectionTextureScalingMatrix;
  106463. /**
  106464. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106465. * It can cast shadows.
  106466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106467. * @param name The light friendly name
  106468. * @param position The position of the spot light in the scene
  106469. * @param direction The direction of the light in the scene
  106470. * @param angle The cone angle of the light in Radians
  106471. * @param exponent The light decay speed with the distance from the emission spot
  106472. * @param scene The scene the lights belongs to
  106473. */
  106474. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106475. /**
  106476. * Returns the string "SpotLight".
  106477. * @returns the class name
  106478. */
  106479. getClassName(): string;
  106480. /**
  106481. * Returns the integer 2.
  106482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106483. */
  106484. getTypeID(): number;
  106485. /**
  106486. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106487. */
  106488. protected _setDirection(value: Vector3): void;
  106489. /**
  106490. * Overrides the position setter to recompute the projection texture view light Matrix.
  106491. */
  106492. protected _setPosition(value: Vector3): void;
  106493. /**
  106494. * 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.
  106495. * Returns the SpotLight.
  106496. */
  106497. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106498. protected _computeProjectionTextureViewLightMatrix(): void;
  106499. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106500. /**
  106501. * Main function for light texture projection matrix computing.
  106502. */
  106503. protected _computeProjectionTextureMatrix(): void;
  106504. protected _buildUniformLayout(): void;
  106505. private _computeAngleValues;
  106506. /**
  106507. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106508. * @param effect The effect to update
  106509. * @param lightIndex The index of the light in the effect to update
  106510. * @returns The spot light
  106511. */
  106512. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106513. /**
  106514. * Disposes the light and the associated resources.
  106515. */
  106516. dispose(): void;
  106517. /**
  106518. * Prepares the list of defines specific to the light type.
  106519. * @param defines the list of defines
  106520. * @param lightIndex defines the index of the light for the effect
  106521. */
  106522. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106523. }
  106524. }
  106525. declare module BABYLON {
  106526. /**
  106527. * Gizmo that enables viewing a light
  106528. */
  106529. export class LightGizmo extends Gizmo {
  106530. private _lightMesh;
  106531. private _material;
  106532. private cachedPosition;
  106533. private cachedForward;
  106534. /**
  106535. * Creates a LightGizmo
  106536. * @param gizmoLayer The utility layer the gizmo will be added to
  106537. */
  106538. constructor(gizmoLayer?: UtilityLayerRenderer);
  106539. private _light;
  106540. /**
  106541. * The light that the gizmo is attached to
  106542. */
  106543. light: Nullable<Light>;
  106544. /**
  106545. * @hidden
  106546. * Updates the gizmo to match the attached mesh's position/rotation
  106547. */
  106548. protected _update(): void;
  106549. private static _Scale;
  106550. /**
  106551. * Creates the lines for a light mesh
  106552. */
  106553. private static _createLightLines;
  106554. /**
  106555. * Disposes of the light gizmo
  106556. */
  106557. dispose(): void;
  106558. private static _CreateHemisphericLightMesh;
  106559. private static _CreatePointLightMesh;
  106560. private static _CreateSpotLightMesh;
  106561. private static _CreateDirectionalLightMesh;
  106562. }
  106563. }
  106564. declare module BABYLON {
  106565. /** @hidden */
  106566. export var backgroundFragmentDeclaration: {
  106567. name: string;
  106568. shader: string;
  106569. };
  106570. }
  106571. declare module BABYLON {
  106572. /** @hidden */
  106573. export var backgroundUboDeclaration: {
  106574. name: string;
  106575. shader: string;
  106576. };
  106577. }
  106578. declare module BABYLON {
  106579. /** @hidden */
  106580. export var backgroundPixelShader: {
  106581. name: string;
  106582. shader: string;
  106583. };
  106584. }
  106585. declare module BABYLON {
  106586. /** @hidden */
  106587. export var backgroundVertexDeclaration: {
  106588. name: string;
  106589. shader: string;
  106590. };
  106591. }
  106592. declare module BABYLON {
  106593. /** @hidden */
  106594. export var backgroundVertexShader: {
  106595. name: string;
  106596. shader: string;
  106597. };
  106598. }
  106599. declare module BABYLON {
  106600. /**
  106601. * Background material used to create an efficient environement around your scene.
  106602. */
  106603. export class BackgroundMaterial extends PushMaterial {
  106604. /**
  106605. * Standard reflectance value at parallel view angle.
  106606. */
  106607. static StandardReflectance0: number;
  106608. /**
  106609. * Standard reflectance value at grazing angle.
  106610. */
  106611. static StandardReflectance90: number;
  106612. protected _primaryColor: Color3;
  106613. /**
  106614. * Key light Color (multiply against the environement texture)
  106615. */
  106616. primaryColor: Color3;
  106617. protected __perceptualColor: Nullable<Color3>;
  106618. /**
  106619. * Experimental Internal Use Only.
  106620. *
  106621. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106622. * This acts as a helper to set the primary color to a more "human friendly" value.
  106623. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106624. * output color as close as possible from the chosen value.
  106625. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106626. * part of lighting setup.)
  106627. */
  106628. _perceptualColor: Nullable<Color3>;
  106629. protected _primaryColorShadowLevel: float;
  106630. /**
  106631. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106632. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106633. */
  106634. primaryColorShadowLevel: float;
  106635. protected _primaryColorHighlightLevel: float;
  106636. /**
  106637. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106638. * The primary color is used at the level chosen to define what the white area would look.
  106639. */
  106640. primaryColorHighlightLevel: float;
  106641. protected _reflectionTexture: Nullable<BaseTexture>;
  106642. /**
  106643. * Reflection Texture used in the material.
  106644. * Should be author in a specific way for the best result (refer to the documentation).
  106645. */
  106646. reflectionTexture: Nullable<BaseTexture>;
  106647. protected _reflectionBlur: float;
  106648. /**
  106649. * Reflection Texture level of blur.
  106650. *
  106651. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106652. * texture twice.
  106653. */
  106654. reflectionBlur: float;
  106655. protected _diffuseTexture: Nullable<BaseTexture>;
  106656. /**
  106657. * Diffuse Texture used in the material.
  106658. * Should be author in a specific way for the best result (refer to the documentation).
  106659. */
  106660. diffuseTexture: Nullable<BaseTexture>;
  106661. protected _shadowLights: Nullable<IShadowLight[]>;
  106662. /**
  106663. * Specify the list of lights casting shadow on the material.
  106664. * All scene shadow lights will be included if null.
  106665. */
  106666. shadowLights: Nullable<IShadowLight[]>;
  106667. protected _shadowLevel: float;
  106668. /**
  106669. * Helps adjusting the shadow to a softer level if required.
  106670. * 0 means black shadows and 1 means no shadows.
  106671. */
  106672. shadowLevel: float;
  106673. protected _sceneCenter: Vector3;
  106674. /**
  106675. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106676. * It is usually zero but might be interesting to modify according to your setup.
  106677. */
  106678. sceneCenter: Vector3;
  106679. protected _opacityFresnel: boolean;
  106680. /**
  106681. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106682. * This helps ensuring a nice transition when the camera goes under the ground.
  106683. */
  106684. opacityFresnel: boolean;
  106685. protected _reflectionFresnel: boolean;
  106686. /**
  106687. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106688. * This helps adding a mirror texture on the ground.
  106689. */
  106690. reflectionFresnel: boolean;
  106691. protected _reflectionFalloffDistance: number;
  106692. /**
  106693. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106694. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106695. */
  106696. reflectionFalloffDistance: number;
  106697. protected _reflectionAmount: number;
  106698. /**
  106699. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106700. */
  106701. reflectionAmount: number;
  106702. protected _reflectionReflectance0: number;
  106703. /**
  106704. * This specifies the weight of the reflection at grazing angle.
  106705. */
  106706. reflectionReflectance0: number;
  106707. protected _reflectionReflectance90: number;
  106708. /**
  106709. * This specifies the weight of the reflection at a perpendicular point of view.
  106710. */
  106711. reflectionReflectance90: number;
  106712. /**
  106713. * Sets the reflection reflectance fresnel values according to the default standard
  106714. * empirically know to work well :-)
  106715. */
  106716. reflectionStandardFresnelWeight: number;
  106717. protected _useRGBColor: boolean;
  106718. /**
  106719. * Helps to directly use the maps channels instead of their level.
  106720. */
  106721. useRGBColor: boolean;
  106722. protected _enableNoise: boolean;
  106723. /**
  106724. * This helps reducing the banding effect that could occur on the background.
  106725. */
  106726. enableNoise: boolean;
  106727. /**
  106728. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106729. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106730. * Recommended to be keep at 1.0 except for special cases.
  106731. */
  106732. fovMultiplier: number;
  106733. private _fovMultiplier;
  106734. /**
  106735. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106736. */
  106737. useEquirectangularFOV: boolean;
  106738. private _maxSimultaneousLights;
  106739. /**
  106740. * Number of Simultaneous lights allowed on the material.
  106741. */
  106742. maxSimultaneousLights: int;
  106743. /**
  106744. * Default configuration related to image processing available in the Background Material.
  106745. */
  106746. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106747. /**
  106748. * Keep track of the image processing observer to allow dispose and replace.
  106749. */
  106750. private _imageProcessingObserver;
  106751. /**
  106752. * Attaches a new image processing configuration to the PBR Material.
  106753. * @param configuration (if null the scene configuration will be use)
  106754. */
  106755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106756. /**
  106757. * Gets the image processing configuration used either in this material.
  106758. */
  106759. /**
  106760. * Sets the Default image processing configuration used either in the this material.
  106761. *
  106762. * If sets to null, the scene one is in use.
  106763. */
  106764. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106765. /**
  106766. * Gets wether the color curves effect is enabled.
  106767. */
  106768. /**
  106769. * Sets wether the color curves effect is enabled.
  106770. */
  106771. cameraColorCurvesEnabled: boolean;
  106772. /**
  106773. * Gets wether the color grading effect is enabled.
  106774. */
  106775. /**
  106776. * Gets wether the color grading effect is enabled.
  106777. */
  106778. cameraColorGradingEnabled: boolean;
  106779. /**
  106780. * Gets wether tonemapping is enabled or not.
  106781. */
  106782. /**
  106783. * Sets wether tonemapping is enabled or not
  106784. */
  106785. cameraToneMappingEnabled: boolean;
  106786. /**
  106787. * The camera exposure used on this material.
  106788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106789. * This corresponds to a photographic exposure.
  106790. */
  106791. /**
  106792. * The camera exposure used on this material.
  106793. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106794. * This corresponds to a photographic exposure.
  106795. */
  106796. cameraExposure: float;
  106797. /**
  106798. * Gets The camera contrast used on this material.
  106799. */
  106800. /**
  106801. * Sets The camera contrast used on this material.
  106802. */
  106803. cameraContrast: float;
  106804. /**
  106805. * Gets the Color Grading 2D Lookup Texture.
  106806. */
  106807. /**
  106808. * Sets the Color Grading 2D Lookup Texture.
  106809. */
  106810. cameraColorGradingTexture: Nullable<BaseTexture>;
  106811. /**
  106812. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106813. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106814. * 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;
  106815. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106816. */
  106817. /**
  106818. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106819. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106820. * 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;
  106821. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106822. */
  106823. cameraColorCurves: Nullable<ColorCurves>;
  106824. /**
  106825. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106826. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106827. */
  106828. switchToBGR: boolean;
  106829. private _renderTargets;
  106830. private _reflectionControls;
  106831. private _white;
  106832. private _primaryShadowColor;
  106833. private _primaryHighlightColor;
  106834. /**
  106835. * Instantiates a Background Material in the given scene
  106836. * @param name The friendly name of the material
  106837. * @param scene The scene to add the material to
  106838. */
  106839. constructor(name: string, scene: Scene);
  106840. /**
  106841. * Gets a boolean indicating that current material needs to register RTT
  106842. */
  106843. readonly hasRenderTargetTextures: boolean;
  106844. /**
  106845. * The entire material has been created in order to prevent overdraw.
  106846. * @returns false
  106847. */
  106848. needAlphaTesting(): boolean;
  106849. /**
  106850. * The entire material has been created in order to prevent overdraw.
  106851. * @returns true if blending is enable
  106852. */
  106853. needAlphaBlending(): boolean;
  106854. /**
  106855. * Checks wether the material is ready to be rendered for a given mesh.
  106856. * @param mesh The mesh to render
  106857. * @param subMesh The submesh to check against
  106858. * @param useInstances Specify wether or not the material is used with instances
  106859. * @returns true if all the dependencies are ready (Textures, Effects...)
  106860. */
  106861. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106862. /**
  106863. * Compute the primary color according to the chosen perceptual color.
  106864. */
  106865. private _computePrimaryColorFromPerceptualColor;
  106866. /**
  106867. * Compute the highlights and shadow colors according to their chosen levels.
  106868. */
  106869. private _computePrimaryColors;
  106870. /**
  106871. * Build the uniform buffer used in the material.
  106872. */
  106873. buildUniformLayout(): void;
  106874. /**
  106875. * Unbind the material.
  106876. */
  106877. unbind(): void;
  106878. /**
  106879. * Bind only the world matrix to the material.
  106880. * @param world The world matrix to bind.
  106881. */
  106882. bindOnlyWorldMatrix(world: Matrix): void;
  106883. /**
  106884. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106885. * @param world The world matrix to bind.
  106886. * @param subMesh The submesh to bind for.
  106887. */
  106888. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106889. /**
  106890. * Dispose the material.
  106891. * @param forceDisposeEffect Force disposal of the associated effect.
  106892. * @param forceDisposeTextures Force disposal of the associated textures.
  106893. */
  106894. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106895. /**
  106896. * Clones the material.
  106897. * @param name The cloned name.
  106898. * @returns The cloned material.
  106899. */
  106900. clone(name: string): BackgroundMaterial;
  106901. /**
  106902. * Serializes the current material to its JSON representation.
  106903. * @returns The JSON representation.
  106904. */
  106905. serialize(): any;
  106906. /**
  106907. * Gets the class name of the material
  106908. * @returns "BackgroundMaterial"
  106909. */
  106910. getClassName(): string;
  106911. /**
  106912. * Parse a JSON input to create back a background material.
  106913. * @param source The JSON data to parse
  106914. * @param scene The scene to create the parsed material in
  106915. * @param rootUrl The root url of the assets the material depends upon
  106916. * @returns the instantiated BackgroundMaterial.
  106917. */
  106918. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106919. }
  106920. }
  106921. declare module BABYLON {
  106922. /**
  106923. * Represents the different options available during the creation of
  106924. * a Environment helper.
  106925. *
  106926. * This can control the default ground, skybox and image processing setup of your scene.
  106927. */
  106928. export interface IEnvironmentHelperOptions {
  106929. /**
  106930. * Specifies wether or not to create a ground.
  106931. * True by default.
  106932. */
  106933. createGround: boolean;
  106934. /**
  106935. * Specifies the ground size.
  106936. * 15 by default.
  106937. */
  106938. groundSize: number;
  106939. /**
  106940. * The texture used on the ground for the main color.
  106941. * Comes from the BabylonJS CDN by default.
  106942. *
  106943. * Remarks: Can be either a texture or a url.
  106944. */
  106945. groundTexture: string | BaseTexture;
  106946. /**
  106947. * The color mixed in the ground texture by default.
  106948. * BabylonJS clearColor by default.
  106949. */
  106950. groundColor: Color3;
  106951. /**
  106952. * Specifies the ground opacity.
  106953. * 1 by default.
  106954. */
  106955. groundOpacity: number;
  106956. /**
  106957. * Enables the ground to receive shadows.
  106958. * True by default.
  106959. */
  106960. enableGroundShadow: boolean;
  106961. /**
  106962. * Helps preventing the shadow to be fully black on the ground.
  106963. * 0.5 by default.
  106964. */
  106965. groundShadowLevel: number;
  106966. /**
  106967. * Creates a mirror texture attach to the ground.
  106968. * false by default.
  106969. */
  106970. enableGroundMirror: boolean;
  106971. /**
  106972. * Specifies the ground mirror size ratio.
  106973. * 0.3 by default as the default kernel is 64.
  106974. */
  106975. groundMirrorSizeRatio: number;
  106976. /**
  106977. * Specifies the ground mirror blur kernel size.
  106978. * 64 by default.
  106979. */
  106980. groundMirrorBlurKernel: number;
  106981. /**
  106982. * Specifies the ground mirror visibility amount.
  106983. * 1 by default
  106984. */
  106985. groundMirrorAmount: number;
  106986. /**
  106987. * Specifies the ground mirror reflectance weight.
  106988. * This uses the standard weight of the background material to setup the fresnel effect
  106989. * of the mirror.
  106990. * 1 by default.
  106991. */
  106992. groundMirrorFresnelWeight: number;
  106993. /**
  106994. * Specifies the ground mirror Falloff distance.
  106995. * This can helps reducing the size of the reflection.
  106996. * 0 by Default.
  106997. */
  106998. groundMirrorFallOffDistance: number;
  106999. /**
  107000. * Specifies the ground mirror texture type.
  107001. * Unsigned Int by Default.
  107002. */
  107003. groundMirrorTextureType: number;
  107004. /**
  107005. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107006. * the shown objects.
  107007. */
  107008. groundYBias: number;
  107009. /**
  107010. * Specifies wether or not to create a skybox.
  107011. * True by default.
  107012. */
  107013. createSkybox: boolean;
  107014. /**
  107015. * Specifies the skybox size.
  107016. * 20 by default.
  107017. */
  107018. skyboxSize: number;
  107019. /**
  107020. * The texture used on the skybox for the main color.
  107021. * Comes from the BabylonJS CDN by default.
  107022. *
  107023. * Remarks: Can be either a texture or a url.
  107024. */
  107025. skyboxTexture: string | BaseTexture;
  107026. /**
  107027. * The color mixed in the skybox texture by default.
  107028. * BabylonJS clearColor by default.
  107029. */
  107030. skyboxColor: Color3;
  107031. /**
  107032. * The background rotation around the Y axis of the scene.
  107033. * This helps aligning the key lights of your scene with the background.
  107034. * 0 by default.
  107035. */
  107036. backgroundYRotation: number;
  107037. /**
  107038. * Compute automatically the size of the elements to best fit with the scene.
  107039. */
  107040. sizeAuto: boolean;
  107041. /**
  107042. * Default position of the rootMesh if autoSize is not true.
  107043. */
  107044. rootPosition: Vector3;
  107045. /**
  107046. * Sets up the image processing in the scene.
  107047. * true by default.
  107048. */
  107049. setupImageProcessing: boolean;
  107050. /**
  107051. * The texture used as your environment texture in the scene.
  107052. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107053. *
  107054. * Remarks: Can be either a texture or a url.
  107055. */
  107056. environmentTexture: string | BaseTexture;
  107057. /**
  107058. * The value of the exposure to apply to the scene.
  107059. * 0.6 by default if setupImageProcessing is true.
  107060. */
  107061. cameraExposure: number;
  107062. /**
  107063. * The value of the contrast to apply to the scene.
  107064. * 1.6 by default if setupImageProcessing is true.
  107065. */
  107066. cameraContrast: number;
  107067. /**
  107068. * Specifies wether or not tonemapping should be enabled in the scene.
  107069. * true by default if setupImageProcessing is true.
  107070. */
  107071. toneMappingEnabled: boolean;
  107072. }
  107073. /**
  107074. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107075. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107076. * It also helps with the default setup of your imageProcessing configuration.
  107077. */
  107078. export class EnvironmentHelper {
  107079. /**
  107080. * Default ground texture URL.
  107081. */
  107082. private static _groundTextureCDNUrl;
  107083. /**
  107084. * Default skybox texture URL.
  107085. */
  107086. private static _skyboxTextureCDNUrl;
  107087. /**
  107088. * Default environment texture URL.
  107089. */
  107090. private static _environmentTextureCDNUrl;
  107091. /**
  107092. * Creates the default options for the helper.
  107093. */
  107094. private static _getDefaultOptions;
  107095. private _rootMesh;
  107096. /**
  107097. * Gets the root mesh created by the helper.
  107098. */
  107099. readonly rootMesh: Mesh;
  107100. private _skybox;
  107101. /**
  107102. * Gets the skybox created by the helper.
  107103. */
  107104. readonly skybox: Nullable<Mesh>;
  107105. private _skyboxTexture;
  107106. /**
  107107. * Gets the skybox texture created by the helper.
  107108. */
  107109. readonly skyboxTexture: Nullable<BaseTexture>;
  107110. private _skyboxMaterial;
  107111. /**
  107112. * Gets the skybox material created by the helper.
  107113. */
  107114. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107115. private _ground;
  107116. /**
  107117. * Gets the ground mesh created by the helper.
  107118. */
  107119. readonly ground: Nullable<Mesh>;
  107120. private _groundTexture;
  107121. /**
  107122. * Gets the ground texture created by the helper.
  107123. */
  107124. readonly groundTexture: Nullable<BaseTexture>;
  107125. private _groundMirror;
  107126. /**
  107127. * Gets the ground mirror created by the helper.
  107128. */
  107129. readonly groundMirror: Nullable<MirrorTexture>;
  107130. /**
  107131. * Gets the ground mirror render list to helps pushing the meshes
  107132. * you wish in the ground reflection.
  107133. */
  107134. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107135. private _groundMaterial;
  107136. /**
  107137. * Gets the ground material created by the helper.
  107138. */
  107139. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107140. /**
  107141. * Stores the creation options.
  107142. */
  107143. private readonly _scene;
  107144. private _options;
  107145. /**
  107146. * This observable will be notified with any error during the creation of the environment,
  107147. * mainly texture creation errors.
  107148. */
  107149. onErrorObservable: Observable<{
  107150. message?: string;
  107151. exception?: any;
  107152. }>;
  107153. /**
  107154. * constructor
  107155. * @param options Defines the options we want to customize the helper
  107156. * @param scene The scene to add the material to
  107157. */
  107158. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107159. /**
  107160. * Updates the background according to the new options
  107161. * @param options
  107162. */
  107163. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107164. /**
  107165. * Sets the primary color of all the available elements.
  107166. * @param color the main color to affect to the ground and the background
  107167. */
  107168. setMainColor(color: Color3): void;
  107169. /**
  107170. * Setup the image processing according to the specified options.
  107171. */
  107172. private _setupImageProcessing;
  107173. /**
  107174. * Setup the environment texture according to the specified options.
  107175. */
  107176. private _setupEnvironmentTexture;
  107177. /**
  107178. * Setup the background according to the specified options.
  107179. */
  107180. private _setupBackground;
  107181. /**
  107182. * Get the scene sizes according to the setup.
  107183. */
  107184. private _getSceneSize;
  107185. /**
  107186. * Setup the ground according to the specified options.
  107187. */
  107188. private _setupGround;
  107189. /**
  107190. * Setup the ground material according to the specified options.
  107191. */
  107192. private _setupGroundMaterial;
  107193. /**
  107194. * Setup the ground diffuse texture according to the specified options.
  107195. */
  107196. private _setupGroundDiffuseTexture;
  107197. /**
  107198. * Setup the ground mirror texture according to the specified options.
  107199. */
  107200. private _setupGroundMirrorTexture;
  107201. /**
  107202. * Setup the ground to receive the mirror texture.
  107203. */
  107204. private _setupMirrorInGroundMaterial;
  107205. /**
  107206. * Setup the skybox according to the specified options.
  107207. */
  107208. private _setupSkybox;
  107209. /**
  107210. * Setup the skybox material according to the specified options.
  107211. */
  107212. private _setupSkyboxMaterial;
  107213. /**
  107214. * Setup the skybox reflection texture according to the specified options.
  107215. */
  107216. private _setupSkyboxReflectionTexture;
  107217. private _errorHandler;
  107218. /**
  107219. * Dispose all the elements created by the Helper.
  107220. */
  107221. dispose(): void;
  107222. }
  107223. }
  107224. declare module BABYLON {
  107225. /**
  107226. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107227. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107228. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107229. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107230. */
  107231. export class PhotoDome extends TransformNode {
  107232. /**
  107233. * Define the image as a Monoscopic panoramic 360 image.
  107234. */
  107235. static readonly MODE_MONOSCOPIC: number;
  107236. /**
  107237. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107238. */
  107239. static readonly MODE_TOPBOTTOM: number;
  107240. /**
  107241. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107242. */
  107243. static readonly MODE_SIDEBYSIDE: number;
  107244. private _useDirectMapping;
  107245. /**
  107246. * The texture being displayed on the sphere
  107247. */
  107248. protected _photoTexture: Texture;
  107249. /**
  107250. * Gets or sets the texture being displayed on the sphere
  107251. */
  107252. photoTexture: Texture;
  107253. /**
  107254. * Observable raised when an error occured while loading the 360 image
  107255. */
  107256. onLoadErrorObservable: Observable<string>;
  107257. /**
  107258. * The skybox material
  107259. */
  107260. protected _material: BackgroundMaterial;
  107261. /**
  107262. * The surface used for the skybox
  107263. */
  107264. protected _mesh: Mesh;
  107265. /**
  107266. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107267. * Also see the options.resolution property.
  107268. */
  107269. fovMultiplier: number;
  107270. private _imageMode;
  107271. /**
  107272. * Gets or set the current video mode for the video. It can be:
  107273. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107274. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107275. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107276. */
  107277. imageMode: number;
  107278. /**
  107279. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107280. * @param name Element's name, child elements will append suffixes for their own names.
  107281. * @param urlsOfPhoto defines the url of the photo to display
  107282. * @param options defines an object containing optional or exposed sub element properties
  107283. * @param onError defines a callback called when an error occured while loading the texture
  107284. */
  107285. constructor(name: string, urlOfPhoto: string, options: {
  107286. resolution?: number;
  107287. size?: number;
  107288. useDirectMapping?: boolean;
  107289. faceForward?: boolean;
  107290. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107291. private _onBeforeCameraRenderObserver;
  107292. private _changeImageMode;
  107293. /**
  107294. * Releases resources associated with this node.
  107295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107297. */
  107298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107299. }
  107300. }
  107301. declare module BABYLON {
  107302. /** @hidden */
  107303. export var rgbdDecodePixelShader: {
  107304. name: string;
  107305. shader: string;
  107306. };
  107307. }
  107308. declare module BABYLON {
  107309. /**
  107310. * Class used to host texture specific utilities
  107311. */
  107312. export class BRDFTextureTools {
  107313. /**
  107314. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107315. * @param texture the texture to expand.
  107316. */
  107317. private static _ExpandDefaultBRDFTexture;
  107318. /**
  107319. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107320. * @param scene defines the hosting scene
  107321. * @returns the environment BRDF texture
  107322. */
  107323. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107324. private static _environmentBRDFBase64Texture;
  107325. }
  107326. }
  107327. declare module BABYLON {
  107328. /**
  107329. * @hidden
  107330. */
  107331. export interface IMaterialClearCoatDefines {
  107332. CLEARCOAT: boolean;
  107333. CLEARCOAT_DEFAULTIOR: boolean;
  107334. CLEARCOAT_TEXTURE: boolean;
  107335. CLEARCOAT_TEXTUREDIRECTUV: number;
  107336. CLEARCOAT_BUMP: boolean;
  107337. CLEARCOAT_BUMPDIRECTUV: number;
  107338. CLEARCOAT_TINT: boolean;
  107339. CLEARCOAT_TINT_TEXTURE: boolean;
  107340. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107341. /** @hidden */
  107342. _areTexturesDirty: boolean;
  107343. }
  107344. /**
  107345. * Define the code related to the clear coat parameters of the pbr material.
  107346. */
  107347. export class PBRClearCoatConfiguration {
  107348. /**
  107349. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107350. * The default fits with a polyurethane material.
  107351. */
  107352. private static readonly _DefaultIndexOfRefraction;
  107353. private _isEnabled;
  107354. /**
  107355. * Defines if the clear coat is enabled in the material.
  107356. */
  107357. isEnabled: boolean;
  107358. /**
  107359. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107360. */
  107361. intensity: number;
  107362. /**
  107363. * Defines the clear coat layer roughness.
  107364. */
  107365. roughness: number;
  107366. private _indexOfRefraction;
  107367. /**
  107368. * Defines the index of refraction of the clear coat.
  107369. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107370. * The default fits with a polyurethane material.
  107371. * Changing the default value is more performance intensive.
  107372. */
  107373. indexOfRefraction: number;
  107374. private _texture;
  107375. /**
  107376. * Stores the clear coat values in a texture.
  107377. */
  107378. texture: Nullable<BaseTexture>;
  107379. private _bumpTexture;
  107380. /**
  107381. * Define the clear coat specific bump texture.
  107382. */
  107383. bumpTexture: Nullable<BaseTexture>;
  107384. private _isTintEnabled;
  107385. /**
  107386. * Defines if the clear coat tint is enabled in the material.
  107387. */
  107388. isTintEnabled: boolean;
  107389. /**
  107390. * Defines the clear coat tint of the material.
  107391. * This is only use if tint is enabled
  107392. */
  107393. tintColor: Color3;
  107394. /**
  107395. * Defines the distance at which the tint color should be found in the
  107396. * clear coat media.
  107397. * This is only use if tint is enabled
  107398. */
  107399. tintColorAtDistance: number;
  107400. /**
  107401. * Defines the clear coat layer thickness.
  107402. * This is only use if tint is enabled
  107403. */
  107404. tintThickness: number;
  107405. private _tintTexture;
  107406. /**
  107407. * Stores the clear tint values in a texture.
  107408. * rgb is tint
  107409. * a is a thickness factor
  107410. */
  107411. tintTexture: Nullable<BaseTexture>;
  107412. /** @hidden */
  107413. private _internalMarkAllSubMeshesAsTexturesDirty;
  107414. /** @hidden */
  107415. _markAllSubMeshesAsTexturesDirty(): void;
  107416. /**
  107417. * Instantiate a new istance of clear coat configuration.
  107418. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107419. */
  107420. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107421. /**
  107422. * Gets wehter the submesh is ready to be used or not.
  107423. * @param defines the list of "defines" to update.
  107424. * @param scene defines the scene the material belongs to.
  107425. * @param engine defines the engine the material belongs to.
  107426. * @param disableBumpMap defines wether the material disables bump or not.
  107427. * @returns - boolean indicating that the submesh is ready or not.
  107428. */
  107429. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107430. /**
  107431. * Checks to see if a texture is used in the material.
  107432. * @param defines the list of "defines" to update.
  107433. * @param scene defines the scene to the material belongs to.
  107434. */
  107435. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107436. /**
  107437. * Binds the material data.
  107438. * @param uniformBuffer defines the Uniform buffer to fill in.
  107439. * @param scene defines the scene the material belongs to.
  107440. * @param engine defines the engine the material belongs to.
  107441. * @param disableBumpMap defines wether the material disables bump or not.
  107442. * @param isFrozen defines wether the material is frozen or not.
  107443. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107444. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107445. */
  107446. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107447. /**
  107448. * Checks to see if a texture is used in the material.
  107449. * @param texture - Base texture to use.
  107450. * @returns - Boolean specifying if a texture is used in the material.
  107451. */
  107452. hasTexture(texture: BaseTexture): boolean;
  107453. /**
  107454. * Returns an array of the actively used textures.
  107455. * @param activeTextures Array of BaseTextures
  107456. */
  107457. getActiveTextures(activeTextures: BaseTexture[]): void;
  107458. /**
  107459. * Returns the animatable textures.
  107460. * @param animatables Array of animatable textures.
  107461. */
  107462. getAnimatables(animatables: IAnimatable[]): void;
  107463. /**
  107464. * Disposes the resources of the material.
  107465. * @param forceDisposeTextures - Forces the disposal of all textures.
  107466. */
  107467. dispose(forceDisposeTextures?: boolean): void;
  107468. /**
  107469. * Get the current class name of the texture useful for serialization or dynamic coding.
  107470. * @returns "PBRClearCoatConfiguration"
  107471. */
  107472. getClassName(): string;
  107473. /**
  107474. * Add fallbacks to the effect fallbacks list.
  107475. * @param defines defines the Base texture to use.
  107476. * @param fallbacks defines the current fallback list.
  107477. * @param currentRank defines the current fallback rank.
  107478. * @returns the new fallback rank.
  107479. */
  107480. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107481. /**
  107482. * Add the required uniforms to the current list.
  107483. * @param uniforms defines the current uniform list.
  107484. */
  107485. static AddUniforms(uniforms: string[]): void;
  107486. /**
  107487. * Add the required samplers to the current list.
  107488. * @param samplers defines the current sampler list.
  107489. */
  107490. static AddSamplers(samplers: string[]): void;
  107491. /**
  107492. * Add the required uniforms to the current buffer.
  107493. * @param uniformBuffer defines the current uniform buffer.
  107494. */
  107495. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107496. /**
  107497. * Makes a duplicate of the current configuration into another one.
  107498. * @param clearCoatConfiguration define the config where to copy the info
  107499. */
  107500. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107501. /**
  107502. * Serializes this clear coat configuration.
  107503. * @returns - An object with the serialized config.
  107504. */
  107505. serialize(): any;
  107506. /**
  107507. * Parses a anisotropy Configuration from a serialized object.
  107508. * @param source - Serialized object.
  107509. * @param scene Defines the scene we are parsing for
  107510. * @param rootUrl Defines the rootUrl to load from
  107511. */
  107512. parse(source: any, scene: Scene, rootUrl: string): void;
  107513. }
  107514. }
  107515. declare module BABYLON {
  107516. /**
  107517. * @hidden
  107518. */
  107519. export interface IMaterialAnisotropicDefines {
  107520. ANISOTROPIC: boolean;
  107521. ANISOTROPIC_TEXTURE: boolean;
  107522. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107523. MAINUV1: boolean;
  107524. _areTexturesDirty: boolean;
  107525. _needUVs: boolean;
  107526. }
  107527. /**
  107528. * Define the code related to the anisotropic parameters of the pbr material.
  107529. */
  107530. export class PBRAnisotropicConfiguration {
  107531. private _isEnabled;
  107532. /**
  107533. * Defines if the anisotropy is enabled in the material.
  107534. */
  107535. isEnabled: boolean;
  107536. /**
  107537. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107538. */
  107539. intensity: number;
  107540. /**
  107541. * Defines if the effect is along the tangents, bitangents or in between.
  107542. * By default, the effect is "strectching" the highlights along the tangents.
  107543. */
  107544. direction: Vector2;
  107545. private _texture;
  107546. /**
  107547. * Stores the anisotropy values in a texture.
  107548. * rg is direction (like normal from -1 to 1)
  107549. * b is a intensity
  107550. */
  107551. texture: Nullable<BaseTexture>;
  107552. /** @hidden */
  107553. private _internalMarkAllSubMeshesAsTexturesDirty;
  107554. /** @hidden */
  107555. _markAllSubMeshesAsTexturesDirty(): void;
  107556. /**
  107557. * Instantiate a new istance of anisotropy configuration.
  107558. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107559. */
  107560. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107561. /**
  107562. * Specifies that the submesh is ready to be used.
  107563. * @param defines the list of "defines" to update.
  107564. * @param scene defines the scene the material belongs to.
  107565. * @returns - boolean indicating that the submesh is ready or not.
  107566. */
  107567. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107568. /**
  107569. * Checks to see if a texture is used in the material.
  107570. * @param defines the list of "defines" to update.
  107571. * @param mesh the mesh we are preparing the defines for.
  107572. * @param scene defines the scene the material belongs to.
  107573. */
  107574. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107575. /**
  107576. * Binds the material data.
  107577. * @param uniformBuffer defines the Uniform buffer to fill in.
  107578. * @param scene defines the scene the material belongs to.
  107579. * @param isFrozen defines wether the material is frozen or not.
  107580. */
  107581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107582. /**
  107583. * Checks to see if a texture is used in the material.
  107584. * @param texture - Base texture to use.
  107585. * @returns - Boolean specifying if a texture is used in the material.
  107586. */
  107587. hasTexture(texture: BaseTexture): boolean;
  107588. /**
  107589. * Returns an array of the actively used textures.
  107590. * @param activeTextures Array of BaseTextures
  107591. */
  107592. getActiveTextures(activeTextures: BaseTexture[]): void;
  107593. /**
  107594. * Returns the animatable textures.
  107595. * @param animatables Array of animatable textures.
  107596. */
  107597. getAnimatables(animatables: IAnimatable[]): void;
  107598. /**
  107599. * Disposes the resources of the material.
  107600. * @param forceDisposeTextures - Forces the disposal of all textures.
  107601. */
  107602. dispose(forceDisposeTextures?: boolean): void;
  107603. /**
  107604. * Get the current class name of the texture useful for serialization or dynamic coding.
  107605. * @returns "PBRAnisotropicConfiguration"
  107606. */
  107607. getClassName(): string;
  107608. /**
  107609. * Add fallbacks to the effect fallbacks list.
  107610. * @param defines defines the Base texture to use.
  107611. * @param fallbacks defines the current fallback list.
  107612. * @param currentRank defines the current fallback rank.
  107613. * @returns the new fallback rank.
  107614. */
  107615. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107616. /**
  107617. * Add the required uniforms to the current list.
  107618. * @param uniforms defines the current uniform list.
  107619. */
  107620. static AddUniforms(uniforms: string[]): void;
  107621. /**
  107622. * Add the required uniforms to the current buffer.
  107623. * @param uniformBuffer defines the current uniform buffer.
  107624. */
  107625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107626. /**
  107627. * Add the required samplers to the current list.
  107628. * @param samplers defines the current sampler list.
  107629. */
  107630. static AddSamplers(samplers: string[]): void;
  107631. /**
  107632. * Makes a duplicate of the current configuration into another one.
  107633. * @param anisotropicConfiguration define the config where to copy the info
  107634. */
  107635. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107636. /**
  107637. * Serializes this anisotropy configuration.
  107638. * @returns - An object with the serialized config.
  107639. */
  107640. serialize(): any;
  107641. /**
  107642. * Parses a anisotropy Configuration from a serialized object.
  107643. * @param source - Serialized object.
  107644. * @param scene Defines the scene we are parsing for
  107645. * @param rootUrl Defines the rootUrl to load from
  107646. */
  107647. parse(source: any, scene: Scene, rootUrl: string): void;
  107648. }
  107649. }
  107650. declare module BABYLON {
  107651. /**
  107652. * @hidden
  107653. */
  107654. export interface IMaterialBRDFDefines {
  107655. BRDF_V_HEIGHT_CORRELATED: boolean;
  107656. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107657. SPHERICAL_HARMONICS: boolean;
  107658. /** @hidden */
  107659. _areMiscDirty: boolean;
  107660. }
  107661. /**
  107662. * Define the code related to the BRDF parameters of the pbr material.
  107663. */
  107664. export class PBRBRDFConfiguration {
  107665. /**
  107666. * Default value used for the energy conservation.
  107667. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107668. */
  107669. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107670. /**
  107671. * Default value used for the Smith Visibility Height Correlated mode.
  107672. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107673. */
  107674. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107675. /**
  107676. * Default value used for the IBL diffuse part.
  107677. * This can help switching back to the polynomials mode globally which is a tiny bit
  107678. * less GPU intensive at the drawback of a lower quality.
  107679. */
  107680. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107681. private _useEnergyConservation;
  107682. /**
  107683. * Defines if the material uses energy conservation.
  107684. */
  107685. useEnergyConservation: boolean;
  107686. private _useSmithVisibilityHeightCorrelated;
  107687. /**
  107688. * LEGACY Mode set to false
  107689. * Defines if the material uses height smith correlated visibility term.
  107690. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107691. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107692. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107693. * Not relying on height correlated will also disable energy conservation.
  107694. */
  107695. useSmithVisibilityHeightCorrelated: boolean;
  107696. private _useSphericalHarmonics;
  107697. /**
  107698. * LEGACY Mode set to false
  107699. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107700. * diffuse part of the IBL.
  107701. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107702. * to the ground truth.
  107703. */
  107704. useSphericalHarmonics: boolean;
  107705. /** @hidden */
  107706. private _internalMarkAllSubMeshesAsMiscDirty;
  107707. /** @hidden */
  107708. _markAllSubMeshesAsMiscDirty(): void;
  107709. /**
  107710. * Instantiate a new istance of clear coat configuration.
  107711. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107712. */
  107713. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107714. /**
  107715. * Checks to see if a texture is used in the material.
  107716. * @param defines the list of "defines" to update.
  107717. */
  107718. prepareDefines(defines: IMaterialBRDFDefines): void;
  107719. /**
  107720. * Get the current class name of the texture useful for serialization or dynamic coding.
  107721. * @returns "PBRClearCoatConfiguration"
  107722. */
  107723. getClassName(): string;
  107724. /**
  107725. * Makes a duplicate of the current configuration into another one.
  107726. * @param brdfConfiguration define the config where to copy the info
  107727. */
  107728. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107729. /**
  107730. * Serializes this BRDF configuration.
  107731. * @returns - An object with the serialized config.
  107732. */
  107733. serialize(): any;
  107734. /**
  107735. * Parses a anisotropy Configuration from a serialized object.
  107736. * @param source - Serialized object.
  107737. * @param scene Defines the scene we are parsing for
  107738. * @param rootUrl Defines the rootUrl to load from
  107739. */
  107740. parse(source: any, scene: Scene, rootUrl: string): void;
  107741. }
  107742. }
  107743. declare module BABYLON {
  107744. /**
  107745. * @hidden
  107746. */
  107747. export interface IMaterialSheenDefines {
  107748. SHEEN: boolean;
  107749. SHEEN_TEXTURE: boolean;
  107750. SHEEN_TEXTUREDIRECTUV: number;
  107751. SHEEN_LINKWITHALBEDO: boolean;
  107752. /** @hidden */
  107753. _areTexturesDirty: boolean;
  107754. }
  107755. /**
  107756. * Define the code related to the Sheen parameters of the pbr material.
  107757. */
  107758. export class PBRSheenConfiguration {
  107759. private _isEnabled;
  107760. /**
  107761. * Defines if the material uses sheen.
  107762. */
  107763. isEnabled: boolean;
  107764. private _linkSheenWithAlbedo;
  107765. /**
  107766. * Defines if the sheen is linked to the sheen color.
  107767. */
  107768. linkSheenWithAlbedo: boolean;
  107769. /**
  107770. * Defines the sheen intensity.
  107771. */
  107772. intensity: number;
  107773. /**
  107774. * Defines the sheen color.
  107775. */
  107776. color: Color3;
  107777. private _texture;
  107778. /**
  107779. * Stores the sheen tint values in a texture.
  107780. * rgb is tint
  107781. * a is a intensity
  107782. */
  107783. texture: Nullable<BaseTexture>;
  107784. /** @hidden */
  107785. private _internalMarkAllSubMeshesAsTexturesDirty;
  107786. /** @hidden */
  107787. _markAllSubMeshesAsTexturesDirty(): void;
  107788. /**
  107789. * Instantiate a new istance of clear coat configuration.
  107790. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107791. */
  107792. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107793. /**
  107794. * Specifies that the submesh is ready to be used.
  107795. * @param defines the list of "defines" to update.
  107796. * @param scene defines the scene the material belongs to.
  107797. * @returns - boolean indicating that the submesh is ready or not.
  107798. */
  107799. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107800. /**
  107801. * Checks to see if a texture is used in the material.
  107802. * @param defines the list of "defines" to update.
  107803. * @param scene defines the scene the material belongs to.
  107804. */
  107805. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107806. /**
  107807. * Binds the material data.
  107808. * @param uniformBuffer defines the Uniform buffer to fill in.
  107809. * @param scene defines the scene the material belongs to.
  107810. * @param isFrozen defines wether the material is frozen or not.
  107811. */
  107812. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107813. /**
  107814. * Checks to see if a texture is used in the material.
  107815. * @param texture - Base texture to use.
  107816. * @returns - Boolean specifying if a texture is used in the material.
  107817. */
  107818. hasTexture(texture: BaseTexture): boolean;
  107819. /**
  107820. * Returns an array of the actively used textures.
  107821. * @param activeTextures Array of BaseTextures
  107822. */
  107823. getActiveTextures(activeTextures: BaseTexture[]): void;
  107824. /**
  107825. * Returns the animatable textures.
  107826. * @param animatables Array of animatable textures.
  107827. */
  107828. getAnimatables(animatables: IAnimatable[]): void;
  107829. /**
  107830. * Disposes the resources of the material.
  107831. * @param forceDisposeTextures - Forces the disposal of all textures.
  107832. */
  107833. dispose(forceDisposeTextures?: boolean): void;
  107834. /**
  107835. * Get the current class name of the texture useful for serialization or dynamic coding.
  107836. * @returns "PBRSheenConfiguration"
  107837. */
  107838. getClassName(): string;
  107839. /**
  107840. * Add fallbacks to the effect fallbacks list.
  107841. * @param defines defines the Base texture to use.
  107842. * @param fallbacks defines the current fallback list.
  107843. * @param currentRank defines the current fallback rank.
  107844. * @returns the new fallback rank.
  107845. */
  107846. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107847. /**
  107848. * Add the required uniforms to the current list.
  107849. * @param uniforms defines the current uniform list.
  107850. */
  107851. static AddUniforms(uniforms: string[]): void;
  107852. /**
  107853. * Add the required uniforms to the current buffer.
  107854. * @param uniformBuffer defines the current uniform buffer.
  107855. */
  107856. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107857. /**
  107858. * Add the required samplers to the current list.
  107859. * @param samplers defines the current sampler list.
  107860. */
  107861. static AddSamplers(samplers: string[]): void;
  107862. /**
  107863. * Makes a duplicate of the current configuration into another one.
  107864. * @param sheenConfiguration define the config where to copy the info
  107865. */
  107866. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107867. /**
  107868. * Serializes this BRDF configuration.
  107869. * @returns - An object with the serialized config.
  107870. */
  107871. serialize(): any;
  107872. /**
  107873. * Parses a anisotropy Configuration from a serialized object.
  107874. * @param source - Serialized object.
  107875. * @param scene Defines the scene we are parsing for
  107876. * @param rootUrl Defines the rootUrl to load from
  107877. */
  107878. parse(source: any, scene: Scene, rootUrl: string): void;
  107879. }
  107880. }
  107881. declare module BABYLON {
  107882. /**
  107883. * @hidden
  107884. */
  107885. export interface IMaterialSubSurfaceDefines {
  107886. SUBSURFACE: boolean;
  107887. SS_REFRACTION: boolean;
  107888. SS_TRANSLUCENCY: boolean;
  107889. SS_SCATERRING: boolean;
  107890. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107891. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107892. SS_REFRACTIONMAP_3D: boolean;
  107893. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107894. SS_LODINREFRACTIONALPHA: boolean;
  107895. SS_GAMMAREFRACTION: boolean;
  107896. SS_RGBDREFRACTION: boolean;
  107897. SS_LINEARSPECULARREFRACTION: boolean;
  107898. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107899. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107900. /** @hidden */
  107901. _areTexturesDirty: boolean;
  107902. }
  107903. /**
  107904. * Define the code related to the sub surface parameters of the pbr material.
  107905. */
  107906. export class PBRSubSurfaceConfiguration {
  107907. private _isRefractionEnabled;
  107908. /**
  107909. * Defines if the refraction is enabled in the material.
  107910. */
  107911. isRefractionEnabled: boolean;
  107912. private _isTranslucencyEnabled;
  107913. /**
  107914. * Defines if the translucency is enabled in the material.
  107915. */
  107916. isTranslucencyEnabled: boolean;
  107917. private _isScatteringEnabled;
  107918. /**
  107919. * Defines the refraction intensity of the material.
  107920. * The refraction when enabled replaces the Diffuse part of the material.
  107921. * The intensity helps transitionning between diffuse and refraction.
  107922. */
  107923. refractionIntensity: number;
  107924. /**
  107925. * Defines the translucency intensity of the material.
  107926. * When translucency has been enabled, this defines how much of the "translucency"
  107927. * is addded to the diffuse part of the material.
  107928. */
  107929. translucencyIntensity: number;
  107930. /**
  107931. * Defines the scattering intensity of the material.
  107932. * When scattering has been enabled, this defines how much of the "scattered light"
  107933. * is addded to the diffuse part of the material.
  107934. */
  107935. scatteringIntensity: number;
  107936. private _thicknessTexture;
  107937. /**
  107938. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107939. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107940. * 0 would mean minimumThickness
  107941. * 1 would mean maximumThickness
  107942. * The other channels might be use as a mask to vary the different effects intensity.
  107943. */
  107944. thicknessTexture: Nullable<BaseTexture>;
  107945. private _refractionTexture;
  107946. /**
  107947. * Defines the texture to use for refraction.
  107948. */
  107949. refractionTexture: Nullable<BaseTexture>;
  107950. private _indexOfRefraction;
  107951. /**
  107952. * Defines the index of refraction used in the material.
  107953. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107954. */
  107955. indexOfRefraction: number;
  107956. private _invertRefractionY;
  107957. /**
  107958. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107959. */
  107960. invertRefractionY: boolean;
  107961. private _linkRefractionWithTransparency;
  107962. /**
  107963. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107964. * Materials half opaque for instance using refraction could benefit from this control.
  107965. */
  107966. linkRefractionWithTransparency: boolean;
  107967. /**
  107968. * Defines the minimum thickness stored in the thickness map.
  107969. * If no thickness map is defined, this value will be used to simulate thickness.
  107970. */
  107971. minimumThickness: number;
  107972. /**
  107973. * Defines the maximum thickness stored in the thickness map.
  107974. */
  107975. maximumThickness: number;
  107976. /**
  107977. * Defines the volume tint of the material.
  107978. * This is used for both translucency and scattering.
  107979. */
  107980. tintColor: Color3;
  107981. /**
  107982. * Defines the distance at which the tint color should be found in the media.
  107983. * This is used for refraction only.
  107984. */
  107985. tintColorAtDistance: number;
  107986. /**
  107987. * Defines how far each channel transmit through the media.
  107988. * It is defined as a color to simplify it selection.
  107989. */
  107990. diffusionDistance: Color3;
  107991. private _useMaskFromThicknessTexture;
  107992. /**
  107993. * Stores the intensity of the different subsurface effects in the thickness texture.
  107994. * * the green channel is the translucency intensity.
  107995. * * the blue channel is the scattering intensity.
  107996. * * the alpha channel is the refraction intensity.
  107997. */
  107998. useMaskFromThicknessTexture: boolean;
  107999. /** @hidden */
  108000. private _internalMarkAllSubMeshesAsTexturesDirty;
  108001. /** @hidden */
  108002. _markAllSubMeshesAsTexturesDirty(): void;
  108003. /**
  108004. * Instantiate a new istance of sub surface configuration.
  108005. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108006. */
  108007. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108008. /**
  108009. * Gets wehter the submesh is ready to be used or not.
  108010. * @param defines the list of "defines" to update.
  108011. * @param scene defines the scene the material belongs to.
  108012. * @returns - boolean indicating that the submesh is ready or not.
  108013. */
  108014. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108015. /**
  108016. * Checks to see if a texture is used in the material.
  108017. * @param defines the list of "defines" to update.
  108018. * @param scene defines the scene to the material belongs to.
  108019. */
  108020. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108021. /**
  108022. * Binds the material data.
  108023. * @param uniformBuffer defines the Uniform buffer to fill in.
  108024. * @param scene defines the scene the material belongs to.
  108025. * @param engine defines the engine the material belongs to.
  108026. * @param isFrozen defines wether the material is frozen or not.
  108027. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108028. */
  108029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108030. /**
  108031. * Unbinds the material from the mesh.
  108032. * @param activeEffect defines the effect that should be unbound from.
  108033. * @returns true if unbound, otherwise false
  108034. */
  108035. unbind(activeEffect: Effect): boolean;
  108036. /**
  108037. * Returns the texture used for refraction or null if none is used.
  108038. * @param scene defines the scene the material belongs to.
  108039. * @returns - Refraction texture if present. If no refraction texture and refraction
  108040. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108041. */
  108042. private _getRefractionTexture;
  108043. /**
  108044. * Returns true if alpha blending should be disabled.
  108045. */
  108046. readonly disableAlphaBlending: boolean;
  108047. /**
  108048. * Fills the list of render target textures.
  108049. * @param renderTargets the list of render targets to update
  108050. */
  108051. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108052. /**
  108053. * Checks to see if a texture is used in the material.
  108054. * @param texture - Base texture to use.
  108055. * @returns - Boolean specifying if a texture is used in the material.
  108056. */
  108057. hasTexture(texture: BaseTexture): boolean;
  108058. /**
  108059. * Gets a boolean indicating that current material needs to register RTT
  108060. * @returns true if this uses a render target otherwise false.
  108061. */
  108062. hasRenderTargetTextures(): boolean;
  108063. /**
  108064. * Returns an array of the actively used textures.
  108065. * @param activeTextures Array of BaseTextures
  108066. */
  108067. getActiveTextures(activeTextures: BaseTexture[]): void;
  108068. /**
  108069. * Returns the animatable textures.
  108070. * @param animatables Array of animatable textures.
  108071. */
  108072. getAnimatables(animatables: IAnimatable[]): void;
  108073. /**
  108074. * Disposes the resources of the material.
  108075. * @param forceDisposeTextures - Forces the disposal of all textures.
  108076. */
  108077. dispose(forceDisposeTextures?: boolean): void;
  108078. /**
  108079. * Get the current class name of the texture useful for serialization or dynamic coding.
  108080. * @returns "PBRSubSurfaceConfiguration"
  108081. */
  108082. getClassName(): string;
  108083. /**
  108084. * Add fallbacks to the effect fallbacks list.
  108085. * @param defines defines the Base texture to use.
  108086. * @param fallbacks defines the current fallback list.
  108087. * @param currentRank defines the current fallback rank.
  108088. * @returns the new fallback rank.
  108089. */
  108090. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108091. /**
  108092. * Add the required uniforms to the current list.
  108093. * @param uniforms defines the current uniform list.
  108094. */
  108095. static AddUniforms(uniforms: string[]): void;
  108096. /**
  108097. * Add the required samplers to the current list.
  108098. * @param samplers defines the current sampler list.
  108099. */
  108100. static AddSamplers(samplers: string[]): void;
  108101. /**
  108102. * Add the required uniforms to the current buffer.
  108103. * @param uniformBuffer defines the current uniform buffer.
  108104. */
  108105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108106. /**
  108107. * Makes a duplicate of the current configuration into another one.
  108108. * @param configuration define the config where to copy the info
  108109. */
  108110. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108111. /**
  108112. * Serializes this Sub Surface configuration.
  108113. * @returns - An object with the serialized config.
  108114. */
  108115. serialize(): any;
  108116. /**
  108117. * Parses a anisotropy Configuration from a serialized object.
  108118. * @param source - Serialized object.
  108119. * @param scene Defines the scene we are parsing for
  108120. * @param rootUrl Defines the rootUrl to load from
  108121. */
  108122. parse(source: any, scene: Scene, rootUrl: string): void;
  108123. }
  108124. }
  108125. declare module BABYLON {
  108126. /** @hidden */
  108127. export var pbrFragmentDeclaration: {
  108128. name: string;
  108129. shader: string;
  108130. };
  108131. }
  108132. declare module BABYLON {
  108133. /** @hidden */
  108134. export var pbrUboDeclaration: {
  108135. name: string;
  108136. shader: string;
  108137. };
  108138. }
  108139. declare module BABYLON {
  108140. /** @hidden */
  108141. export var pbrFragmentExtraDeclaration: {
  108142. name: string;
  108143. shader: string;
  108144. };
  108145. }
  108146. declare module BABYLON {
  108147. /** @hidden */
  108148. export var pbrFragmentSamplersDeclaration: {
  108149. name: string;
  108150. shader: string;
  108151. };
  108152. }
  108153. declare module BABYLON {
  108154. /** @hidden */
  108155. export var pbrHelperFunctions: {
  108156. name: string;
  108157. shader: string;
  108158. };
  108159. }
  108160. declare module BABYLON {
  108161. /** @hidden */
  108162. export var harmonicsFunctions: {
  108163. name: string;
  108164. shader: string;
  108165. };
  108166. }
  108167. declare module BABYLON {
  108168. /** @hidden */
  108169. export var pbrDirectLightingSetupFunctions: {
  108170. name: string;
  108171. shader: string;
  108172. };
  108173. }
  108174. declare module BABYLON {
  108175. /** @hidden */
  108176. export var pbrDirectLightingFalloffFunctions: {
  108177. name: string;
  108178. shader: string;
  108179. };
  108180. }
  108181. declare module BABYLON {
  108182. /** @hidden */
  108183. export var pbrBRDFFunctions: {
  108184. name: string;
  108185. shader: string;
  108186. };
  108187. }
  108188. declare module BABYLON {
  108189. /** @hidden */
  108190. export var pbrDirectLightingFunctions: {
  108191. name: string;
  108192. shader: string;
  108193. };
  108194. }
  108195. declare module BABYLON {
  108196. /** @hidden */
  108197. export var pbrIBLFunctions: {
  108198. name: string;
  108199. shader: string;
  108200. };
  108201. }
  108202. declare module BABYLON {
  108203. /** @hidden */
  108204. export var pbrDebug: {
  108205. name: string;
  108206. shader: string;
  108207. };
  108208. }
  108209. declare module BABYLON {
  108210. /** @hidden */
  108211. export var pbrPixelShader: {
  108212. name: string;
  108213. shader: string;
  108214. };
  108215. }
  108216. declare module BABYLON {
  108217. /** @hidden */
  108218. export var pbrVertexDeclaration: {
  108219. name: string;
  108220. shader: string;
  108221. };
  108222. }
  108223. declare module BABYLON {
  108224. /** @hidden */
  108225. export var pbrVertexShader: {
  108226. name: string;
  108227. shader: string;
  108228. };
  108229. }
  108230. declare module BABYLON {
  108231. /**
  108232. * Manages the defines for the PBR Material.
  108233. * @hidden
  108234. */
  108235. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108236. PBR: boolean;
  108237. MAINUV1: boolean;
  108238. MAINUV2: boolean;
  108239. UV1: boolean;
  108240. UV2: boolean;
  108241. ALBEDO: boolean;
  108242. ALBEDODIRECTUV: number;
  108243. VERTEXCOLOR: boolean;
  108244. AMBIENT: boolean;
  108245. AMBIENTDIRECTUV: number;
  108246. AMBIENTINGRAYSCALE: boolean;
  108247. OPACITY: boolean;
  108248. VERTEXALPHA: boolean;
  108249. OPACITYDIRECTUV: number;
  108250. OPACITYRGB: boolean;
  108251. ALPHATEST: boolean;
  108252. DEPTHPREPASS: boolean;
  108253. ALPHABLEND: boolean;
  108254. ALPHAFROMALBEDO: boolean;
  108255. ALPHATESTVALUE: string;
  108256. SPECULAROVERALPHA: boolean;
  108257. RADIANCEOVERALPHA: boolean;
  108258. ALPHAFRESNEL: boolean;
  108259. LINEARALPHAFRESNEL: boolean;
  108260. PREMULTIPLYALPHA: boolean;
  108261. EMISSIVE: boolean;
  108262. EMISSIVEDIRECTUV: number;
  108263. REFLECTIVITY: boolean;
  108264. REFLECTIVITYDIRECTUV: number;
  108265. SPECULARTERM: boolean;
  108266. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108267. MICROSURFACEAUTOMATIC: boolean;
  108268. LODBASEDMICROSFURACE: boolean;
  108269. MICROSURFACEMAP: boolean;
  108270. MICROSURFACEMAPDIRECTUV: number;
  108271. METALLICWORKFLOW: boolean;
  108272. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108273. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108274. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108275. AOSTOREINMETALMAPRED: boolean;
  108276. ENVIRONMENTBRDF: boolean;
  108277. ENVIRONMENTBRDF_RGBD: boolean;
  108278. NORMAL: boolean;
  108279. TANGENT: boolean;
  108280. BUMP: boolean;
  108281. BUMPDIRECTUV: number;
  108282. OBJECTSPACE_NORMALMAP: boolean;
  108283. PARALLAX: boolean;
  108284. PARALLAXOCCLUSION: boolean;
  108285. NORMALXYSCALE: boolean;
  108286. LIGHTMAP: boolean;
  108287. LIGHTMAPDIRECTUV: number;
  108288. USELIGHTMAPASSHADOWMAP: boolean;
  108289. GAMMALIGHTMAP: boolean;
  108290. REFLECTION: boolean;
  108291. REFLECTIONMAP_3D: boolean;
  108292. REFLECTIONMAP_SPHERICAL: boolean;
  108293. REFLECTIONMAP_PLANAR: boolean;
  108294. REFLECTIONMAP_CUBIC: boolean;
  108295. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108296. REFLECTIONMAP_PROJECTION: boolean;
  108297. REFLECTIONMAP_SKYBOX: boolean;
  108298. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108299. REFLECTIONMAP_EXPLICIT: boolean;
  108300. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108301. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108302. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108303. INVERTCUBICMAP: boolean;
  108304. USESPHERICALFROMREFLECTIONMAP: boolean;
  108305. USEIRRADIANCEMAP: boolean;
  108306. SPHERICAL_HARMONICS: boolean;
  108307. USESPHERICALINVERTEX: boolean;
  108308. REFLECTIONMAP_OPPOSITEZ: boolean;
  108309. LODINREFLECTIONALPHA: boolean;
  108310. GAMMAREFLECTION: boolean;
  108311. RGBDREFLECTION: boolean;
  108312. LINEARSPECULARREFLECTION: boolean;
  108313. RADIANCEOCCLUSION: boolean;
  108314. HORIZONOCCLUSION: boolean;
  108315. INSTANCES: boolean;
  108316. NUM_BONE_INFLUENCERS: number;
  108317. BonesPerMesh: number;
  108318. BONETEXTURE: boolean;
  108319. NONUNIFORMSCALING: boolean;
  108320. MORPHTARGETS: boolean;
  108321. MORPHTARGETS_NORMAL: boolean;
  108322. MORPHTARGETS_TANGENT: boolean;
  108323. MORPHTARGETS_UV: boolean;
  108324. NUM_MORPH_INFLUENCERS: number;
  108325. IMAGEPROCESSING: boolean;
  108326. VIGNETTE: boolean;
  108327. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108328. VIGNETTEBLENDMODEOPAQUE: boolean;
  108329. TONEMAPPING: boolean;
  108330. TONEMAPPING_ACES: boolean;
  108331. CONTRAST: boolean;
  108332. COLORCURVES: boolean;
  108333. COLORGRADING: boolean;
  108334. COLORGRADING3D: boolean;
  108335. SAMPLER3DGREENDEPTH: boolean;
  108336. SAMPLER3DBGRMAP: boolean;
  108337. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108338. EXPOSURE: boolean;
  108339. MULTIVIEW: boolean;
  108340. USEPHYSICALLIGHTFALLOFF: boolean;
  108341. USEGLTFLIGHTFALLOFF: boolean;
  108342. TWOSIDEDLIGHTING: boolean;
  108343. SHADOWFLOAT: boolean;
  108344. CLIPPLANE: boolean;
  108345. CLIPPLANE2: boolean;
  108346. CLIPPLANE3: boolean;
  108347. CLIPPLANE4: boolean;
  108348. POINTSIZE: boolean;
  108349. FOG: boolean;
  108350. LOGARITHMICDEPTH: boolean;
  108351. FORCENORMALFORWARD: boolean;
  108352. SPECULARAA: boolean;
  108353. CLEARCOAT: boolean;
  108354. CLEARCOAT_DEFAULTIOR: boolean;
  108355. CLEARCOAT_TEXTURE: boolean;
  108356. CLEARCOAT_TEXTUREDIRECTUV: number;
  108357. CLEARCOAT_BUMP: boolean;
  108358. CLEARCOAT_BUMPDIRECTUV: number;
  108359. CLEARCOAT_TINT: boolean;
  108360. CLEARCOAT_TINT_TEXTURE: boolean;
  108361. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108362. ANISOTROPIC: boolean;
  108363. ANISOTROPIC_TEXTURE: boolean;
  108364. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108365. BRDF_V_HEIGHT_CORRELATED: boolean;
  108366. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108367. SHEEN: boolean;
  108368. SHEEN_TEXTURE: boolean;
  108369. SHEEN_TEXTUREDIRECTUV: number;
  108370. SHEEN_LINKWITHALBEDO: boolean;
  108371. SUBSURFACE: boolean;
  108372. SS_REFRACTION: boolean;
  108373. SS_TRANSLUCENCY: boolean;
  108374. SS_SCATERRING: boolean;
  108375. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108376. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108377. SS_REFRACTIONMAP_3D: boolean;
  108378. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108379. SS_LODINREFRACTIONALPHA: boolean;
  108380. SS_GAMMAREFRACTION: boolean;
  108381. SS_RGBDREFRACTION: boolean;
  108382. SS_LINEARSPECULARREFRACTION: boolean;
  108383. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108384. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108385. UNLIT: boolean;
  108386. DEBUGMODE: number;
  108387. /**
  108388. * Initializes the PBR Material defines.
  108389. */
  108390. constructor();
  108391. /**
  108392. * Resets the PBR Material defines.
  108393. */
  108394. reset(): void;
  108395. }
  108396. /**
  108397. * The Physically based material base class of BJS.
  108398. *
  108399. * This offers the main features of a standard PBR material.
  108400. * For more information, please refer to the documentation :
  108401. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108402. */
  108403. export abstract class PBRBaseMaterial extends PushMaterial {
  108404. /**
  108405. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108406. */
  108407. static readonly PBRMATERIAL_OPAQUE: number;
  108408. /**
  108409. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108410. */
  108411. static readonly PBRMATERIAL_ALPHATEST: number;
  108412. /**
  108413. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108414. */
  108415. static readonly PBRMATERIAL_ALPHABLEND: number;
  108416. /**
  108417. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108418. * They are also discarded below the alpha cutoff threshold to improve performances.
  108419. */
  108420. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108421. /**
  108422. * Defines the default value of how much AO map is occluding the analytical lights
  108423. * (point spot...).
  108424. */
  108425. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108426. /**
  108427. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108428. */
  108429. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108430. /**
  108431. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108432. * to enhance interoperability with other engines.
  108433. */
  108434. static readonly LIGHTFALLOFF_GLTF: number;
  108435. /**
  108436. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108437. * to enhance interoperability with other materials.
  108438. */
  108439. static readonly LIGHTFALLOFF_STANDARD: number;
  108440. /**
  108441. * Intensity of the direct lights e.g. the four lights available in your scene.
  108442. * This impacts both the direct diffuse and specular highlights.
  108443. */
  108444. protected _directIntensity: number;
  108445. /**
  108446. * Intensity of the emissive part of the material.
  108447. * This helps controlling the emissive effect without modifying the emissive color.
  108448. */
  108449. protected _emissiveIntensity: number;
  108450. /**
  108451. * Intensity of the environment e.g. how much the environment will light the object
  108452. * either through harmonics for rough material or through the refelction for shiny ones.
  108453. */
  108454. protected _environmentIntensity: number;
  108455. /**
  108456. * This is a special control allowing the reduction of the specular highlights coming from the
  108457. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108458. */
  108459. protected _specularIntensity: number;
  108460. /**
  108461. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108462. */
  108463. private _lightingInfos;
  108464. /**
  108465. * Debug Control allowing disabling the bump map on this material.
  108466. */
  108467. protected _disableBumpMap: boolean;
  108468. /**
  108469. * AKA Diffuse Texture in standard nomenclature.
  108470. */
  108471. protected _albedoTexture: Nullable<BaseTexture>;
  108472. /**
  108473. * AKA Occlusion Texture in other nomenclature.
  108474. */
  108475. protected _ambientTexture: Nullable<BaseTexture>;
  108476. /**
  108477. * AKA Occlusion Texture Intensity in other nomenclature.
  108478. */
  108479. protected _ambientTextureStrength: number;
  108480. /**
  108481. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108482. * 1 means it completely occludes it
  108483. * 0 mean it has no impact
  108484. */
  108485. protected _ambientTextureImpactOnAnalyticalLights: number;
  108486. /**
  108487. * Stores the alpha values in a texture.
  108488. */
  108489. protected _opacityTexture: Nullable<BaseTexture>;
  108490. /**
  108491. * Stores the reflection values in a texture.
  108492. */
  108493. protected _reflectionTexture: Nullable<BaseTexture>;
  108494. /**
  108495. * Stores the emissive values in a texture.
  108496. */
  108497. protected _emissiveTexture: Nullable<BaseTexture>;
  108498. /**
  108499. * AKA Specular texture in other nomenclature.
  108500. */
  108501. protected _reflectivityTexture: Nullable<BaseTexture>;
  108502. /**
  108503. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108504. */
  108505. protected _metallicTexture: Nullable<BaseTexture>;
  108506. /**
  108507. * Specifies the metallic scalar of the metallic/roughness workflow.
  108508. * Can also be used to scale the metalness values of the metallic texture.
  108509. */
  108510. protected _metallic: Nullable<number>;
  108511. /**
  108512. * Specifies the roughness scalar of the metallic/roughness workflow.
  108513. * Can also be used to scale the roughness values of the metallic texture.
  108514. */
  108515. protected _roughness: Nullable<number>;
  108516. /**
  108517. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108518. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108519. */
  108520. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108521. /**
  108522. * Stores surface normal data used to displace a mesh in a texture.
  108523. */
  108524. protected _bumpTexture: Nullable<BaseTexture>;
  108525. /**
  108526. * Stores the pre-calculated light information of a mesh in a texture.
  108527. */
  108528. protected _lightmapTexture: Nullable<BaseTexture>;
  108529. /**
  108530. * The color of a material in ambient lighting.
  108531. */
  108532. protected _ambientColor: Color3;
  108533. /**
  108534. * AKA Diffuse Color in other nomenclature.
  108535. */
  108536. protected _albedoColor: Color3;
  108537. /**
  108538. * AKA Specular Color in other nomenclature.
  108539. */
  108540. protected _reflectivityColor: Color3;
  108541. /**
  108542. * The color applied when light is reflected from a material.
  108543. */
  108544. protected _reflectionColor: Color3;
  108545. /**
  108546. * The color applied when light is emitted from a material.
  108547. */
  108548. protected _emissiveColor: Color3;
  108549. /**
  108550. * AKA Glossiness in other nomenclature.
  108551. */
  108552. protected _microSurface: number;
  108553. /**
  108554. * Specifies that the material will use the light map as a show map.
  108555. */
  108556. protected _useLightmapAsShadowmap: boolean;
  108557. /**
  108558. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108559. * makes the reflect vector face the model (under horizon).
  108560. */
  108561. protected _useHorizonOcclusion: boolean;
  108562. /**
  108563. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108564. * too much the area relying on ambient texture to define their ambient occlusion.
  108565. */
  108566. protected _useRadianceOcclusion: boolean;
  108567. /**
  108568. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108569. */
  108570. protected _useAlphaFromAlbedoTexture: boolean;
  108571. /**
  108572. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108573. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108574. */
  108575. protected _useSpecularOverAlpha: boolean;
  108576. /**
  108577. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108578. */
  108579. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108580. /**
  108581. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108582. */
  108583. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108584. /**
  108585. * Specifies if the metallic texture contains the roughness information in its green channel.
  108586. */
  108587. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108588. /**
  108589. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108590. */
  108591. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108592. /**
  108593. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108594. */
  108595. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108596. /**
  108597. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108598. */
  108599. protected _useAmbientInGrayScale: boolean;
  108600. /**
  108601. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108602. * The material will try to infer what glossiness each pixel should be.
  108603. */
  108604. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108605. /**
  108606. * Defines the falloff type used in this material.
  108607. * It by default is Physical.
  108608. */
  108609. protected _lightFalloff: number;
  108610. /**
  108611. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108612. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108613. */
  108614. protected _useRadianceOverAlpha: boolean;
  108615. /**
  108616. * Allows using an object space normal map (instead of tangent space).
  108617. */
  108618. protected _useObjectSpaceNormalMap: boolean;
  108619. /**
  108620. * Allows using the bump map in parallax mode.
  108621. */
  108622. protected _useParallax: boolean;
  108623. /**
  108624. * Allows using the bump map in parallax occlusion mode.
  108625. */
  108626. protected _useParallaxOcclusion: boolean;
  108627. /**
  108628. * Controls the scale bias of the parallax mode.
  108629. */
  108630. protected _parallaxScaleBias: number;
  108631. /**
  108632. * If sets to true, disables all the lights affecting the material.
  108633. */
  108634. protected _disableLighting: boolean;
  108635. /**
  108636. * Number of Simultaneous lights allowed on the material.
  108637. */
  108638. protected _maxSimultaneousLights: number;
  108639. /**
  108640. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108641. */
  108642. protected _invertNormalMapX: boolean;
  108643. /**
  108644. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108645. */
  108646. protected _invertNormalMapY: boolean;
  108647. /**
  108648. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108649. */
  108650. protected _twoSidedLighting: boolean;
  108651. /**
  108652. * Defines the alpha limits in alpha test mode.
  108653. */
  108654. protected _alphaCutOff: number;
  108655. /**
  108656. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108657. */
  108658. protected _forceAlphaTest: boolean;
  108659. /**
  108660. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108661. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108662. */
  108663. protected _useAlphaFresnel: boolean;
  108664. /**
  108665. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108666. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108667. */
  108668. protected _useLinearAlphaFresnel: boolean;
  108669. /**
  108670. * The transparency mode of the material.
  108671. */
  108672. protected _transparencyMode: Nullable<number>;
  108673. /**
  108674. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108675. * from cos thetav and roughness:
  108676. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108677. */
  108678. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108679. /**
  108680. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108681. */
  108682. protected _forceIrradianceInFragment: boolean;
  108683. /**
  108684. * Force normal to face away from face.
  108685. */
  108686. protected _forceNormalForward: boolean;
  108687. /**
  108688. * Enables specular anti aliasing in the PBR shader.
  108689. * It will both interacts on the Geometry for analytical and IBL lighting.
  108690. * It also prefilter the roughness map based on the bump values.
  108691. */
  108692. protected _enableSpecularAntiAliasing: boolean;
  108693. /**
  108694. * Default configuration related to image processing available in the PBR Material.
  108695. */
  108696. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108697. /**
  108698. * Keep track of the image processing observer to allow dispose and replace.
  108699. */
  108700. private _imageProcessingObserver;
  108701. /**
  108702. * Attaches a new image processing configuration to the PBR Material.
  108703. * @param configuration
  108704. */
  108705. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108706. /**
  108707. * Stores the available render targets.
  108708. */
  108709. private _renderTargets;
  108710. /**
  108711. * Sets the global ambient color for the material used in lighting calculations.
  108712. */
  108713. private _globalAmbientColor;
  108714. /**
  108715. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108716. */
  108717. private _useLogarithmicDepth;
  108718. /**
  108719. * If set to true, no lighting calculations will be applied.
  108720. */
  108721. private _unlit;
  108722. private _debugMode;
  108723. /**
  108724. * @hidden
  108725. * This is reserved for the inspector.
  108726. * Defines the material debug mode.
  108727. * It helps seeing only some components of the material while troubleshooting.
  108728. */
  108729. debugMode: number;
  108730. /**
  108731. * @hidden
  108732. * This is reserved for the inspector.
  108733. * Specify from where on screen the debug mode should start.
  108734. * The value goes from -1 (full screen) to 1 (not visible)
  108735. * It helps with side by side comparison against the final render
  108736. * This defaults to -1
  108737. */
  108738. private debugLimit;
  108739. /**
  108740. * @hidden
  108741. * This is reserved for the inspector.
  108742. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108743. * You can use the factor to better multiply the final value.
  108744. */
  108745. private debugFactor;
  108746. /**
  108747. * Defines the clear coat layer parameters for the material.
  108748. */
  108749. readonly clearCoat: PBRClearCoatConfiguration;
  108750. /**
  108751. * Defines the anisotropic parameters for the material.
  108752. */
  108753. readonly anisotropy: PBRAnisotropicConfiguration;
  108754. /**
  108755. * Defines the BRDF parameters for the material.
  108756. */
  108757. readonly brdf: PBRBRDFConfiguration;
  108758. /**
  108759. * Defines the Sheen parameters for the material.
  108760. */
  108761. readonly sheen: PBRSheenConfiguration;
  108762. /**
  108763. * Defines the SubSurface parameters for the material.
  108764. */
  108765. readonly subSurface: PBRSubSurfaceConfiguration;
  108766. /**
  108767. * Custom callback helping to override the default shader used in the material.
  108768. */
  108769. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108770. /**
  108771. * Instantiates a new PBRMaterial instance.
  108772. *
  108773. * @param name The material name
  108774. * @param scene The scene the material will be use in.
  108775. */
  108776. constructor(name: string, scene: Scene);
  108777. /**
  108778. * Gets a boolean indicating that current material needs to register RTT
  108779. */
  108780. readonly hasRenderTargetTextures: boolean;
  108781. /**
  108782. * Gets the name of the material class.
  108783. */
  108784. getClassName(): string;
  108785. /**
  108786. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108787. */
  108788. /**
  108789. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108790. */
  108791. useLogarithmicDepth: boolean;
  108792. /**
  108793. * Gets the current transparency mode.
  108794. */
  108795. /**
  108796. * Sets the transparency mode of the material.
  108797. *
  108798. * | Value | Type | Description |
  108799. * | ----- | ----------------------------------- | ----------- |
  108800. * | 0 | OPAQUE | |
  108801. * | 1 | ALPHATEST | |
  108802. * | 2 | ALPHABLEND | |
  108803. * | 3 | ALPHATESTANDBLEND | |
  108804. *
  108805. */
  108806. transparencyMode: Nullable<number>;
  108807. /**
  108808. * Returns true if alpha blending should be disabled.
  108809. */
  108810. private readonly _disableAlphaBlending;
  108811. /**
  108812. * Specifies whether or not this material should be rendered in alpha blend mode.
  108813. */
  108814. needAlphaBlending(): boolean;
  108815. /**
  108816. * Specifies if the mesh will require alpha blending.
  108817. * @param mesh - BJS mesh.
  108818. */
  108819. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108820. /**
  108821. * Specifies whether or not this material should be rendered in alpha test mode.
  108822. */
  108823. needAlphaTesting(): boolean;
  108824. /**
  108825. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108826. */
  108827. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108828. /**
  108829. * Gets the texture used for the alpha test.
  108830. */
  108831. getAlphaTestTexture(): Nullable<BaseTexture>;
  108832. /**
  108833. * Specifies that the submesh is ready to be used.
  108834. * @param mesh - BJS mesh.
  108835. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108836. * @param useInstances - Specifies that instances should be used.
  108837. * @returns - boolean indicating that the submesh is ready or not.
  108838. */
  108839. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108840. /**
  108841. * Specifies if the material uses metallic roughness workflow.
  108842. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108843. */
  108844. isMetallicWorkflow(): boolean;
  108845. private _prepareEffect;
  108846. private _prepareDefines;
  108847. /**
  108848. * Force shader compilation
  108849. */
  108850. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108851. clipPlane: boolean;
  108852. }>): void;
  108853. /**
  108854. * Initializes the uniform buffer layout for the shader.
  108855. */
  108856. buildUniformLayout(): void;
  108857. /**
  108858. * Unbinds the material from the mesh
  108859. */
  108860. unbind(): void;
  108861. /**
  108862. * Binds the submesh data.
  108863. * @param world - The world matrix.
  108864. * @param mesh - The BJS mesh.
  108865. * @param subMesh - A submesh of the BJS mesh.
  108866. */
  108867. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108868. /**
  108869. * Returns the animatable textures.
  108870. * @returns - Array of animatable textures.
  108871. */
  108872. getAnimatables(): IAnimatable[];
  108873. /**
  108874. * Returns the texture used for reflections.
  108875. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108876. */
  108877. private _getReflectionTexture;
  108878. /**
  108879. * Returns an array of the actively used textures.
  108880. * @returns - Array of BaseTextures
  108881. */
  108882. getActiveTextures(): BaseTexture[];
  108883. /**
  108884. * Checks to see if a texture is used in the material.
  108885. * @param texture - Base texture to use.
  108886. * @returns - Boolean specifying if a texture is used in the material.
  108887. */
  108888. hasTexture(texture: BaseTexture): boolean;
  108889. /**
  108890. * Disposes the resources of the material.
  108891. * @param forceDisposeEffect - Forces the disposal of effects.
  108892. * @param forceDisposeTextures - Forces the disposal of all textures.
  108893. */
  108894. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108895. }
  108896. }
  108897. declare module BABYLON {
  108898. /**
  108899. * The Physically based material of BJS.
  108900. *
  108901. * This offers the main features of a standard PBR material.
  108902. * For more information, please refer to the documentation :
  108903. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108904. */
  108905. export class PBRMaterial extends PBRBaseMaterial {
  108906. /**
  108907. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108908. */
  108909. static readonly PBRMATERIAL_OPAQUE: number;
  108910. /**
  108911. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108912. */
  108913. static readonly PBRMATERIAL_ALPHATEST: number;
  108914. /**
  108915. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108916. */
  108917. static readonly PBRMATERIAL_ALPHABLEND: number;
  108918. /**
  108919. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108920. * They are also discarded below the alpha cutoff threshold to improve performances.
  108921. */
  108922. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108923. /**
  108924. * Defines the default value of how much AO map is occluding the analytical lights
  108925. * (point spot...).
  108926. */
  108927. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108928. /**
  108929. * Intensity of the direct lights e.g. the four lights available in your scene.
  108930. * This impacts both the direct diffuse and specular highlights.
  108931. */
  108932. directIntensity: number;
  108933. /**
  108934. * Intensity of the emissive part of the material.
  108935. * This helps controlling the emissive effect without modifying the emissive color.
  108936. */
  108937. emissiveIntensity: number;
  108938. /**
  108939. * Intensity of the environment e.g. how much the environment will light the object
  108940. * either through harmonics for rough material or through the refelction for shiny ones.
  108941. */
  108942. environmentIntensity: number;
  108943. /**
  108944. * This is a special control allowing the reduction of the specular highlights coming from the
  108945. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108946. */
  108947. specularIntensity: number;
  108948. /**
  108949. * Debug Control allowing disabling the bump map on this material.
  108950. */
  108951. disableBumpMap: boolean;
  108952. /**
  108953. * AKA Diffuse Texture in standard nomenclature.
  108954. */
  108955. albedoTexture: BaseTexture;
  108956. /**
  108957. * AKA Occlusion Texture in other nomenclature.
  108958. */
  108959. ambientTexture: BaseTexture;
  108960. /**
  108961. * AKA Occlusion Texture Intensity in other nomenclature.
  108962. */
  108963. ambientTextureStrength: number;
  108964. /**
  108965. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108966. * 1 means it completely occludes it
  108967. * 0 mean it has no impact
  108968. */
  108969. ambientTextureImpactOnAnalyticalLights: number;
  108970. /**
  108971. * Stores the alpha values in a texture.
  108972. */
  108973. opacityTexture: BaseTexture;
  108974. /**
  108975. * Stores the reflection values in a texture.
  108976. */
  108977. reflectionTexture: Nullable<BaseTexture>;
  108978. /**
  108979. * Stores the emissive values in a texture.
  108980. */
  108981. emissiveTexture: BaseTexture;
  108982. /**
  108983. * AKA Specular texture in other nomenclature.
  108984. */
  108985. reflectivityTexture: BaseTexture;
  108986. /**
  108987. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108988. */
  108989. metallicTexture: BaseTexture;
  108990. /**
  108991. * Specifies the metallic scalar of the metallic/roughness workflow.
  108992. * Can also be used to scale the metalness values of the metallic texture.
  108993. */
  108994. metallic: Nullable<number>;
  108995. /**
  108996. * Specifies the roughness scalar of the metallic/roughness workflow.
  108997. * Can also be used to scale the roughness values of the metallic texture.
  108998. */
  108999. roughness: Nullable<number>;
  109000. /**
  109001. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109002. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109003. */
  109004. microSurfaceTexture: BaseTexture;
  109005. /**
  109006. * Stores surface normal data used to displace a mesh in a texture.
  109007. */
  109008. bumpTexture: BaseTexture;
  109009. /**
  109010. * Stores the pre-calculated light information of a mesh in a texture.
  109011. */
  109012. lightmapTexture: BaseTexture;
  109013. /**
  109014. * Stores the refracted light information in a texture.
  109015. */
  109016. refractionTexture: Nullable<BaseTexture>;
  109017. /**
  109018. * The color of a material in ambient lighting.
  109019. */
  109020. ambientColor: Color3;
  109021. /**
  109022. * AKA Diffuse Color in other nomenclature.
  109023. */
  109024. albedoColor: Color3;
  109025. /**
  109026. * AKA Specular Color in other nomenclature.
  109027. */
  109028. reflectivityColor: Color3;
  109029. /**
  109030. * The color reflected from the material.
  109031. */
  109032. reflectionColor: Color3;
  109033. /**
  109034. * The color emitted from the material.
  109035. */
  109036. emissiveColor: Color3;
  109037. /**
  109038. * AKA Glossiness in other nomenclature.
  109039. */
  109040. microSurface: number;
  109041. /**
  109042. * source material index of refraction (IOR)' / 'destination material IOR.
  109043. */
  109044. indexOfRefraction: number;
  109045. /**
  109046. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109047. */
  109048. invertRefractionY: boolean;
  109049. /**
  109050. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109051. * Materials half opaque for instance using refraction could benefit from this control.
  109052. */
  109053. linkRefractionWithTransparency: boolean;
  109054. /**
  109055. * If true, the light map contains occlusion information instead of lighting info.
  109056. */
  109057. useLightmapAsShadowmap: boolean;
  109058. /**
  109059. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109060. */
  109061. useAlphaFromAlbedoTexture: boolean;
  109062. /**
  109063. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109064. */
  109065. forceAlphaTest: boolean;
  109066. /**
  109067. * Defines the alpha limits in alpha test mode.
  109068. */
  109069. alphaCutOff: number;
  109070. /**
  109071. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109072. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109073. */
  109074. useSpecularOverAlpha: boolean;
  109075. /**
  109076. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109077. */
  109078. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109079. /**
  109080. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109081. */
  109082. useRoughnessFromMetallicTextureAlpha: boolean;
  109083. /**
  109084. * Specifies if the metallic texture contains the roughness information in its green channel.
  109085. */
  109086. useRoughnessFromMetallicTextureGreen: boolean;
  109087. /**
  109088. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109089. */
  109090. useMetallnessFromMetallicTextureBlue: boolean;
  109091. /**
  109092. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109093. */
  109094. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109095. /**
  109096. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109097. */
  109098. useAmbientInGrayScale: boolean;
  109099. /**
  109100. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109101. * The material will try to infer what glossiness each pixel should be.
  109102. */
  109103. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109104. /**
  109105. * BJS is using an harcoded light falloff based on a manually sets up range.
  109106. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109107. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109108. */
  109109. /**
  109110. * BJS is using an harcoded light falloff based on a manually sets up range.
  109111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109113. */
  109114. usePhysicalLightFalloff: boolean;
  109115. /**
  109116. * In order to support the falloff compatibility with gltf, a special mode has been added
  109117. * to reproduce the gltf light falloff.
  109118. */
  109119. /**
  109120. * In order to support the falloff compatibility with gltf, a special mode has been added
  109121. * to reproduce the gltf light falloff.
  109122. */
  109123. useGLTFLightFalloff: boolean;
  109124. /**
  109125. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109126. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109127. */
  109128. useRadianceOverAlpha: boolean;
  109129. /**
  109130. * Allows using an object space normal map (instead of tangent space).
  109131. */
  109132. useObjectSpaceNormalMap: boolean;
  109133. /**
  109134. * Allows using the bump map in parallax mode.
  109135. */
  109136. useParallax: boolean;
  109137. /**
  109138. * Allows using the bump map in parallax occlusion mode.
  109139. */
  109140. useParallaxOcclusion: boolean;
  109141. /**
  109142. * Controls the scale bias of the parallax mode.
  109143. */
  109144. parallaxScaleBias: number;
  109145. /**
  109146. * If sets to true, disables all the lights affecting the material.
  109147. */
  109148. disableLighting: boolean;
  109149. /**
  109150. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109151. */
  109152. forceIrradianceInFragment: boolean;
  109153. /**
  109154. * Number of Simultaneous lights allowed on the material.
  109155. */
  109156. maxSimultaneousLights: number;
  109157. /**
  109158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109159. */
  109160. invertNormalMapX: boolean;
  109161. /**
  109162. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109163. */
  109164. invertNormalMapY: boolean;
  109165. /**
  109166. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109167. */
  109168. twoSidedLighting: boolean;
  109169. /**
  109170. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109171. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109172. */
  109173. useAlphaFresnel: boolean;
  109174. /**
  109175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109176. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109177. */
  109178. useLinearAlphaFresnel: boolean;
  109179. /**
  109180. * Let user defines the brdf lookup texture used for IBL.
  109181. * A default 8bit version is embedded but you could point at :
  109182. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109183. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109184. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109185. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109186. */
  109187. environmentBRDFTexture: Nullable<BaseTexture>;
  109188. /**
  109189. * Force normal to face away from face.
  109190. */
  109191. forceNormalForward: boolean;
  109192. /**
  109193. * Enables specular anti aliasing in the PBR shader.
  109194. * It will both interacts on the Geometry for analytical and IBL lighting.
  109195. * It also prefilter the roughness map based on the bump values.
  109196. */
  109197. enableSpecularAntiAliasing: boolean;
  109198. /**
  109199. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109200. * makes the reflect vector face the model (under horizon).
  109201. */
  109202. useHorizonOcclusion: boolean;
  109203. /**
  109204. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109205. * too much the area relying on ambient texture to define their ambient occlusion.
  109206. */
  109207. useRadianceOcclusion: boolean;
  109208. /**
  109209. * If set to true, no lighting calculations will be applied.
  109210. */
  109211. unlit: boolean;
  109212. /**
  109213. * Gets the image processing configuration used either in this material.
  109214. */
  109215. /**
  109216. * Sets the Default image processing configuration used either in the this material.
  109217. *
  109218. * If sets to null, the scene one is in use.
  109219. */
  109220. imageProcessingConfiguration: ImageProcessingConfiguration;
  109221. /**
  109222. * Gets wether the color curves effect is enabled.
  109223. */
  109224. /**
  109225. * Sets wether the color curves effect is enabled.
  109226. */
  109227. cameraColorCurvesEnabled: boolean;
  109228. /**
  109229. * Gets wether the color grading effect is enabled.
  109230. */
  109231. /**
  109232. * Gets wether the color grading effect is enabled.
  109233. */
  109234. cameraColorGradingEnabled: boolean;
  109235. /**
  109236. * Gets wether tonemapping is enabled or not.
  109237. */
  109238. /**
  109239. * Sets wether tonemapping is enabled or not
  109240. */
  109241. cameraToneMappingEnabled: boolean;
  109242. /**
  109243. * The camera exposure used on this material.
  109244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109245. * This corresponds to a photographic exposure.
  109246. */
  109247. /**
  109248. * The camera exposure used on this material.
  109249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109250. * This corresponds to a photographic exposure.
  109251. */
  109252. cameraExposure: number;
  109253. /**
  109254. * Gets The camera contrast used on this material.
  109255. */
  109256. /**
  109257. * Sets The camera contrast used on this material.
  109258. */
  109259. cameraContrast: number;
  109260. /**
  109261. * Gets the Color Grading 2D Lookup Texture.
  109262. */
  109263. /**
  109264. * Sets the Color Grading 2D Lookup Texture.
  109265. */
  109266. cameraColorGradingTexture: Nullable<BaseTexture>;
  109267. /**
  109268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109270. * 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;
  109271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109272. */
  109273. /**
  109274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109276. * 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;
  109277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109278. */
  109279. cameraColorCurves: Nullable<ColorCurves>;
  109280. /**
  109281. * Instantiates a new PBRMaterial instance.
  109282. *
  109283. * @param name The material name
  109284. * @param scene The scene the material will be use in.
  109285. */
  109286. constructor(name: string, scene: Scene);
  109287. /**
  109288. * Returns the name of this material class.
  109289. */
  109290. getClassName(): string;
  109291. /**
  109292. * Makes a duplicate of the current material.
  109293. * @param name - name to use for the new material.
  109294. */
  109295. clone(name: string): PBRMaterial;
  109296. /**
  109297. * Serializes this PBR Material.
  109298. * @returns - An object with the serialized material.
  109299. */
  109300. serialize(): any;
  109301. /**
  109302. * Parses a PBR Material from a serialized object.
  109303. * @param source - Serialized object.
  109304. * @param scene - BJS scene instance.
  109305. * @param rootUrl - url for the scene object
  109306. * @returns - PBRMaterial
  109307. */
  109308. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109309. }
  109310. }
  109311. declare module BABYLON {
  109312. /**
  109313. * Direct draw surface info
  109314. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109315. */
  109316. export interface DDSInfo {
  109317. /**
  109318. * Width of the texture
  109319. */
  109320. width: number;
  109321. /**
  109322. * Width of the texture
  109323. */
  109324. height: number;
  109325. /**
  109326. * Number of Mipmaps for the texture
  109327. * @see https://en.wikipedia.org/wiki/Mipmap
  109328. */
  109329. mipmapCount: number;
  109330. /**
  109331. * If the textures format is a known fourCC format
  109332. * @see https://www.fourcc.org/
  109333. */
  109334. isFourCC: boolean;
  109335. /**
  109336. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109337. */
  109338. isRGB: boolean;
  109339. /**
  109340. * If the texture is a lumincance format
  109341. */
  109342. isLuminance: boolean;
  109343. /**
  109344. * If this is a cube texture
  109345. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109346. */
  109347. isCube: boolean;
  109348. /**
  109349. * If the texture is a compressed format eg. FOURCC_DXT1
  109350. */
  109351. isCompressed: boolean;
  109352. /**
  109353. * The dxgiFormat of the texture
  109354. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109355. */
  109356. dxgiFormat: number;
  109357. /**
  109358. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109359. */
  109360. textureType: number;
  109361. /**
  109362. * Sphericle polynomial created for the dds texture
  109363. */
  109364. sphericalPolynomial?: SphericalPolynomial;
  109365. }
  109366. /**
  109367. * Class used to provide DDS decompression tools
  109368. */
  109369. export class DDSTools {
  109370. /**
  109371. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109372. */
  109373. static StoreLODInAlphaChannel: boolean;
  109374. /**
  109375. * Gets DDS information from an array buffer
  109376. * @param arrayBuffer defines the array buffer to read data from
  109377. * @returns the DDS information
  109378. */
  109379. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109380. private static _FloatView;
  109381. private static _Int32View;
  109382. private static _ToHalfFloat;
  109383. private static _FromHalfFloat;
  109384. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109385. private static _GetHalfFloatRGBAArrayBuffer;
  109386. private static _GetFloatRGBAArrayBuffer;
  109387. private static _GetFloatAsUIntRGBAArrayBuffer;
  109388. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109389. private static _GetRGBAArrayBuffer;
  109390. private static _ExtractLongWordOrder;
  109391. private static _GetRGBArrayBuffer;
  109392. private static _GetLuminanceArrayBuffer;
  109393. /**
  109394. * Uploads DDS Levels to a Babylon Texture
  109395. * @hidden
  109396. */
  109397. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109398. }
  109399. interface Engine {
  109400. /**
  109401. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109402. * @param rootUrl defines the url where the file to load is located
  109403. * @param scene defines the current scene
  109404. * @param lodScale defines scale to apply to the mip map selection
  109405. * @param lodOffset defines offset to apply to the mip map selection
  109406. * @param onLoad defines an optional callback raised when the texture is loaded
  109407. * @param onError defines an optional callback raised if there is an issue to load the texture
  109408. * @param format defines the format of the data
  109409. * @param forcedExtension defines the extension to use to pick the right loader
  109410. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109411. * @returns the cube texture as an InternalTexture
  109412. */
  109413. 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;
  109414. }
  109415. }
  109416. declare module BABYLON {
  109417. /**
  109418. * Implementation of the DDS Texture Loader.
  109419. * @hidden
  109420. */
  109421. export class _DDSTextureLoader implements IInternalTextureLoader {
  109422. /**
  109423. * Defines wether the loader supports cascade loading the different faces.
  109424. */
  109425. readonly supportCascades: boolean;
  109426. /**
  109427. * This returns if the loader support the current file information.
  109428. * @param extension defines the file extension of the file being loaded
  109429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109430. * @param fallback defines the fallback internal texture if any
  109431. * @param isBase64 defines whether the texture is encoded as a base64
  109432. * @param isBuffer defines whether the texture data are stored as a buffer
  109433. * @returns true if the loader can load the specified file
  109434. */
  109435. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109436. /**
  109437. * Transform the url before loading if required.
  109438. * @param rootUrl the url of the texture
  109439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109440. * @returns the transformed texture
  109441. */
  109442. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109443. /**
  109444. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109445. * @param rootUrl the url of the texture
  109446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109447. * @returns the fallback texture
  109448. */
  109449. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109450. /**
  109451. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109452. * @param data contains the texture data
  109453. * @param texture defines the BabylonJS internal texture
  109454. * @param createPolynomials will be true if polynomials have been requested
  109455. * @param onLoad defines the callback to trigger once the texture is ready
  109456. * @param onError defines the callback to trigger in case of error
  109457. */
  109458. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109459. /**
  109460. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109461. * @param data contains the texture data
  109462. * @param texture defines the BabylonJS internal texture
  109463. * @param callback defines the method to call once ready to upload
  109464. */
  109465. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109466. }
  109467. }
  109468. declare module BABYLON {
  109469. /** @hidden */
  109470. export var rgbdEncodePixelShader: {
  109471. name: string;
  109472. shader: string;
  109473. };
  109474. }
  109475. declare module BABYLON {
  109476. /**
  109477. * Raw texture data and descriptor sufficient for WebGL texture upload
  109478. */
  109479. export interface EnvironmentTextureInfo {
  109480. /**
  109481. * Version of the environment map
  109482. */
  109483. version: number;
  109484. /**
  109485. * Width of image
  109486. */
  109487. width: number;
  109488. /**
  109489. * Irradiance information stored in the file.
  109490. */
  109491. irradiance: any;
  109492. /**
  109493. * Specular information stored in the file.
  109494. */
  109495. specular: any;
  109496. }
  109497. /**
  109498. * Sets of helpers addressing the serialization and deserialization of environment texture
  109499. * stored in a BabylonJS env file.
  109500. * Those files are usually stored as .env files.
  109501. */
  109502. export class EnvironmentTextureTools {
  109503. /**
  109504. * Magic number identifying the env file.
  109505. */
  109506. private static _MagicBytes;
  109507. /**
  109508. * Gets the environment info from an env file.
  109509. * @param data The array buffer containing the .env bytes.
  109510. * @returns the environment file info (the json header) if successfully parsed.
  109511. */
  109512. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109513. /**
  109514. * Creates an environment texture from a loaded cube texture.
  109515. * @param texture defines the cube texture to convert in env file
  109516. * @return a promise containing the environment data if succesfull.
  109517. */
  109518. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109519. /**
  109520. * Creates a JSON representation of the spherical data.
  109521. * @param texture defines the texture containing the polynomials
  109522. * @return the JSON representation of the spherical info
  109523. */
  109524. private static _CreateEnvTextureIrradiance;
  109525. /**
  109526. * Uploads the texture info contained in the env file to the GPU.
  109527. * @param texture defines the internal texture to upload to
  109528. * @param arrayBuffer defines the buffer cotaining the data to load
  109529. * @param info defines the texture info retrieved through the GetEnvInfo method
  109530. * @returns a promise
  109531. */
  109532. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109533. /**
  109534. * Uploads the levels of image data to the GPU.
  109535. * @param texture defines the internal texture to upload to
  109536. * @param imageData defines the array buffer views of image data [mipmap][face]
  109537. * @returns a promise
  109538. */
  109539. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109540. /**
  109541. * Uploads spherical polynomials information to the texture.
  109542. * @param texture defines the texture we are trying to upload the information to
  109543. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109544. */
  109545. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109546. /** @hidden */
  109547. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109548. }
  109549. }
  109550. declare module BABYLON {
  109551. /**
  109552. * Implementation of the ENV Texture Loader.
  109553. * @hidden
  109554. */
  109555. export class _ENVTextureLoader implements IInternalTextureLoader {
  109556. /**
  109557. * Defines wether the loader supports cascade loading the different faces.
  109558. */
  109559. readonly supportCascades: boolean;
  109560. /**
  109561. * This returns if the loader support the current file information.
  109562. * @param extension defines the file extension of the file being loaded
  109563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109564. * @param fallback defines the fallback internal texture if any
  109565. * @param isBase64 defines whether the texture is encoded as a base64
  109566. * @param isBuffer defines whether the texture data are stored as a buffer
  109567. * @returns true if the loader can load the specified file
  109568. */
  109569. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109570. /**
  109571. * Transform the url before loading if required.
  109572. * @param rootUrl the url of the texture
  109573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109574. * @returns the transformed texture
  109575. */
  109576. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109577. /**
  109578. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109579. * @param rootUrl the url of the texture
  109580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109581. * @returns the fallback texture
  109582. */
  109583. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109584. /**
  109585. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109586. * @param data contains the texture data
  109587. * @param texture defines the BabylonJS internal texture
  109588. * @param createPolynomials will be true if polynomials have been requested
  109589. * @param onLoad defines the callback to trigger once the texture is ready
  109590. * @param onError defines the callback to trigger in case of error
  109591. */
  109592. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109593. /**
  109594. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109595. * @param data contains the texture data
  109596. * @param texture defines the BabylonJS internal texture
  109597. * @param callback defines the method to call once ready to upload
  109598. */
  109599. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109600. }
  109601. }
  109602. declare module BABYLON {
  109603. /**
  109604. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109605. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109606. */
  109607. export class KhronosTextureContainer {
  109608. /** contents of the KTX container file */
  109609. arrayBuffer: any;
  109610. private static HEADER_LEN;
  109611. private static COMPRESSED_2D;
  109612. private static COMPRESSED_3D;
  109613. private static TEX_2D;
  109614. private static TEX_3D;
  109615. /**
  109616. * Gets the openGL type
  109617. */
  109618. glType: number;
  109619. /**
  109620. * Gets the openGL type size
  109621. */
  109622. glTypeSize: number;
  109623. /**
  109624. * Gets the openGL format
  109625. */
  109626. glFormat: number;
  109627. /**
  109628. * Gets the openGL internal format
  109629. */
  109630. glInternalFormat: number;
  109631. /**
  109632. * Gets the base internal format
  109633. */
  109634. glBaseInternalFormat: number;
  109635. /**
  109636. * Gets image width in pixel
  109637. */
  109638. pixelWidth: number;
  109639. /**
  109640. * Gets image height in pixel
  109641. */
  109642. pixelHeight: number;
  109643. /**
  109644. * Gets image depth in pixels
  109645. */
  109646. pixelDepth: number;
  109647. /**
  109648. * Gets the number of array elements
  109649. */
  109650. numberOfArrayElements: number;
  109651. /**
  109652. * Gets the number of faces
  109653. */
  109654. numberOfFaces: number;
  109655. /**
  109656. * Gets the number of mipmap levels
  109657. */
  109658. numberOfMipmapLevels: number;
  109659. /**
  109660. * Gets the bytes of key value data
  109661. */
  109662. bytesOfKeyValueData: number;
  109663. /**
  109664. * Gets the load type
  109665. */
  109666. loadType: number;
  109667. /**
  109668. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109669. */
  109670. isInvalid: boolean;
  109671. /**
  109672. * Creates a new KhronosTextureContainer
  109673. * @param arrayBuffer contents of the KTX container file
  109674. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109675. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109676. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109677. */
  109678. constructor(
  109679. /** contents of the KTX container file */
  109680. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109681. /**
  109682. * Uploads KTX content to a Babylon Texture.
  109683. * It is assumed that the texture has already been created & is currently bound
  109684. * @hidden
  109685. */
  109686. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109687. private _upload2DCompressedLevels;
  109688. }
  109689. }
  109690. declare module BABYLON {
  109691. /**
  109692. * Implementation of the KTX Texture Loader.
  109693. * @hidden
  109694. */
  109695. export class _KTXTextureLoader implements IInternalTextureLoader {
  109696. /**
  109697. * Defines wether the loader supports cascade loading the different faces.
  109698. */
  109699. readonly supportCascades: boolean;
  109700. /**
  109701. * This returns if the loader support the current file information.
  109702. * @param extension defines the file extension of the file being loaded
  109703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109704. * @param fallback defines the fallback internal texture if any
  109705. * @param isBase64 defines whether the texture is encoded as a base64
  109706. * @param isBuffer defines whether the texture data are stored as a buffer
  109707. * @returns true if the loader can load the specified file
  109708. */
  109709. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109710. /**
  109711. * Transform the url before loading if required.
  109712. * @param rootUrl the url of the texture
  109713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109714. * @returns the transformed texture
  109715. */
  109716. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109717. /**
  109718. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109719. * @param rootUrl the url of the texture
  109720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109721. * @returns the fallback texture
  109722. */
  109723. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109724. /**
  109725. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109726. * @param data contains the texture data
  109727. * @param texture defines the BabylonJS internal texture
  109728. * @param createPolynomials will be true if polynomials have been requested
  109729. * @param onLoad defines the callback to trigger once the texture is ready
  109730. * @param onError defines the callback to trigger in case of error
  109731. */
  109732. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109733. /**
  109734. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109735. * @param data contains the texture data
  109736. * @param texture defines the BabylonJS internal texture
  109737. * @param callback defines the method to call once ready to upload
  109738. */
  109739. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109740. }
  109741. }
  109742. declare module BABYLON {
  109743. /** @hidden */
  109744. export var _forceSceneHelpersToBundle: boolean;
  109745. interface Scene {
  109746. /**
  109747. * Creates a default light for the scene.
  109748. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109749. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109750. */
  109751. createDefaultLight(replace?: boolean): void;
  109752. /**
  109753. * Creates a default camera for the scene.
  109754. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109755. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109756. * @param replace has default false, when true replaces the active camera in the scene
  109757. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109758. */
  109759. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109760. /**
  109761. * Creates a default camera and a default light.
  109762. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109763. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109764. * @param replace has the default false, when true replaces the active camera/light in the scene
  109765. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109766. */
  109767. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109768. /**
  109769. * Creates a new sky box
  109770. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109771. * @param environmentTexture defines the texture to use as environment texture
  109772. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109773. * @param scale defines the overall scale of the skybox
  109774. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109775. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109776. * @returns a new mesh holding the sky box
  109777. */
  109778. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109779. /**
  109780. * Creates a new environment
  109781. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109782. * @param options defines the options you can use to configure the environment
  109783. * @returns the new EnvironmentHelper
  109784. */
  109785. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109786. /**
  109787. * Creates a new VREXperienceHelper
  109788. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109789. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109790. * @returns a new VREXperienceHelper
  109791. */
  109792. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109793. /**
  109794. * Creates a new XREXperienceHelper
  109795. * @see http://doc.babylonjs.com/how_to/webxr
  109796. * @returns a promise for a new XREXperienceHelper
  109797. */
  109798. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109799. }
  109800. }
  109801. declare module BABYLON {
  109802. /**
  109803. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109804. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109805. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109806. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109807. */
  109808. export class VideoDome extends TransformNode {
  109809. /**
  109810. * Define the video source as a Monoscopic panoramic 360 video.
  109811. */
  109812. static readonly MODE_MONOSCOPIC: number;
  109813. /**
  109814. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109815. */
  109816. static readonly MODE_TOPBOTTOM: number;
  109817. /**
  109818. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109819. */
  109820. static readonly MODE_SIDEBYSIDE: number;
  109821. private _useDirectMapping;
  109822. /**
  109823. * The video texture being displayed on the sphere
  109824. */
  109825. protected _videoTexture: VideoTexture;
  109826. /**
  109827. * Gets the video texture being displayed on the sphere
  109828. */
  109829. readonly videoTexture: VideoTexture;
  109830. /**
  109831. * The skybox material
  109832. */
  109833. protected _material: BackgroundMaterial;
  109834. /**
  109835. * The surface used for the skybox
  109836. */
  109837. protected _mesh: Mesh;
  109838. /**
  109839. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109840. * Also see the options.resolution property.
  109841. */
  109842. fovMultiplier: number;
  109843. private _videoMode;
  109844. /**
  109845. * Gets or set the current video mode for the video. It can be:
  109846. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109847. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109848. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109849. */
  109850. videoMode: number;
  109851. /**
  109852. * Oberserver used in Stereoscopic VR Mode.
  109853. */
  109854. private _onBeforeCameraRenderObserver;
  109855. /**
  109856. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109857. * @param name Element's name, child elements will append suffixes for their own names.
  109858. * @param urlsOrVideo defines the url(s) or the video element to use
  109859. * @param options An object containing optional or exposed sub element properties
  109860. */
  109861. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109862. resolution?: number;
  109863. clickToPlay?: boolean;
  109864. autoPlay?: boolean;
  109865. loop?: boolean;
  109866. size?: number;
  109867. poster?: string;
  109868. faceForward?: boolean;
  109869. useDirectMapping?: boolean;
  109870. }, scene: Scene);
  109871. private _changeVideoMode;
  109872. /**
  109873. * Releases resources associated with this node.
  109874. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109875. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109876. */
  109877. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109878. }
  109879. }
  109880. declare module BABYLON {
  109881. /**
  109882. * This class can be used to get instrumentation data from a Babylon engine
  109883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109884. */
  109885. export class EngineInstrumentation implements IDisposable {
  109886. /**
  109887. * Define the instrumented engine.
  109888. */
  109889. engine: Engine;
  109890. private _captureGPUFrameTime;
  109891. private _gpuFrameTimeToken;
  109892. private _gpuFrameTime;
  109893. private _captureShaderCompilationTime;
  109894. private _shaderCompilationTime;
  109895. private _onBeginFrameObserver;
  109896. private _onEndFrameObserver;
  109897. private _onBeforeShaderCompilationObserver;
  109898. private _onAfterShaderCompilationObserver;
  109899. /**
  109900. * Gets the perf counter used for GPU frame time
  109901. */
  109902. readonly gpuFrameTimeCounter: PerfCounter;
  109903. /**
  109904. * Gets the GPU frame time capture status
  109905. */
  109906. /**
  109907. * Enable or disable the GPU frame time capture
  109908. */
  109909. captureGPUFrameTime: boolean;
  109910. /**
  109911. * Gets the perf counter used for shader compilation time
  109912. */
  109913. readonly shaderCompilationTimeCounter: PerfCounter;
  109914. /**
  109915. * Gets the shader compilation time capture status
  109916. */
  109917. /**
  109918. * Enable or disable the shader compilation time capture
  109919. */
  109920. captureShaderCompilationTime: boolean;
  109921. /**
  109922. * Instantiates a new engine instrumentation.
  109923. * This class can be used to get instrumentation data from a Babylon engine
  109924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109925. * @param engine Defines the engine to instrument
  109926. */
  109927. constructor(
  109928. /**
  109929. * Define the instrumented engine.
  109930. */
  109931. engine: Engine);
  109932. /**
  109933. * Dispose and release associated resources.
  109934. */
  109935. dispose(): void;
  109936. }
  109937. }
  109938. declare module BABYLON {
  109939. /**
  109940. * This class can be used to get instrumentation data from a Babylon engine
  109941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109942. */
  109943. export class SceneInstrumentation implements IDisposable {
  109944. /**
  109945. * Defines the scene to instrument
  109946. */
  109947. scene: Scene;
  109948. private _captureActiveMeshesEvaluationTime;
  109949. private _activeMeshesEvaluationTime;
  109950. private _captureRenderTargetsRenderTime;
  109951. private _renderTargetsRenderTime;
  109952. private _captureFrameTime;
  109953. private _frameTime;
  109954. private _captureRenderTime;
  109955. private _renderTime;
  109956. private _captureInterFrameTime;
  109957. private _interFrameTime;
  109958. private _captureParticlesRenderTime;
  109959. private _particlesRenderTime;
  109960. private _captureSpritesRenderTime;
  109961. private _spritesRenderTime;
  109962. private _capturePhysicsTime;
  109963. private _physicsTime;
  109964. private _captureAnimationsTime;
  109965. private _animationsTime;
  109966. private _captureCameraRenderTime;
  109967. private _cameraRenderTime;
  109968. private _onBeforeActiveMeshesEvaluationObserver;
  109969. private _onAfterActiveMeshesEvaluationObserver;
  109970. private _onBeforeRenderTargetsRenderObserver;
  109971. private _onAfterRenderTargetsRenderObserver;
  109972. private _onAfterRenderObserver;
  109973. private _onBeforeDrawPhaseObserver;
  109974. private _onAfterDrawPhaseObserver;
  109975. private _onBeforeAnimationsObserver;
  109976. private _onBeforeParticlesRenderingObserver;
  109977. private _onAfterParticlesRenderingObserver;
  109978. private _onBeforeSpritesRenderingObserver;
  109979. private _onAfterSpritesRenderingObserver;
  109980. private _onBeforePhysicsObserver;
  109981. private _onAfterPhysicsObserver;
  109982. private _onAfterAnimationsObserver;
  109983. private _onBeforeCameraRenderObserver;
  109984. private _onAfterCameraRenderObserver;
  109985. /**
  109986. * Gets the perf counter used for active meshes evaluation time
  109987. */
  109988. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109989. /**
  109990. * Gets the active meshes evaluation time capture status
  109991. */
  109992. /**
  109993. * Enable or disable the active meshes evaluation time capture
  109994. */
  109995. captureActiveMeshesEvaluationTime: boolean;
  109996. /**
  109997. * Gets the perf counter used for render targets render time
  109998. */
  109999. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110000. /**
  110001. * Gets the render targets render time capture status
  110002. */
  110003. /**
  110004. * Enable or disable the render targets render time capture
  110005. */
  110006. captureRenderTargetsRenderTime: boolean;
  110007. /**
  110008. * Gets the perf counter used for particles render time
  110009. */
  110010. readonly particlesRenderTimeCounter: PerfCounter;
  110011. /**
  110012. * Gets the particles render time capture status
  110013. */
  110014. /**
  110015. * Enable or disable the particles render time capture
  110016. */
  110017. captureParticlesRenderTime: boolean;
  110018. /**
  110019. * Gets the perf counter used for sprites render time
  110020. */
  110021. readonly spritesRenderTimeCounter: PerfCounter;
  110022. /**
  110023. * Gets the sprites render time capture status
  110024. */
  110025. /**
  110026. * Enable or disable the sprites render time capture
  110027. */
  110028. captureSpritesRenderTime: boolean;
  110029. /**
  110030. * Gets the perf counter used for physics time
  110031. */
  110032. readonly physicsTimeCounter: PerfCounter;
  110033. /**
  110034. * Gets the physics time capture status
  110035. */
  110036. /**
  110037. * Enable or disable the physics time capture
  110038. */
  110039. capturePhysicsTime: boolean;
  110040. /**
  110041. * Gets the perf counter used for animations time
  110042. */
  110043. readonly animationsTimeCounter: PerfCounter;
  110044. /**
  110045. * Gets the animations time capture status
  110046. */
  110047. /**
  110048. * Enable or disable the animations time capture
  110049. */
  110050. captureAnimationsTime: boolean;
  110051. /**
  110052. * Gets the perf counter used for frame time capture
  110053. */
  110054. readonly frameTimeCounter: PerfCounter;
  110055. /**
  110056. * Gets the frame time capture status
  110057. */
  110058. /**
  110059. * Enable or disable the frame time capture
  110060. */
  110061. captureFrameTime: boolean;
  110062. /**
  110063. * Gets the perf counter used for inter-frames time capture
  110064. */
  110065. readonly interFrameTimeCounter: PerfCounter;
  110066. /**
  110067. * Gets the inter-frames time capture status
  110068. */
  110069. /**
  110070. * Enable or disable the inter-frames time capture
  110071. */
  110072. captureInterFrameTime: boolean;
  110073. /**
  110074. * Gets the perf counter used for render time capture
  110075. */
  110076. readonly renderTimeCounter: PerfCounter;
  110077. /**
  110078. * Gets the render time capture status
  110079. */
  110080. /**
  110081. * Enable or disable the render time capture
  110082. */
  110083. captureRenderTime: boolean;
  110084. /**
  110085. * Gets the perf counter used for camera render time capture
  110086. */
  110087. readonly cameraRenderTimeCounter: PerfCounter;
  110088. /**
  110089. * Gets the camera render time capture status
  110090. */
  110091. /**
  110092. * Enable or disable the camera render time capture
  110093. */
  110094. captureCameraRenderTime: boolean;
  110095. /**
  110096. * Gets the perf counter used for draw calls
  110097. */
  110098. readonly drawCallsCounter: PerfCounter;
  110099. /**
  110100. * Instantiates a new scene instrumentation.
  110101. * This class can be used to get instrumentation data from a Babylon engine
  110102. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110103. * @param scene Defines the scene to instrument
  110104. */
  110105. constructor(
  110106. /**
  110107. * Defines the scene to instrument
  110108. */
  110109. scene: Scene);
  110110. /**
  110111. * Dispose and release associated resources.
  110112. */
  110113. dispose(): void;
  110114. }
  110115. }
  110116. declare module BABYLON {
  110117. /** @hidden */
  110118. export var glowMapGenerationPixelShader: {
  110119. name: string;
  110120. shader: string;
  110121. };
  110122. }
  110123. declare module BABYLON {
  110124. /** @hidden */
  110125. export var glowMapGenerationVertexShader: {
  110126. name: string;
  110127. shader: string;
  110128. };
  110129. }
  110130. declare module BABYLON {
  110131. /**
  110132. * Effect layer options. This helps customizing the behaviour
  110133. * of the effect layer.
  110134. */
  110135. export interface IEffectLayerOptions {
  110136. /**
  110137. * Multiplication factor apply to the canvas size to compute the render target size
  110138. * used to generated the objects (the smaller the faster).
  110139. */
  110140. mainTextureRatio: number;
  110141. /**
  110142. * Enforces a fixed size texture to ensure effect stability across devices.
  110143. */
  110144. mainTextureFixedSize?: number;
  110145. /**
  110146. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110147. */
  110148. alphaBlendingMode: number;
  110149. /**
  110150. * The camera attached to the layer.
  110151. */
  110152. camera: Nullable<Camera>;
  110153. /**
  110154. * The rendering group to draw the layer in.
  110155. */
  110156. renderingGroupId: number;
  110157. }
  110158. /**
  110159. * The effect layer Helps adding post process effect blended with the main pass.
  110160. *
  110161. * This can be for instance use to generate glow or higlight effects on the scene.
  110162. *
  110163. * The effect layer class can not be used directly and is intented to inherited from to be
  110164. * customized per effects.
  110165. */
  110166. export abstract class EffectLayer {
  110167. private _vertexBuffers;
  110168. private _indexBuffer;
  110169. private _cachedDefines;
  110170. private _effectLayerMapGenerationEffect;
  110171. private _effectLayerOptions;
  110172. private _mergeEffect;
  110173. protected _scene: Scene;
  110174. protected _engine: Engine;
  110175. protected _maxSize: number;
  110176. protected _mainTextureDesiredSize: ISize;
  110177. protected _mainTexture: RenderTargetTexture;
  110178. protected _shouldRender: boolean;
  110179. protected _postProcesses: PostProcess[];
  110180. protected _textures: BaseTexture[];
  110181. protected _emissiveTextureAndColor: {
  110182. texture: Nullable<BaseTexture>;
  110183. color: Color4;
  110184. };
  110185. /**
  110186. * The name of the layer
  110187. */
  110188. name: string;
  110189. /**
  110190. * The clear color of the texture used to generate the glow map.
  110191. */
  110192. neutralColor: Color4;
  110193. /**
  110194. * Specifies wether the highlight layer is enabled or not.
  110195. */
  110196. isEnabled: boolean;
  110197. /**
  110198. * Gets the camera attached to the layer.
  110199. */
  110200. readonly camera: Nullable<Camera>;
  110201. /**
  110202. * Gets the rendering group id the layer should render in.
  110203. */
  110204. renderingGroupId: number;
  110205. /**
  110206. * An event triggered when the effect layer has been disposed.
  110207. */
  110208. onDisposeObservable: Observable<EffectLayer>;
  110209. /**
  110210. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110211. */
  110212. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110213. /**
  110214. * An event triggered when the generated texture is being merged in the scene.
  110215. */
  110216. onBeforeComposeObservable: Observable<EffectLayer>;
  110217. /**
  110218. * An event triggered when the generated texture has been merged in the scene.
  110219. */
  110220. onAfterComposeObservable: Observable<EffectLayer>;
  110221. /**
  110222. * An event triggered when the efffect layer changes its size.
  110223. */
  110224. onSizeChangedObservable: Observable<EffectLayer>;
  110225. /** @hidden */
  110226. static _SceneComponentInitialization: (scene: Scene) => void;
  110227. /**
  110228. * Instantiates a new effect Layer and references it in the scene.
  110229. * @param name The name of the layer
  110230. * @param scene The scene to use the layer in
  110231. */
  110232. constructor(
  110233. /** The Friendly of the effect in the scene */
  110234. name: string, scene: Scene);
  110235. /**
  110236. * Get the effect name of the layer.
  110237. * @return The effect name
  110238. */
  110239. abstract getEffectName(): string;
  110240. /**
  110241. * Checks for the readiness of the element composing the layer.
  110242. * @param subMesh the mesh to check for
  110243. * @param useInstances specify wether or not to use instances to render the mesh
  110244. * @return true if ready otherwise, false
  110245. */
  110246. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110247. /**
  110248. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110249. * @returns true if the effect requires stencil during the main canvas render pass.
  110250. */
  110251. abstract needStencil(): boolean;
  110252. /**
  110253. * Create the merge effect. This is the shader use to blit the information back
  110254. * to the main canvas at the end of the scene rendering.
  110255. * @returns The effect containing the shader used to merge the effect on the main canvas
  110256. */
  110257. protected abstract _createMergeEffect(): Effect;
  110258. /**
  110259. * Creates the render target textures and post processes used in the effect layer.
  110260. */
  110261. protected abstract _createTextureAndPostProcesses(): void;
  110262. /**
  110263. * Implementation specific of rendering the generating effect on the main canvas.
  110264. * @param effect The effect used to render through
  110265. */
  110266. protected abstract _internalRender(effect: Effect): void;
  110267. /**
  110268. * Sets the required values for both the emissive texture and and the main color.
  110269. */
  110270. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110271. /**
  110272. * Free any resources and references associated to a mesh.
  110273. * Internal use
  110274. * @param mesh The mesh to free.
  110275. */
  110276. abstract _disposeMesh(mesh: Mesh): void;
  110277. /**
  110278. * Serializes this layer (Glow or Highlight for example)
  110279. * @returns a serialized layer object
  110280. */
  110281. abstract serialize?(): any;
  110282. /**
  110283. * Initializes the effect layer with the required options.
  110284. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110285. */
  110286. protected _init(options: Partial<IEffectLayerOptions>): void;
  110287. /**
  110288. * Generates the index buffer of the full screen quad blending to the main canvas.
  110289. */
  110290. private _generateIndexBuffer;
  110291. /**
  110292. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110293. */
  110294. private _generateVertexBuffer;
  110295. /**
  110296. * Sets the main texture desired size which is the closest power of two
  110297. * of the engine canvas size.
  110298. */
  110299. private _setMainTextureSize;
  110300. /**
  110301. * Creates the main texture for the effect layer.
  110302. */
  110303. protected _createMainTexture(): void;
  110304. /**
  110305. * Adds specific effects defines.
  110306. * @param defines The defines to add specifics to.
  110307. */
  110308. protected _addCustomEffectDefines(defines: string[]): void;
  110309. /**
  110310. * Checks for the readiness of the element composing the layer.
  110311. * @param subMesh the mesh to check for
  110312. * @param useInstances specify wether or not to use instances to render the mesh
  110313. * @param emissiveTexture the associated emissive texture used to generate the glow
  110314. * @return true if ready otherwise, false
  110315. */
  110316. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110317. /**
  110318. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110319. */
  110320. render(): void;
  110321. /**
  110322. * Determine if a given mesh will be used in the current effect.
  110323. * @param mesh mesh to test
  110324. * @returns true if the mesh will be used
  110325. */
  110326. hasMesh(mesh: AbstractMesh): boolean;
  110327. /**
  110328. * Returns true if the layer contains information to display, otherwise false.
  110329. * @returns true if the glow layer should be rendered
  110330. */
  110331. shouldRender(): boolean;
  110332. /**
  110333. * Returns true if the mesh should render, otherwise false.
  110334. * @param mesh The mesh to render
  110335. * @returns true if it should render otherwise false
  110336. */
  110337. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110338. /**
  110339. * Returns true if the mesh can be rendered, otherwise false.
  110340. * @param mesh The mesh to render
  110341. * @param material The material used on the mesh
  110342. * @returns true if it can be rendered otherwise false
  110343. */
  110344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110345. /**
  110346. * Returns true if the mesh should render, otherwise false.
  110347. * @param mesh The mesh to render
  110348. * @returns true if it should render otherwise false
  110349. */
  110350. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110351. /**
  110352. * Renders the submesh passed in parameter to the generation map.
  110353. */
  110354. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110355. /**
  110356. * Rebuild the required buffers.
  110357. * @hidden Internal use only.
  110358. */
  110359. _rebuild(): void;
  110360. /**
  110361. * Dispose only the render target textures and post process.
  110362. */
  110363. private _disposeTextureAndPostProcesses;
  110364. /**
  110365. * Dispose the highlight layer and free resources.
  110366. */
  110367. dispose(): void;
  110368. /**
  110369. * Gets the class name of the effect layer
  110370. * @returns the string with the class name of the effect layer
  110371. */
  110372. getClassName(): string;
  110373. /**
  110374. * Creates an effect layer from parsed effect layer data
  110375. * @param parsedEffectLayer defines effect layer data
  110376. * @param scene defines the current scene
  110377. * @param rootUrl defines the root URL containing the effect layer information
  110378. * @returns a parsed effect Layer
  110379. */
  110380. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110381. }
  110382. }
  110383. declare module BABYLON {
  110384. interface AbstractScene {
  110385. /**
  110386. * The list of effect layers (highlights/glow) added to the scene
  110387. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110388. * @see http://doc.babylonjs.com/how_to/glow_layer
  110389. */
  110390. effectLayers: Array<EffectLayer>;
  110391. /**
  110392. * Removes the given effect layer from this scene.
  110393. * @param toRemove defines the effect layer to remove
  110394. * @returns the index of the removed effect layer
  110395. */
  110396. removeEffectLayer(toRemove: EffectLayer): number;
  110397. /**
  110398. * Adds the given effect layer to this scene
  110399. * @param newEffectLayer defines the effect layer to add
  110400. */
  110401. addEffectLayer(newEffectLayer: EffectLayer): void;
  110402. }
  110403. /**
  110404. * Defines the layer scene component responsible to manage any effect layers
  110405. * in a given scene.
  110406. */
  110407. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110408. /**
  110409. * The component name helpfull to identify the component in the list of scene components.
  110410. */
  110411. readonly name: string;
  110412. /**
  110413. * The scene the component belongs to.
  110414. */
  110415. scene: Scene;
  110416. private _engine;
  110417. private _renderEffects;
  110418. private _needStencil;
  110419. private _previousStencilState;
  110420. /**
  110421. * Creates a new instance of the component for the given scene
  110422. * @param scene Defines the scene to register the component in
  110423. */
  110424. constructor(scene: Scene);
  110425. /**
  110426. * Registers the component in a given scene
  110427. */
  110428. register(): void;
  110429. /**
  110430. * Rebuilds the elements related to this component in case of
  110431. * context lost for instance.
  110432. */
  110433. rebuild(): void;
  110434. /**
  110435. * Serializes the component data to the specified json object
  110436. * @param serializationObject The object to serialize to
  110437. */
  110438. serialize(serializationObject: any): void;
  110439. /**
  110440. * Adds all the elements from the container to the scene
  110441. * @param container the container holding the elements
  110442. */
  110443. addFromContainer(container: AbstractScene): void;
  110444. /**
  110445. * Removes all the elements in the container from the scene
  110446. * @param container contains the elements to remove
  110447. * @param dispose if the removed element should be disposed (default: false)
  110448. */
  110449. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110450. /**
  110451. * Disposes the component and the associated ressources.
  110452. */
  110453. dispose(): void;
  110454. private _isReadyForMesh;
  110455. private _renderMainTexture;
  110456. private _setStencil;
  110457. private _setStencilBack;
  110458. private _draw;
  110459. private _drawCamera;
  110460. private _drawRenderingGroup;
  110461. }
  110462. }
  110463. declare module BABYLON {
  110464. /** @hidden */
  110465. export var glowMapMergePixelShader: {
  110466. name: string;
  110467. shader: string;
  110468. };
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var glowMapMergeVertexShader: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. interface AbstractScene {
  110479. /**
  110480. * Return a the first highlight layer of the scene with a given name.
  110481. * @param name The name of the highlight layer to look for.
  110482. * @return The highlight layer if found otherwise null.
  110483. */
  110484. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110485. }
  110486. /**
  110487. * Glow layer options. This helps customizing the behaviour
  110488. * of the glow layer.
  110489. */
  110490. export interface IGlowLayerOptions {
  110491. /**
  110492. * Multiplication factor apply to the canvas size to compute the render target size
  110493. * used to generated the glowing objects (the smaller the faster).
  110494. */
  110495. mainTextureRatio: number;
  110496. /**
  110497. * Enforces a fixed size texture to ensure resize independant blur.
  110498. */
  110499. mainTextureFixedSize?: number;
  110500. /**
  110501. * How big is the kernel of the blur texture.
  110502. */
  110503. blurKernelSize: number;
  110504. /**
  110505. * The camera attached to the layer.
  110506. */
  110507. camera: Nullable<Camera>;
  110508. /**
  110509. * Enable MSAA by chosing the number of samples.
  110510. */
  110511. mainTextureSamples?: number;
  110512. /**
  110513. * The rendering group to draw the layer in.
  110514. */
  110515. renderingGroupId: number;
  110516. }
  110517. /**
  110518. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110519. *
  110520. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110521. * glowy meshes to your scene.
  110522. *
  110523. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110524. */
  110525. export class GlowLayer extends EffectLayer {
  110526. /**
  110527. * Effect Name of the layer.
  110528. */
  110529. static readonly EffectName: string;
  110530. /**
  110531. * The default blur kernel size used for the glow.
  110532. */
  110533. static DefaultBlurKernelSize: number;
  110534. /**
  110535. * The default texture size ratio used for the glow.
  110536. */
  110537. static DefaultTextureRatio: number;
  110538. /**
  110539. * Sets the kernel size of the blur.
  110540. */
  110541. /**
  110542. * Gets the kernel size of the blur.
  110543. */
  110544. blurKernelSize: number;
  110545. /**
  110546. * Sets the glow intensity.
  110547. */
  110548. /**
  110549. * Gets the glow intensity.
  110550. */
  110551. intensity: number;
  110552. private _options;
  110553. private _intensity;
  110554. private _horizontalBlurPostprocess1;
  110555. private _verticalBlurPostprocess1;
  110556. private _horizontalBlurPostprocess2;
  110557. private _verticalBlurPostprocess2;
  110558. private _blurTexture1;
  110559. private _blurTexture2;
  110560. private _postProcesses1;
  110561. private _postProcesses2;
  110562. private _includedOnlyMeshes;
  110563. private _excludedMeshes;
  110564. /**
  110565. * Callback used to let the user override the color selection on a per mesh basis
  110566. */
  110567. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110568. /**
  110569. * Callback used to let the user override the texture selection on a per mesh basis
  110570. */
  110571. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110572. /**
  110573. * Instantiates a new glow Layer and references it to the scene.
  110574. * @param name The name of the layer
  110575. * @param scene The scene to use the layer in
  110576. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110577. */
  110578. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110579. /**
  110580. * Get the effect name of the layer.
  110581. * @return The effect name
  110582. */
  110583. getEffectName(): string;
  110584. /**
  110585. * Create the merge effect. This is the shader use to blit the information back
  110586. * to the main canvas at the end of the scene rendering.
  110587. */
  110588. protected _createMergeEffect(): Effect;
  110589. /**
  110590. * Creates the render target textures and post processes used in the glow layer.
  110591. */
  110592. protected _createTextureAndPostProcesses(): void;
  110593. /**
  110594. * Checks for the readiness of the element composing the layer.
  110595. * @param subMesh the mesh to check for
  110596. * @param useInstances specify wether or not to use instances to render the mesh
  110597. * @param emissiveTexture the associated emissive texture used to generate the glow
  110598. * @return true if ready otherwise, false
  110599. */
  110600. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110601. /**
  110602. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110603. */
  110604. needStencil(): boolean;
  110605. /**
  110606. * Returns true if the mesh can be rendered, otherwise false.
  110607. * @param mesh The mesh to render
  110608. * @param material The material used on the mesh
  110609. * @returns true if it can be rendered otherwise false
  110610. */
  110611. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110612. /**
  110613. * Implementation specific of rendering the generating effect on the main canvas.
  110614. * @param effect The effect used to render through
  110615. */
  110616. protected _internalRender(effect: Effect): void;
  110617. /**
  110618. * Sets the required values for both the emissive texture and and the main color.
  110619. */
  110620. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110621. /**
  110622. * Returns true if the mesh should render, otherwise false.
  110623. * @param mesh The mesh to render
  110624. * @returns true if it should render otherwise false
  110625. */
  110626. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110627. /**
  110628. * Adds specific effects defines.
  110629. * @param defines The defines to add specifics to.
  110630. */
  110631. protected _addCustomEffectDefines(defines: string[]): void;
  110632. /**
  110633. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110634. * @param mesh The mesh to exclude from the glow layer
  110635. */
  110636. addExcludedMesh(mesh: Mesh): void;
  110637. /**
  110638. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110639. * @param mesh The mesh to remove
  110640. */
  110641. removeExcludedMesh(mesh: Mesh): void;
  110642. /**
  110643. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110644. * @param mesh The mesh to include in the glow layer
  110645. */
  110646. addIncludedOnlyMesh(mesh: Mesh): void;
  110647. /**
  110648. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110649. * @param mesh The mesh to remove
  110650. */
  110651. removeIncludedOnlyMesh(mesh: Mesh): void;
  110652. /**
  110653. * Determine if a given mesh will be used in the glow layer
  110654. * @param mesh The mesh to test
  110655. * @returns true if the mesh will be highlighted by the current glow layer
  110656. */
  110657. hasMesh(mesh: AbstractMesh): boolean;
  110658. /**
  110659. * Free any resources and references associated to a mesh.
  110660. * Internal use
  110661. * @param mesh The mesh to free.
  110662. * @hidden
  110663. */
  110664. _disposeMesh(mesh: Mesh): void;
  110665. /**
  110666. * Gets the class name of the effect layer
  110667. * @returns the string with the class name of the effect layer
  110668. */
  110669. getClassName(): string;
  110670. /**
  110671. * Serializes this glow layer
  110672. * @returns a serialized glow layer object
  110673. */
  110674. serialize(): any;
  110675. /**
  110676. * Creates a Glow Layer from parsed glow layer data
  110677. * @param parsedGlowLayer defines glow layer data
  110678. * @param scene defines the current scene
  110679. * @param rootUrl defines the root URL containing the glow layer information
  110680. * @returns a parsed Glow Layer
  110681. */
  110682. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110683. }
  110684. }
  110685. declare module BABYLON {
  110686. /** @hidden */
  110687. export var glowBlurPostProcessPixelShader: {
  110688. name: string;
  110689. shader: string;
  110690. };
  110691. }
  110692. declare module BABYLON {
  110693. interface AbstractScene {
  110694. /**
  110695. * Return a the first highlight layer of the scene with a given name.
  110696. * @param name The name of the highlight layer to look for.
  110697. * @return The highlight layer if found otherwise null.
  110698. */
  110699. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110700. }
  110701. /**
  110702. * Highlight layer options. This helps customizing the behaviour
  110703. * of the highlight layer.
  110704. */
  110705. export interface IHighlightLayerOptions {
  110706. /**
  110707. * Multiplication factor apply to the canvas size to compute the render target size
  110708. * used to generated the glowing objects (the smaller the faster).
  110709. */
  110710. mainTextureRatio: number;
  110711. /**
  110712. * Enforces a fixed size texture to ensure resize independant blur.
  110713. */
  110714. mainTextureFixedSize?: number;
  110715. /**
  110716. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110717. * of the picture to blur (the smaller the faster).
  110718. */
  110719. blurTextureSizeRatio: number;
  110720. /**
  110721. * How big in texel of the blur texture is the vertical blur.
  110722. */
  110723. blurVerticalSize: number;
  110724. /**
  110725. * How big in texel of the blur texture is the horizontal blur.
  110726. */
  110727. blurHorizontalSize: number;
  110728. /**
  110729. * Alpha blending mode used to apply the blur. Default is combine.
  110730. */
  110731. alphaBlendingMode: number;
  110732. /**
  110733. * The camera attached to the layer.
  110734. */
  110735. camera: Nullable<Camera>;
  110736. /**
  110737. * Should we display highlight as a solid stroke?
  110738. */
  110739. isStroke?: boolean;
  110740. /**
  110741. * The rendering group to draw the layer in.
  110742. */
  110743. renderingGroupId: number;
  110744. }
  110745. /**
  110746. * The highlight layer Helps adding a glow effect around a mesh.
  110747. *
  110748. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110749. * glowy meshes to your scene.
  110750. *
  110751. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110752. */
  110753. export class HighlightLayer extends EffectLayer {
  110754. name: string;
  110755. /**
  110756. * Effect Name of the highlight layer.
  110757. */
  110758. static readonly EffectName: string;
  110759. /**
  110760. * The neutral color used during the preparation of the glow effect.
  110761. * This is black by default as the blend operation is a blend operation.
  110762. */
  110763. static NeutralColor: Color4;
  110764. /**
  110765. * Stencil value used for glowing meshes.
  110766. */
  110767. static GlowingMeshStencilReference: number;
  110768. /**
  110769. * Stencil value used for the other meshes in the scene.
  110770. */
  110771. static NormalMeshStencilReference: number;
  110772. /**
  110773. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110774. */
  110775. innerGlow: boolean;
  110776. /**
  110777. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110778. */
  110779. outerGlow: boolean;
  110780. /**
  110781. * Specifies the horizontal size of the blur.
  110782. */
  110783. /**
  110784. * Gets the horizontal size of the blur.
  110785. */
  110786. blurHorizontalSize: number;
  110787. /**
  110788. * Specifies the vertical size of the blur.
  110789. */
  110790. /**
  110791. * Gets the vertical size of the blur.
  110792. */
  110793. blurVerticalSize: number;
  110794. /**
  110795. * An event triggered when the highlight layer is being blurred.
  110796. */
  110797. onBeforeBlurObservable: Observable<HighlightLayer>;
  110798. /**
  110799. * An event triggered when the highlight layer has been blurred.
  110800. */
  110801. onAfterBlurObservable: Observable<HighlightLayer>;
  110802. private _instanceGlowingMeshStencilReference;
  110803. private _options;
  110804. private _downSamplePostprocess;
  110805. private _horizontalBlurPostprocess;
  110806. private _verticalBlurPostprocess;
  110807. private _blurTexture;
  110808. private _meshes;
  110809. private _excludedMeshes;
  110810. /**
  110811. * Instantiates a new highlight Layer and references it to the scene..
  110812. * @param name The name of the layer
  110813. * @param scene The scene to use the layer in
  110814. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110815. */
  110816. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110817. /**
  110818. * Get the effect name of the layer.
  110819. * @return The effect name
  110820. */
  110821. getEffectName(): string;
  110822. /**
  110823. * Create the merge effect. This is the shader use to blit the information back
  110824. * to the main canvas at the end of the scene rendering.
  110825. */
  110826. protected _createMergeEffect(): Effect;
  110827. /**
  110828. * Creates the render target textures and post processes used in the highlight layer.
  110829. */
  110830. protected _createTextureAndPostProcesses(): void;
  110831. /**
  110832. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110833. */
  110834. needStencil(): boolean;
  110835. /**
  110836. * Checks for the readiness of the element composing the layer.
  110837. * @param subMesh the mesh to check for
  110838. * @param useInstances specify wether or not to use instances to render the mesh
  110839. * @param emissiveTexture the associated emissive texture used to generate the glow
  110840. * @return true if ready otherwise, false
  110841. */
  110842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110843. /**
  110844. * Implementation specific of rendering the generating effect on the main canvas.
  110845. * @param effect The effect used to render through
  110846. */
  110847. protected _internalRender(effect: Effect): void;
  110848. /**
  110849. * Returns true if the layer contains information to display, otherwise false.
  110850. */
  110851. shouldRender(): boolean;
  110852. /**
  110853. * Returns true if the mesh should render, otherwise false.
  110854. * @param mesh The mesh to render
  110855. * @returns true if it should render otherwise false
  110856. */
  110857. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110858. /**
  110859. * Sets the required values for both the emissive texture and and the main color.
  110860. */
  110861. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110862. /**
  110863. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110864. * @param mesh The mesh to exclude from the highlight layer
  110865. */
  110866. addExcludedMesh(mesh: Mesh): void;
  110867. /**
  110868. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110869. * @param mesh The mesh to highlight
  110870. */
  110871. removeExcludedMesh(mesh: Mesh): void;
  110872. /**
  110873. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110874. * @param mesh mesh to test
  110875. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110876. */
  110877. hasMesh(mesh: AbstractMesh): boolean;
  110878. /**
  110879. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110880. * @param mesh The mesh to highlight
  110881. * @param color The color of the highlight
  110882. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110883. */
  110884. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110885. /**
  110886. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110887. * @param mesh The mesh to highlight
  110888. */
  110889. removeMesh(mesh: Mesh): void;
  110890. /**
  110891. * Force the stencil to the normal expected value for none glowing parts
  110892. */
  110893. private _defaultStencilReference;
  110894. /**
  110895. * Free any resources and references associated to a mesh.
  110896. * Internal use
  110897. * @param mesh The mesh to free.
  110898. * @hidden
  110899. */
  110900. _disposeMesh(mesh: Mesh): void;
  110901. /**
  110902. * Dispose the highlight layer and free resources.
  110903. */
  110904. dispose(): void;
  110905. /**
  110906. * Gets the class name of the effect layer
  110907. * @returns the string with the class name of the effect layer
  110908. */
  110909. getClassName(): string;
  110910. /**
  110911. * Serializes this Highlight layer
  110912. * @returns a serialized Highlight layer object
  110913. */
  110914. serialize(): any;
  110915. /**
  110916. * Creates a Highlight layer from parsed Highlight layer data
  110917. * @param parsedHightlightLayer defines the Highlight layer data
  110918. * @param scene defines the current scene
  110919. * @param rootUrl defines the root URL containing the Highlight layer information
  110920. * @returns a parsed Highlight layer
  110921. */
  110922. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110923. }
  110924. }
  110925. declare module BABYLON {
  110926. interface AbstractScene {
  110927. /**
  110928. * The list of layers (background and foreground) of the scene
  110929. */
  110930. layers: Array<Layer>;
  110931. }
  110932. /**
  110933. * Defines the layer scene component responsible to manage any layers
  110934. * in a given scene.
  110935. */
  110936. export class LayerSceneComponent implements ISceneComponent {
  110937. /**
  110938. * The component name helpfull to identify the component in the list of scene components.
  110939. */
  110940. readonly name: string;
  110941. /**
  110942. * The scene the component belongs to.
  110943. */
  110944. scene: Scene;
  110945. private _engine;
  110946. /**
  110947. * Creates a new instance of the component for the given scene
  110948. * @param scene Defines the scene to register the component in
  110949. */
  110950. constructor(scene: Scene);
  110951. /**
  110952. * Registers the component in a given scene
  110953. */
  110954. register(): void;
  110955. /**
  110956. * Rebuilds the elements related to this component in case of
  110957. * context lost for instance.
  110958. */
  110959. rebuild(): void;
  110960. /**
  110961. * Disposes the component and the associated ressources.
  110962. */
  110963. dispose(): void;
  110964. private _draw;
  110965. private _drawCameraPredicate;
  110966. private _drawCameraBackground;
  110967. private _drawCameraForeground;
  110968. private _drawRenderTargetPredicate;
  110969. private _drawRenderTargetBackground;
  110970. private _drawRenderTargetForeground;
  110971. /**
  110972. * Adds all the elements from the container to the scene
  110973. * @param container the container holding the elements
  110974. */
  110975. addFromContainer(container: AbstractScene): void;
  110976. /**
  110977. * Removes all the elements in the container from the scene
  110978. * @param container contains the elements to remove
  110979. * @param dispose if the removed element should be disposed (default: false)
  110980. */
  110981. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /** @hidden */
  110986. export var layerPixelShader: {
  110987. name: string;
  110988. shader: string;
  110989. };
  110990. }
  110991. declare module BABYLON {
  110992. /** @hidden */
  110993. export var layerVertexShader: {
  110994. name: string;
  110995. shader: string;
  110996. };
  110997. }
  110998. declare module BABYLON {
  110999. /**
  111000. * This represents a full screen 2d layer.
  111001. * This can be useful to display a picture in the background of your scene for instance.
  111002. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111003. */
  111004. export class Layer {
  111005. /**
  111006. * Define the name of the layer.
  111007. */
  111008. name: string;
  111009. /**
  111010. * Define the texture the layer should display.
  111011. */
  111012. texture: Nullable<Texture>;
  111013. /**
  111014. * Is the layer in background or foreground.
  111015. */
  111016. isBackground: boolean;
  111017. /**
  111018. * Define the color of the layer (instead of texture).
  111019. */
  111020. color: Color4;
  111021. /**
  111022. * Define the scale of the layer in order to zoom in out of the texture.
  111023. */
  111024. scale: Vector2;
  111025. /**
  111026. * Define an offset for the layer in order to shift the texture.
  111027. */
  111028. offset: Vector2;
  111029. /**
  111030. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111031. */
  111032. alphaBlendingMode: number;
  111033. /**
  111034. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111035. * Alpha test will not mix with the background color in case of transparency.
  111036. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111037. */
  111038. alphaTest: boolean;
  111039. /**
  111040. * Define a mask to restrict the layer to only some of the scene cameras.
  111041. */
  111042. layerMask: number;
  111043. /**
  111044. * Define the list of render target the layer is visible into.
  111045. */
  111046. renderTargetTextures: RenderTargetTexture[];
  111047. /**
  111048. * Define if the layer is only used in renderTarget or if it also
  111049. * renders in the main frame buffer of the canvas.
  111050. */
  111051. renderOnlyInRenderTargetTextures: boolean;
  111052. private _scene;
  111053. private _vertexBuffers;
  111054. private _indexBuffer;
  111055. private _effect;
  111056. private _alphaTestEffect;
  111057. /**
  111058. * An event triggered when the layer is disposed.
  111059. */
  111060. onDisposeObservable: Observable<Layer>;
  111061. private _onDisposeObserver;
  111062. /**
  111063. * Back compatibility with callback before the onDisposeObservable existed.
  111064. * The set callback will be triggered when the layer has been disposed.
  111065. */
  111066. onDispose: () => void;
  111067. /**
  111068. * An event triggered before rendering the scene
  111069. */
  111070. onBeforeRenderObservable: Observable<Layer>;
  111071. private _onBeforeRenderObserver;
  111072. /**
  111073. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111074. * The set callback will be triggered just before rendering the layer.
  111075. */
  111076. onBeforeRender: () => void;
  111077. /**
  111078. * An event triggered after rendering the scene
  111079. */
  111080. onAfterRenderObservable: Observable<Layer>;
  111081. private _onAfterRenderObserver;
  111082. /**
  111083. * Back compatibility with callback before the onAfterRenderObservable existed.
  111084. * The set callback will be triggered just after rendering the layer.
  111085. */
  111086. onAfterRender: () => void;
  111087. /**
  111088. * Instantiates a new layer.
  111089. * This represents a full screen 2d layer.
  111090. * This can be useful to display a picture in the background of your scene for instance.
  111091. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111092. * @param name Define the name of the layer in the scene
  111093. * @param imgUrl Define the url of the texture to display in the layer
  111094. * @param scene Define the scene the layer belongs to
  111095. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111096. * @param color Defines a color for the layer
  111097. */
  111098. constructor(
  111099. /**
  111100. * Define the name of the layer.
  111101. */
  111102. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111103. private _createIndexBuffer;
  111104. /** @hidden */
  111105. _rebuild(): void;
  111106. /**
  111107. * Renders the layer in the scene.
  111108. */
  111109. render(): void;
  111110. /**
  111111. * Disposes and releases the associated ressources.
  111112. */
  111113. dispose(): void;
  111114. }
  111115. }
  111116. declare module BABYLON {
  111117. /** @hidden */
  111118. export var lensFlarePixelShader: {
  111119. name: string;
  111120. shader: string;
  111121. };
  111122. }
  111123. declare module BABYLON {
  111124. /** @hidden */
  111125. export var lensFlareVertexShader: {
  111126. name: string;
  111127. shader: string;
  111128. };
  111129. }
  111130. declare module BABYLON {
  111131. /**
  111132. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111133. * It is usually composed of several `lensFlare`.
  111134. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111135. */
  111136. export class LensFlareSystem {
  111137. /**
  111138. * Define the name of the lens flare system
  111139. */
  111140. name: string;
  111141. /**
  111142. * List of lens flares used in this system.
  111143. */
  111144. lensFlares: LensFlare[];
  111145. /**
  111146. * Define a limit from the border the lens flare can be visible.
  111147. */
  111148. borderLimit: number;
  111149. /**
  111150. * Define a viewport border we do not want to see the lens flare in.
  111151. */
  111152. viewportBorder: number;
  111153. /**
  111154. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111155. */
  111156. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111157. /**
  111158. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111159. */
  111160. layerMask: number;
  111161. /**
  111162. * Define the id of the lens flare system in the scene.
  111163. * (equal to name by default)
  111164. */
  111165. id: string;
  111166. private _scene;
  111167. private _emitter;
  111168. private _vertexBuffers;
  111169. private _indexBuffer;
  111170. private _effect;
  111171. private _positionX;
  111172. private _positionY;
  111173. private _isEnabled;
  111174. /** @hidden */
  111175. static _SceneComponentInitialization: (scene: Scene) => void;
  111176. /**
  111177. * Instantiates a lens flare system.
  111178. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111179. * It is usually composed of several `lensFlare`.
  111180. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111181. * @param name Define the name of the lens flare system in the scene
  111182. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111183. * @param scene Define the scene the lens flare system belongs to
  111184. */
  111185. constructor(
  111186. /**
  111187. * Define the name of the lens flare system
  111188. */
  111189. name: string, emitter: any, scene: Scene);
  111190. /**
  111191. * Define if the lens flare system is enabled.
  111192. */
  111193. isEnabled: boolean;
  111194. /**
  111195. * Get the scene the effects belongs to.
  111196. * @returns the scene holding the lens flare system
  111197. */
  111198. getScene(): Scene;
  111199. /**
  111200. * Get the emitter of the lens flare system.
  111201. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111202. * @returns the emitter of the lens flare system
  111203. */
  111204. getEmitter(): any;
  111205. /**
  111206. * Set the emitter of the lens flare system.
  111207. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111208. * @param newEmitter Define the new emitter of the system
  111209. */
  111210. setEmitter(newEmitter: any): void;
  111211. /**
  111212. * Get the lens flare system emitter position.
  111213. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111214. * @returns the position
  111215. */
  111216. getEmitterPosition(): Vector3;
  111217. /**
  111218. * @hidden
  111219. */
  111220. computeEffectivePosition(globalViewport: Viewport): boolean;
  111221. /** @hidden */
  111222. _isVisible(): boolean;
  111223. /**
  111224. * @hidden
  111225. */
  111226. render(): boolean;
  111227. /**
  111228. * Dispose and release the lens flare with its associated resources.
  111229. */
  111230. dispose(): void;
  111231. /**
  111232. * Parse a lens flare system from a JSON repressentation
  111233. * @param parsedLensFlareSystem Define the JSON to parse
  111234. * @param scene Define the scene the parsed system should be instantiated in
  111235. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111236. * @returns the parsed system
  111237. */
  111238. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111239. /**
  111240. * Serialize the current Lens Flare System into a JSON representation.
  111241. * @returns the serialized JSON
  111242. */
  111243. serialize(): any;
  111244. }
  111245. }
  111246. declare module BABYLON {
  111247. /**
  111248. * This represents one of the lens effect in a `lensFlareSystem`.
  111249. * It controls one of the indiviual texture used in the effect.
  111250. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111251. */
  111252. export class LensFlare {
  111253. /**
  111254. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111255. */
  111256. size: number;
  111257. /**
  111258. * 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.
  111259. */
  111260. position: number;
  111261. /**
  111262. * Define the lens color.
  111263. */
  111264. color: Color3;
  111265. /**
  111266. * Define the lens texture.
  111267. */
  111268. texture: Nullable<Texture>;
  111269. /**
  111270. * Define the alpha mode to render this particular lens.
  111271. */
  111272. alphaMode: number;
  111273. private _system;
  111274. /**
  111275. * Creates a new Lens Flare.
  111276. * This represents one of the lens effect in a `lensFlareSystem`.
  111277. * It controls one of the indiviual texture used in the effect.
  111278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111279. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111280. * @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.
  111281. * @param color Define the lens color
  111282. * @param imgUrl Define the lens texture url
  111283. * @param system Define the `lensFlareSystem` this flare is part of
  111284. * @returns The newly created Lens Flare
  111285. */
  111286. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111287. /**
  111288. * Instantiates a new Lens Flare.
  111289. * This represents one of the lens effect in a `lensFlareSystem`.
  111290. * It controls one of the indiviual texture used in the effect.
  111291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111292. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111293. * @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.
  111294. * @param color Define the lens color
  111295. * @param imgUrl Define the lens texture url
  111296. * @param system Define the `lensFlareSystem` this flare is part of
  111297. */
  111298. constructor(
  111299. /**
  111300. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111301. */
  111302. size: number,
  111303. /**
  111304. * 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.
  111305. */
  111306. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111307. /**
  111308. * Dispose and release the lens flare with its associated resources.
  111309. */
  111310. dispose(): void;
  111311. }
  111312. }
  111313. declare module BABYLON {
  111314. interface AbstractScene {
  111315. /**
  111316. * The list of lens flare system added to the scene
  111317. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111318. */
  111319. lensFlareSystems: Array<LensFlareSystem>;
  111320. /**
  111321. * Removes the given lens flare system from this scene.
  111322. * @param toRemove The lens flare system to remove
  111323. * @returns The index of the removed lens flare system
  111324. */
  111325. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111326. /**
  111327. * Adds the given lens flare system to this scene
  111328. * @param newLensFlareSystem The lens flare system to add
  111329. */
  111330. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111331. /**
  111332. * Gets a lens flare system using its name
  111333. * @param name defines the name to look for
  111334. * @returns the lens flare system or null if not found
  111335. */
  111336. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111337. /**
  111338. * Gets a lens flare system using its id
  111339. * @param id defines the id to look for
  111340. * @returns the lens flare system or null if not found
  111341. */
  111342. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111343. }
  111344. /**
  111345. * Defines the lens flare scene component responsible to manage any lens flares
  111346. * in a given scene.
  111347. */
  111348. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111349. /**
  111350. * The component name helpfull to identify the component in the list of scene components.
  111351. */
  111352. readonly name: string;
  111353. /**
  111354. * The scene the component belongs to.
  111355. */
  111356. scene: Scene;
  111357. /**
  111358. * Creates a new instance of the component for the given scene
  111359. * @param scene Defines the scene to register the component in
  111360. */
  111361. constructor(scene: Scene);
  111362. /**
  111363. * Registers the component in a given scene
  111364. */
  111365. register(): void;
  111366. /**
  111367. * Rebuilds the elements related to this component in case of
  111368. * context lost for instance.
  111369. */
  111370. rebuild(): void;
  111371. /**
  111372. * Adds all the elements from the container to the scene
  111373. * @param container the container holding the elements
  111374. */
  111375. addFromContainer(container: AbstractScene): void;
  111376. /**
  111377. * Removes all the elements in the container from the scene
  111378. * @param container contains the elements to remove
  111379. * @param dispose if the removed element should be disposed (default: false)
  111380. */
  111381. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111382. /**
  111383. * Serializes the component data to the specified json object
  111384. * @param serializationObject The object to serialize to
  111385. */
  111386. serialize(serializationObject: any): void;
  111387. /**
  111388. * Disposes the component and the associated ressources.
  111389. */
  111390. dispose(): void;
  111391. private _draw;
  111392. }
  111393. }
  111394. declare module BABYLON {
  111395. /**
  111396. * Defines the shadow generator component responsible to manage any shadow generators
  111397. * in a given scene.
  111398. */
  111399. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111400. /**
  111401. * The component name helpfull to identify the component in the list of scene components.
  111402. */
  111403. readonly name: string;
  111404. /**
  111405. * The scene the component belongs to.
  111406. */
  111407. scene: Scene;
  111408. /**
  111409. * Creates a new instance of the component for the given scene
  111410. * @param scene Defines the scene to register the component in
  111411. */
  111412. constructor(scene: Scene);
  111413. /**
  111414. * Registers the component in a given scene
  111415. */
  111416. register(): void;
  111417. /**
  111418. * Rebuilds the elements related to this component in case of
  111419. * context lost for instance.
  111420. */
  111421. rebuild(): void;
  111422. /**
  111423. * Serializes the component data to the specified json object
  111424. * @param serializationObject The object to serialize to
  111425. */
  111426. serialize(serializationObject: any): void;
  111427. /**
  111428. * Adds all the elements from the container to the scene
  111429. * @param container the container holding the elements
  111430. */
  111431. addFromContainer(container: AbstractScene): void;
  111432. /**
  111433. * Removes all the elements in the container from the scene
  111434. * @param container contains the elements to remove
  111435. * @param dispose if the removed element should be disposed (default: false)
  111436. */
  111437. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111438. /**
  111439. * Rebuilds the elements related to this component in case of
  111440. * context lost for instance.
  111441. */
  111442. dispose(): void;
  111443. private _gatherRenderTargets;
  111444. }
  111445. }
  111446. declare module BABYLON {
  111447. /**
  111448. * A point light is a light defined by an unique point in world space.
  111449. * The light is emitted in every direction from this point.
  111450. * A good example of a point light is a standard light bulb.
  111451. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111452. */
  111453. export class PointLight extends ShadowLight {
  111454. private _shadowAngle;
  111455. /**
  111456. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111457. * This specifies what angle the shadow will use to be created.
  111458. *
  111459. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111460. */
  111461. /**
  111462. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111463. * This specifies what angle the shadow will use to be created.
  111464. *
  111465. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111466. */
  111467. shadowAngle: number;
  111468. /**
  111469. * Gets the direction if it has been set.
  111470. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111471. */
  111472. /**
  111473. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111474. */
  111475. direction: Vector3;
  111476. /**
  111477. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111478. * A PointLight emits the light in every direction.
  111479. * It can cast shadows.
  111480. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111481. * ```javascript
  111482. * var pointLight = new PointLight("pl", camera.position, scene);
  111483. * ```
  111484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111485. * @param name The light friendly name
  111486. * @param position The position of the point light in the scene
  111487. * @param scene The scene the lights belongs to
  111488. */
  111489. constructor(name: string, position: Vector3, scene: Scene);
  111490. /**
  111491. * Returns the string "PointLight"
  111492. * @returns the class name
  111493. */
  111494. getClassName(): string;
  111495. /**
  111496. * Returns the integer 0.
  111497. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111498. */
  111499. getTypeID(): number;
  111500. /**
  111501. * Specifies wether or not the shadowmap should be a cube texture.
  111502. * @returns true if the shadowmap needs to be a cube texture.
  111503. */
  111504. needCube(): boolean;
  111505. /**
  111506. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111507. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111508. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111509. */
  111510. getShadowDirection(faceIndex?: number): Vector3;
  111511. /**
  111512. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111513. * - fov = PI / 2
  111514. * - aspect ratio : 1.0
  111515. * - z-near and far equal to the active camera minZ and maxZ.
  111516. * Returns the PointLight.
  111517. */
  111518. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111519. protected _buildUniformLayout(): void;
  111520. /**
  111521. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111522. * @param effect The effect to update
  111523. * @param lightIndex The index of the light in the effect to update
  111524. * @returns The point light
  111525. */
  111526. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111527. /**
  111528. * Prepares the list of defines specific to the light type.
  111529. * @param defines the list of defines
  111530. * @param lightIndex defines the index of the light for the effect
  111531. */
  111532. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111533. }
  111534. }
  111535. declare module BABYLON {
  111536. /**
  111537. * Header information of HDR texture files.
  111538. */
  111539. export interface HDRInfo {
  111540. /**
  111541. * The height of the texture in pixels.
  111542. */
  111543. height: number;
  111544. /**
  111545. * The width of the texture in pixels.
  111546. */
  111547. width: number;
  111548. /**
  111549. * The index of the beginning of the data in the binary file.
  111550. */
  111551. dataPosition: number;
  111552. }
  111553. /**
  111554. * This groups tools to convert HDR texture to native colors array.
  111555. */
  111556. export class HDRTools {
  111557. private static Ldexp;
  111558. private static Rgbe2float;
  111559. private static readStringLine;
  111560. /**
  111561. * Reads header information from an RGBE texture stored in a native array.
  111562. * More information on this format are available here:
  111563. * https://en.wikipedia.org/wiki/RGBE_image_format
  111564. *
  111565. * @param uint8array The binary file stored in native array.
  111566. * @return The header information.
  111567. */
  111568. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111569. /**
  111570. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111571. * This RGBE texture needs to store the information as a panorama.
  111572. *
  111573. * More information on this format are available here:
  111574. * https://en.wikipedia.org/wiki/RGBE_image_format
  111575. *
  111576. * @param buffer The binary file stored in an array buffer.
  111577. * @param size The expected size of the extracted cubemap.
  111578. * @return The Cube Map information.
  111579. */
  111580. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111581. /**
  111582. * Returns the pixels data extracted from an RGBE texture.
  111583. * This pixels will be stored left to right up to down in the R G B order in one array.
  111584. *
  111585. * More information on this format are available here:
  111586. * https://en.wikipedia.org/wiki/RGBE_image_format
  111587. *
  111588. * @param uint8array The binary file stored in an array buffer.
  111589. * @param hdrInfo The header information of the file.
  111590. * @return The pixels data in RGB right to left up to down order.
  111591. */
  111592. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111593. private static RGBE_ReadPixels_RLE;
  111594. }
  111595. }
  111596. declare module BABYLON {
  111597. /**
  111598. * This represents a texture coming from an HDR input.
  111599. *
  111600. * The only supported format is currently panorama picture stored in RGBE format.
  111601. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111602. */
  111603. export class HDRCubeTexture extends BaseTexture {
  111604. private static _facesMapping;
  111605. private _generateHarmonics;
  111606. private _noMipmap;
  111607. private _textureMatrix;
  111608. private _size;
  111609. private _onLoad;
  111610. private _onError;
  111611. /**
  111612. * The texture URL.
  111613. */
  111614. url: string;
  111615. /**
  111616. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111617. */
  111618. coordinatesMode: number;
  111619. protected _isBlocking: boolean;
  111620. /**
  111621. * Sets wether or not the texture is blocking during loading.
  111622. */
  111623. /**
  111624. * Gets wether or not the texture is blocking during loading.
  111625. */
  111626. isBlocking: boolean;
  111627. protected _rotationY: number;
  111628. /**
  111629. * Sets texture matrix rotation angle around Y axis in radians.
  111630. */
  111631. /**
  111632. * Gets texture matrix rotation angle around Y axis radians.
  111633. */
  111634. rotationY: number;
  111635. /**
  111636. * Gets or sets the center of the bounding box associated with the cube texture
  111637. * It must define where the camera used to render the texture was set
  111638. */
  111639. boundingBoxPosition: Vector3;
  111640. private _boundingBoxSize;
  111641. /**
  111642. * Gets or sets the size of the bounding box associated with the cube texture
  111643. * When defined, the cubemap will switch to local mode
  111644. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111645. * @example https://www.babylonjs-playground.com/#RNASML
  111646. */
  111647. boundingBoxSize: Vector3;
  111648. /**
  111649. * Instantiates an HDRTexture from the following parameters.
  111650. *
  111651. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111652. * @param scene The scene the texture will be used in
  111653. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111654. * @param noMipmap Forces to not generate the mipmap if true
  111655. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111656. * @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)
  111657. * @param reserved Reserved flag for internal use.
  111658. */
  111659. 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>);
  111660. /**
  111661. * Get the current class name of the texture useful for serialization or dynamic coding.
  111662. * @returns "HDRCubeTexture"
  111663. */
  111664. getClassName(): string;
  111665. /**
  111666. * Occurs when the file is raw .hdr file.
  111667. */
  111668. private loadTexture;
  111669. clone(): HDRCubeTexture;
  111670. delayLoad(): void;
  111671. /**
  111672. * Get the texture reflection matrix used to rotate/transform the reflection.
  111673. * @returns the reflection matrix
  111674. */
  111675. getReflectionTextureMatrix(): Matrix;
  111676. /**
  111677. * Set the texture reflection matrix used to rotate/transform the reflection.
  111678. * @param value Define the reflection matrix to set
  111679. */
  111680. setReflectionTextureMatrix(value: Matrix): void;
  111681. /**
  111682. * Parses a JSON representation of an HDR Texture in order to create the texture
  111683. * @param parsedTexture Define the JSON representation
  111684. * @param scene Define the scene the texture should be created in
  111685. * @param rootUrl Define the root url in case we need to load relative dependencies
  111686. * @returns the newly created texture after parsing
  111687. */
  111688. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111689. serialize(): any;
  111690. }
  111691. }
  111692. declare module BABYLON {
  111693. /**
  111694. * Class used to control physics engine
  111695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111696. */
  111697. export class PhysicsEngine implements IPhysicsEngine {
  111698. private _physicsPlugin;
  111699. /**
  111700. * Global value used to control the smallest number supported by the simulation
  111701. */
  111702. static Epsilon: number;
  111703. private _impostors;
  111704. private _joints;
  111705. /**
  111706. * Gets the gravity vector used by the simulation
  111707. */
  111708. gravity: Vector3;
  111709. /**
  111710. * Factory used to create the default physics plugin.
  111711. * @returns The default physics plugin
  111712. */
  111713. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111714. /**
  111715. * Creates a new Physics Engine
  111716. * @param gravity defines the gravity vector used by the simulation
  111717. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111718. */
  111719. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111720. /**
  111721. * Sets the gravity vector used by the simulation
  111722. * @param gravity defines the gravity vector to use
  111723. */
  111724. setGravity(gravity: Vector3): void;
  111725. /**
  111726. * Set the time step of the physics engine.
  111727. * Default is 1/60.
  111728. * To slow it down, enter 1/600 for example.
  111729. * To speed it up, 1/30
  111730. * @param newTimeStep defines the new timestep to apply to this world.
  111731. */
  111732. setTimeStep(newTimeStep?: number): void;
  111733. /**
  111734. * Get the time step of the physics engine.
  111735. * @returns the current time step
  111736. */
  111737. getTimeStep(): number;
  111738. /**
  111739. * Release all resources
  111740. */
  111741. dispose(): void;
  111742. /**
  111743. * Gets the name of the current physics plugin
  111744. * @returns the name of the plugin
  111745. */
  111746. getPhysicsPluginName(): string;
  111747. /**
  111748. * Adding a new impostor for the impostor tracking.
  111749. * This will be done by the impostor itself.
  111750. * @param impostor the impostor to add
  111751. */
  111752. addImpostor(impostor: PhysicsImpostor): void;
  111753. /**
  111754. * Remove an impostor from the engine.
  111755. * This impostor and its mesh will not longer be updated by the physics engine.
  111756. * @param impostor the impostor to remove
  111757. */
  111758. removeImpostor(impostor: PhysicsImpostor): void;
  111759. /**
  111760. * Add a joint to the physics engine
  111761. * @param mainImpostor defines the main impostor to which the joint is added.
  111762. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111763. * @param joint defines the joint that will connect both impostors.
  111764. */
  111765. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111766. /**
  111767. * Removes a joint from the simulation
  111768. * @param mainImpostor defines the impostor used with the joint
  111769. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111770. * @param joint defines the joint to remove
  111771. */
  111772. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111773. /**
  111774. * Called by the scene. No need to call it.
  111775. * @param delta defines the timespam between frames
  111776. */
  111777. _step(delta: number): void;
  111778. /**
  111779. * Gets the current plugin used to run the simulation
  111780. * @returns current plugin
  111781. */
  111782. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111783. /**
  111784. * Gets the list of physic impostors
  111785. * @returns an array of PhysicsImpostor
  111786. */
  111787. getImpostors(): Array<PhysicsImpostor>;
  111788. /**
  111789. * Gets the impostor for a physics enabled object
  111790. * @param object defines the object impersonated by the impostor
  111791. * @returns the PhysicsImpostor or null if not found
  111792. */
  111793. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111794. /**
  111795. * Gets the impostor for a physics body object
  111796. * @param body defines physics body used by the impostor
  111797. * @returns the PhysicsImpostor or null if not found
  111798. */
  111799. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111800. /**
  111801. * Does a raycast in the physics world
  111802. * @param from when should the ray start?
  111803. * @param to when should the ray end?
  111804. * @returns PhysicsRaycastResult
  111805. */
  111806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111807. }
  111808. }
  111809. declare module BABYLON {
  111810. /** @hidden */
  111811. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111812. private _useDeltaForWorldStep;
  111813. world: any;
  111814. name: string;
  111815. private _physicsMaterials;
  111816. private _fixedTimeStep;
  111817. private _cannonRaycastResult;
  111818. private _raycastResult;
  111819. private _physicsBodysToRemoveAfterStep;
  111820. BJSCANNON: any;
  111821. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111822. setGravity(gravity: Vector3): void;
  111823. setTimeStep(timeStep: number): void;
  111824. getTimeStep(): number;
  111825. executeStep(delta: number): void;
  111826. private _removeMarkedPhysicsBodiesFromWorld;
  111827. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111828. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111829. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111830. private _processChildMeshes;
  111831. removePhysicsBody(impostor: PhysicsImpostor): void;
  111832. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111833. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111834. private _addMaterial;
  111835. private _checkWithEpsilon;
  111836. private _createShape;
  111837. private _createHeightmap;
  111838. private _minus90X;
  111839. private _plus90X;
  111840. private _tmpPosition;
  111841. private _tmpDeltaPosition;
  111842. private _tmpUnityRotation;
  111843. private _updatePhysicsBodyTransformation;
  111844. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111845. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111846. isSupported(): boolean;
  111847. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111848. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111849. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111850. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111851. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111852. getBodyMass(impostor: PhysicsImpostor): number;
  111853. getBodyFriction(impostor: PhysicsImpostor): number;
  111854. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111855. getBodyRestitution(impostor: PhysicsImpostor): number;
  111856. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111857. sleepBody(impostor: PhysicsImpostor): void;
  111858. wakeUpBody(impostor: PhysicsImpostor): void;
  111859. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111860. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111861. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111862. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111863. getRadius(impostor: PhysicsImpostor): number;
  111864. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111865. dispose(): void;
  111866. private _extendNamespace;
  111867. /**
  111868. * Does a raycast in the physics world
  111869. * @param from when should the ray start?
  111870. * @param to when should the ray end?
  111871. * @returns PhysicsRaycastResult
  111872. */
  111873. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111874. }
  111875. }
  111876. declare module BABYLON {
  111877. /** @hidden */
  111878. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111879. world: any;
  111880. name: string;
  111881. BJSOIMO: any;
  111882. private _raycastResult;
  111883. constructor(iterations?: number, oimoInjection?: any);
  111884. setGravity(gravity: Vector3): void;
  111885. setTimeStep(timeStep: number): void;
  111886. getTimeStep(): number;
  111887. private _tmpImpostorsArray;
  111888. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111889. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111890. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111891. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111892. private _tmpPositionVector;
  111893. removePhysicsBody(impostor: PhysicsImpostor): void;
  111894. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111895. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111896. isSupported(): boolean;
  111897. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111898. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111899. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111900. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111901. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111902. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111903. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111904. getBodyMass(impostor: PhysicsImpostor): number;
  111905. getBodyFriction(impostor: PhysicsImpostor): number;
  111906. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111907. getBodyRestitution(impostor: PhysicsImpostor): number;
  111908. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111909. sleepBody(impostor: PhysicsImpostor): void;
  111910. wakeUpBody(impostor: PhysicsImpostor): void;
  111911. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111912. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111913. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111914. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111915. getRadius(impostor: PhysicsImpostor): number;
  111916. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111917. dispose(): void;
  111918. /**
  111919. * Does a raycast in the physics world
  111920. * @param from when should the ray start?
  111921. * @param to when should the ray end?
  111922. * @returns PhysicsRaycastResult
  111923. */
  111924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111925. }
  111926. }
  111927. declare module BABYLON {
  111928. /**
  111929. * Class containing static functions to help procedurally build meshes
  111930. */
  111931. export class RibbonBuilder {
  111932. /**
  111933. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111934. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111935. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111936. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111937. * * 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
  111938. * * 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
  111939. * * 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
  111940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111943. * * 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
  111944. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111945. * * 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
  111946. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111948. * @param name defines the name of the mesh
  111949. * @param options defines the options used to create the mesh
  111950. * @param scene defines the hosting scene
  111951. * @returns the ribbon mesh
  111952. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111954. */
  111955. static CreateRibbon(name: string, options: {
  111956. pathArray: Vector3[][];
  111957. closeArray?: boolean;
  111958. closePath?: boolean;
  111959. offset?: number;
  111960. updatable?: boolean;
  111961. sideOrientation?: number;
  111962. frontUVs?: Vector4;
  111963. backUVs?: Vector4;
  111964. instance?: Mesh;
  111965. invertUV?: boolean;
  111966. uvs?: Vector2[];
  111967. colors?: Color4[];
  111968. }, scene?: Nullable<Scene>): Mesh;
  111969. }
  111970. }
  111971. declare module BABYLON {
  111972. /**
  111973. * Class containing static functions to help procedurally build meshes
  111974. */
  111975. export class ShapeBuilder {
  111976. /**
  111977. * 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.
  111978. * * 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.
  111979. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111980. * * 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.
  111981. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111982. * * 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
  111983. * * 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
  111984. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111989. * @param name defines the name of the mesh
  111990. * @param options defines the options used to create the mesh
  111991. * @param scene defines the hosting scene
  111992. * @returns the extruded shape mesh
  111993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111995. */
  111996. static ExtrudeShape(name: string, options: {
  111997. shape: Vector3[];
  111998. path: Vector3[];
  111999. scale?: number;
  112000. rotation?: number;
  112001. cap?: number;
  112002. updatable?: boolean;
  112003. sideOrientation?: number;
  112004. frontUVs?: Vector4;
  112005. backUVs?: Vector4;
  112006. instance?: Mesh;
  112007. invertUV?: boolean;
  112008. }, scene?: Nullable<Scene>): Mesh;
  112009. /**
  112010. * Creates an custom extruded shape mesh.
  112011. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112012. * * 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.
  112013. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112014. * * 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
  112015. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112016. * * 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
  112017. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112018. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112019. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112020. * * 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
  112021. * * 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
  112022. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112027. * @param name defines the name of the mesh
  112028. * @param options defines the options used to create the mesh
  112029. * @param scene defines the hosting scene
  112030. * @returns the custom extruded shape mesh
  112031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112034. */
  112035. static ExtrudeShapeCustom(name: string, options: {
  112036. shape: Vector3[];
  112037. path: Vector3[];
  112038. scaleFunction?: any;
  112039. rotationFunction?: any;
  112040. ribbonCloseArray?: boolean;
  112041. ribbonClosePath?: boolean;
  112042. cap?: number;
  112043. updatable?: boolean;
  112044. sideOrientation?: number;
  112045. frontUVs?: Vector4;
  112046. backUVs?: Vector4;
  112047. instance?: Mesh;
  112048. invertUV?: boolean;
  112049. }, scene?: Nullable<Scene>): Mesh;
  112050. private static _ExtrudeShapeGeneric;
  112051. }
  112052. }
  112053. declare module BABYLON {
  112054. /**
  112055. * AmmoJS Physics plugin
  112056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112057. * @see https://github.com/kripken/ammo.js/
  112058. */
  112059. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112060. private _useDeltaForWorldStep;
  112061. /**
  112062. * Reference to the Ammo library
  112063. */
  112064. bjsAMMO: any;
  112065. /**
  112066. * Created ammoJS world which physics bodies are added to
  112067. */
  112068. world: any;
  112069. /**
  112070. * Name of the plugin
  112071. */
  112072. name: string;
  112073. private _timeStep;
  112074. private _fixedTimeStep;
  112075. private _maxSteps;
  112076. private _tmpQuaternion;
  112077. private _tmpAmmoTransform;
  112078. private _tmpAmmoQuaternion;
  112079. private _tmpAmmoConcreteContactResultCallback;
  112080. private _collisionConfiguration;
  112081. private _dispatcher;
  112082. private _overlappingPairCache;
  112083. private _solver;
  112084. private _softBodySolver;
  112085. private _tmpAmmoVectorA;
  112086. private _tmpAmmoVectorB;
  112087. private _tmpAmmoVectorC;
  112088. private _tmpAmmoVectorD;
  112089. private _tmpContactCallbackResult;
  112090. private _tmpAmmoVectorRCA;
  112091. private _tmpAmmoVectorRCB;
  112092. private _raycastResult;
  112093. private static readonly DISABLE_COLLISION_FLAG;
  112094. private static readonly KINEMATIC_FLAG;
  112095. private static readonly DISABLE_DEACTIVATION_FLAG;
  112096. /**
  112097. * Initializes the ammoJS plugin
  112098. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112099. * @param ammoInjection can be used to inject your own ammo reference
  112100. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112101. */
  112102. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112103. /**
  112104. * Sets the gravity of the physics world (m/(s^2))
  112105. * @param gravity Gravity to set
  112106. */
  112107. setGravity(gravity: Vector3): void;
  112108. /**
  112109. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112110. * @param timeStep timestep to use in seconds
  112111. */
  112112. setTimeStep(timeStep: number): void;
  112113. /**
  112114. * 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)
  112115. * @param fixedTimeStep fixedTimeStep to use in seconds
  112116. */
  112117. setFixedTimeStep(fixedTimeStep: number): void;
  112118. /**
  112119. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112120. * @param maxSteps the maximum number of steps by the physics engine per frame
  112121. */
  112122. setMaxSteps(maxSteps: number): void;
  112123. /**
  112124. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112125. * @returns the current timestep in seconds
  112126. */
  112127. getTimeStep(): number;
  112128. private _isImpostorInContact;
  112129. private _isImpostorPairInContact;
  112130. private _stepSimulation;
  112131. /**
  112132. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112133. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112134. * After the step the babylon meshes are set to the position of the physics imposters
  112135. * @param delta amount of time to step forward
  112136. * @param impostors array of imposters to update before/after the step
  112137. */
  112138. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112139. /**
  112140. * Update babylon mesh to match physics world object
  112141. * @param impostor imposter to match
  112142. */
  112143. private _afterSoftStep;
  112144. /**
  112145. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112146. * @param impostor imposter to match
  112147. */
  112148. private _ropeStep;
  112149. /**
  112150. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112151. * @param impostor imposter to match
  112152. */
  112153. private _softbodyOrClothStep;
  112154. private _tmpVector;
  112155. private _tmpMatrix;
  112156. /**
  112157. * Applies an impulse on the imposter
  112158. * @param impostor imposter to apply impulse to
  112159. * @param force amount of force to be applied to the imposter
  112160. * @param contactPoint the location to apply the impulse on the imposter
  112161. */
  112162. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112163. /**
  112164. * Applies a force on the imposter
  112165. * @param impostor imposter to apply force
  112166. * @param force amount of force to be applied to the imposter
  112167. * @param contactPoint the location to apply the force on the imposter
  112168. */
  112169. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112170. /**
  112171. * Creates a physics body using the plugin
  112172. * @param impostor the imposter to create the physics body on
  112173. */
  112174. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112175. /**
  112176. * Removes the physics body from the imposter and disposes of the body's memory
  112177. * @param impostor imposter to remove the physics body from
  112178. */
  112179. removePhysicsBody(impostor: PhysicsImpostor): void;
  112180. /**
  112181. * Generates a joint
  112182. * @param impostorJoint the imposter joint to create the joint with
  112183. */
  112184. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112185. /**
  112186. * Removes a joint
  112187. * @param impostorJoint the imposter joint to remove the joint from
  112188. */
  112189. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112190. private _addMeshVerts;
  112191. /**
  112192. * Initialise the soft body vertices to match its object's (mesh) vertices
  112193. * Softbody vertices (nodes) are in world space and to match this
  112194. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112195. * @param impostor to create the softbody for
  112196. */
  112197. private _softVertexData;
  112198. /**
  112199. * Create an impostor's soft body
  112200. * @param impostor to create the softbody for
  112201. */
  112202. private _createSoftbody;
  112203. /**
  112204. * Create cloth for an impostor
  112205. * @param impostor to create the softbody for
  112206. */
  112207. private _createCloth;
  112208. /**
  112209. * Create rope for an impostor
  112210. * @param impostor to create the softbody for
  112211. */
  112212. private _createRope;
  112213. private _addHullVerts;
  112214. private _createShape;
  112215. /**
  112216. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112217. * @param impostor imposter containing the physics body and babylon object
  112218. */
  112219. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112220. /**
  112221. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112222. * @param impostor imposter containing the physics body and babylon object
  112223. * @param newPosition new position
  112224. * @param newRotation new rotation
  112225. */
  112226. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112227. /**
  112228. * If this plugin is supported
  112229. * @returns true if its supported
  112230. */
  112231. isSupported(): boolean;
  112232. /**
  112233. * Sets the linear velocity of the physics body
  112234. * @param impostor imposter to set the velocity on
  112235. * @param velocity velocity to set
  112236. */
  112237. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112238. /**
  112239. * Sets the angular velocity of the physics body
  112240. * @param impostor imposter to set the velocity on
  112241. * @param velocity velocity to set
  112242. */
  112243. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112244. /**
  112245. * gets the linear velocity
  112246. * @param impostor imposter to get linear velocity from
  112247. * @returns linear velocity
  112248. */
  112249. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112250. /**
  112251. * gets the angular velocity
  112252. * @param impostor imposter to get angular velocity from
  112253. * @returns angular velocity
  112254. */
  112255. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112256. /**
  112257. * Sets the mass of physics body
  112258. * @param impostor imposter to set the mass on
  112259. * @param mass mass to set
  112260. */
  112261. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112262. /**
  112263. * Gets the mass of the physics body
  112264. * @param impostor imposter to get the mass from
  112265. * @returns mass
  112266. */
  112267. getBodyMass(impostor: PhysicsImpostor): number;
  112268. /**
  112269. * Gets friction of the impostor
  112270. * @param impostor impostor to get friction from
  112271. * @returns friction value
  112272. */
  112273. getBodyFriction(impostor: PhysicsImpostor): number;
  112274. /**
  112275. * Sets friction of the impostor
  112276. * @param impostor impostor to set friction on
  112277. * @param friction friction value
  112278. */
  112279. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112280. /**
  112281. * Gets restitution of the impostor
  112282. * @param impostor impostor to get restitution from
  112283. * @returns restitution value
  112284. */
  112285. getBodyRestitution(impostor: PhysicsImpostor): number;
  112286. /**
  112287. * Sets resitution of the impostor
  112288. * @param impostor impostor to set resitution on
  112289. * @param restitution resitution value
  112290. */
  112291. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112292. /**
  112293. * Gets pressure inside the impostor
  112294. * @param impostor impostor to get pressure from
  112295. * @returns pressure value
  112296. */
  112297. getBodyPressure(impostor: PhysicsImpostor): number;
  112298. /**
  112299. * Sets pressure inside a soft body impostor
  112300. * Cloth and rope must remain 0 pressure
  112301. * @param impostor impostor to set pressure on
  112302. * @param pressure pressure value
  112303. */
  112304. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112305. /**
  112306. * Gets stiffness of the impostor
  112307. * @param impostor impostor to get stiffness from
  112308. * @returns pressure value
  112309. */
  112310. getBodyStiffness(impostor: PhysicsImpostor): number;
  112311. /**
  112312. * Sets stiffness of the impostor
  112313. * @param impostor impostor to set stiffness on
  112314. * @param stiffness stiffness value from 0 to 1
  112315. */
  112316. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112317. /**
  112318. * Gets velocityIterations of the impostor
  112319. * @param impostor impostor to get velocity iterations from
  112320. * @returns velocityIterations value
  112321. */
  112322. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112323. /**
  112324. * Sets velocityIterations of the impostor
  112325. * @param impostor impostor to set velocity iterations on
  112326. * @param velocityIterations velocityIterations value
  112327. */
  112328. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112329. /**
  112330. * Gets positionIterations of the impostor
  112331. * @param impostor impostor to get position iterations from
  112332. * @returns positionIterations value
  112333. */
  112334. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112335. /**
  112336. * Sets positionIterations of the impostor
  112337. * @param impostor impostor to set position on
  112338. * @param positionIterations positionIterations value
  112339. */
  112340. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112341. /**
  112342. * Append an anchor to a cloth object
  112343. * @param impostor is the cloth impostor to add anchor to
  112344. * @param otherImpostor is the rigid impostor to anchor to
  112345. * @param width ratio across width from 0 to 1
  112346. * @param height ratio up height from 0 to 1
  112347. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112348. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112349. */
  112350. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112351. /**
  112352. * Append an hook to a rope object
  112353. * @param impostor is the rope impostor to add hook to
  112354. * @param otherImpostor is the rigid impostor to hook to
  112355. * @param length ratio along the rope from 0 to 1
  112356. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112357. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112358. */
  112359. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112360. /**
  112361. * Sleeps the physics body and stops it from being active
  112362. * @param impostor impostor to sleep
  112363. */
  112364. sleepBody(impostor: PhysicsImpostor): void;
  112365. /**
  112366. * Activates the physics body
  112367. * @param impostor impostor to activate
  112368. */
  112369. wakeUpBody(impostor: PhysicsImpostor): void;
  112370. /**
  112371. * Updates the distance parameters of the joint
  112372. * @param joint joint to update
  112373. * @param maxDistance maximum distance of the joint
  112374. * @param minDistance minimum distance of the joint
  112375. */
  112376. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112377. /**
  112378. * Sets a motor on the joint
  112379. * @param joint joint to set motor on
  112380. * @param speed speed of the motor
  112381. * @param maxForce maximum force of the motor
  112382. * @param motorIndex index of the motor
  112383. */
  112384. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112385. /**
  112386. * Sets the motors limit
  112387. * @param joint joint to set limit on
  112388. * @param upperLimit upper limit
  112389. * @param lowerLimit lower limit
  112390. */
  112391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112392. /**
  112393. * Syncs the position and rotation of a mesh with the impostor
  112394. * @param mesh mesh to sync
  112395. * @param impostor impostor to update the mesh with
  112396. */
  112397. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112398. /**
  112399. * Gets the radius of the impostor
  112400. * @param impostor impostor to get radius from
  112401. * @returns the radius
  112402. */
  112403. getRadius(impostor: PhysicsImpostor): number;
  112404. /**
  112405. * Gets the box size of the impostor
  112406. * @param impostor impostor to get box size from
  112407. * @param result the resulting box size
  112408. */
  112409. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112410. /**
  112411. * Disposes of the impostor
  112412. */
  112413. dispose(): void;
  112414. /**
  112415. * Does a raycast in the physics world
  112416. * @param from when should the ray start?
  112417. * @param to when should the ray end?
  112418. * @returns PhysicsRaycastResult
  112419. */
  112420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112421. }
  112422. }
  112423. declare module BABYLON {
  112424. interface AbstractScene {
  112425. /**
  112426. * The list of reflection probes added to the scene
  112427. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112428. */
  112429. reflectionProbes: Array<ReflectionProbe>;
  112430. /**
  112431. * Removes the given reflection probe from this scene.
  112432. * @param toRemove The reflection probe to remove
  112433. * @returns The index of the removed reflection probe
  112434. */
  112435. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112436. /**
  112437. * Adds the given reflection probe to this scene.
  112438. * @param newReflectionProbe The reflection probe to add
  112439. */
  112440. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112441. }
  112442. /**
  112443. * Class used to generate realtime reflection / refraction cube textures
  112444. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112445. */
  112446. export class ReflectionProbe {
  112447. /** defines the name of the probe */
  112448. name: string;
  112449. private _scene;
  112450. private _renderTargetTexture;
  112451. private _projectionMatrix;
  112452. private _viewMatrix;
  112453. private _target;
  112454. private _add;
  112455. private _attachedMesh;
  112456. private _invertYAxis;
  112457. /** Gets or sets probe position (center of the cube map) */
  112458. position: Vector3;
  112459. /**
  112460. * Creates a new reflection probe
  112461. * @param name defines the name of the probe
  112462. * @param size defines the texture resolution (for each face)
  112463. * @param scene defines the hosting scene
  112464. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112465. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112466. */
  112467. constructor(
  112468. /** defines the name of the probe */
  112469. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112470. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112471. samples: number;
  112472. /** Gets or sets the refresh rate to use (on every frame by default) */
  112473. refreshRate: number;
  112474. /**
  112475. * Gets the hosting scene
  112476. * @returns a Scene
  112477. */
  112478. getScene(): Scene;
  112479. /** Gets the internal CubeTexture used to render to */
  112480. readonly cubeTexture: RenderTargetTexture;
  112481. /** Gets the list of meshes to render */
  112482. readonly renderList: Nullable<AbstractMesh[]>;
  112483. /**
  112484. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112485. * @param mesh defines the mesh to attach to
  112486. */
  112487. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112488. /**
  112489. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112490. * @param renderingGroupId The rendering group id corresponding to its index
  112491. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112492. */
  112493. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112494. /**
  112495. * Clean all associated resources
  112496. */
  112497. dispose(): void;
  112498. /**
  112499. * Converts the reflection probe information to a readable string for debug purpose.
  112500. * @param fullDetails Supports for multiple levels of logging within scene loading
  112501. * @returns the human readable reflection probe info
  112502. */
  112503. toString(fullDetails?: boolean): string;
  112504. /**
  112505. * Get the class name of the relfection probe.
  112506. * @returns "ReflectionProbe"
  112507. */
  112508. getClassName(): string;
  112509. /**
  112510. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112511. * @returns The JSON representation of the texture
  112512. */
  112513. serialize(): any;
  112514. /**
  112515. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112516. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112517. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112518. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112519. * @returns The parsed reflection probe if successful
  112520. */
  112521. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112522. }
  112523. }
  112524. declare module BABYLON {
  112525. /** @hidden */
  112526. export var _BabylonLoaderRegistered: boolean;
  112527. }
  112528. declare module BABYLON {
  112529. /**
  112530. * The Physically based simple base material of BJS.
  112531. *
  112532. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112533. * It is used as the base class for both the specGloss and metalRough conventions.
  112534. */
  112535. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112536. /**
  112537. * Number of Simultaneous lights allowed on the material.
  112538. */
  112539. maxSimultaneousLights: number;
  112540. /**
  112541. * If sets to true, disables all the lights affecting the material.
  112542. */
  112543. disableLighting: boolean;
  112544. /**
  112545. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112546. */
  112547. environmentTexture: BaseTexture;
  112548. /**
  112549. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112550. */
  112551. invertNormalMapX: boolean;
  112552. /**
  112553. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112554. */
  112555. invertNormalMapY: boolean;
  112556. /**
  112557. * Normal map used in the model.
  112558. */
  112559. normalTexture: BaseTexture;
  112560. /**
  112561. * Emissivie color used to self-illuminate the model.
  112562. */
  112563. emissiveColor: Color3;
  112564. /**
  112565. * Emissivie texture used to self-illuminate the model.
  112566. */
  112567. emissiveTexture: BaseTexture;
  112568. /**
  112569. * Occlusion Channel Strenght.
  112570. */
  112571. occlusionStrength: number;
  112572. /**
  112573. * Occlusion Texture of the material (adding extra occlusion effects).
  112574. */
  112575. occlusionTexture: BaseTexture;
  112576. /**
  112577. * Defines the alpha limits in alpha test mode.
  112578. */
  112579. alphaCutOff: number;
  112580. /**
  112581. * Gets the current double sided mode.
  112582. */
  112583. /**
  112584. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112585. */
  112586. doubleSided: boolean;
  112587. /**
  112588. * Stores the pre-calculated light information of a mesh in a texture.
  112589. */
  112590. lightmapTexture: BaseTexture;
  112591. /**
  112592. * If true, the light map contains occlusion information instead of lighting info.
  112593. */
  112594. useLightmapAsShadowmap: boolean;
  112595. /**
  112596. * Instantiates a new PBRMaterial instance.
  112597. *
  112598. * @param name The material name
  112599. * @param scene The scene the material will be use in.
  112600. */
  112601. constructor(name: string, scene: Scene);
  112602. getClassName(): string;
  112603. }
  112604. }
  112605. declare module BABYLON {
  112606. /**
  112607. * The PBR material of BJS following the metal roughness convention.
  112608. *
  112609. * This fits to the PBR convention in the GLTF definition:
  112610. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112611. */
  112612. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112613. /**
  112614. * The base color has two different interpretations depending on the value of metalness.
  112615. * When the material is a metal, the base color is the specific measured reflectance value
  112616. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112617. * of the material.
  112618. */
  112619. baseColor: Color3;
  112620. /**
  112621. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112622. * well as opacity information in the alpha channel.
  112623. */
  112624. baseTexture: BaseTexture;
  112625. /**
  112626. * Specifies the metallic scalar value of the material.
  112627. * Can also be used to scale the metalness values of the metallic texture.
  112628. */
  112629. metallic: number;
  112630. /**
  112631. * Specifies the roughness scalar value of the material.
  112632. * Can also be used to scale the roughness values of the metallic texture.
  112633. */
  112634. roughness: number;
  112635. /**
  112636. * Texture containing both the metallic value in the B channel and the
  112637. * roughness value in the G channel to keep better precision.
  112638. */
  112639. metallicRoughnessTexture: BaseTexture;
  112640. /**
  112641. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112642. *
  112643. * @param name The material name
  112644. * @param scene The scene the material will be use in.
  112645. */
  112646. constructor(name: string, scene: Scene);
  112647. /**
  112648. * Return the currrent class name of the material.
  112649. */
  112650. getClassName(): string;
  112651. /**
  112652. * Makes a duplicate of the current material.
  112653. * @param name - name to use for the new material.
  112654. */
  112655. clone(name: string): PBRMetallicRoughnessMaterial;
  112656. /**
  112657. * Serialize the material to a parsable JSON object.
  112658. */
  112659. serialize(): any;
  112660. /**
  112661. * Parses a JSON object correponding to the serialize function.
  112662. */
  112663. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112664. }
  112665. }
  112666. declare module BABYLON {
  112667. /**
  112668. * The PBR material of BJS following the specular glossiness convention.
  112669. *
  112670. * This fits to the PBR convention in the GLTF definition:
  112671. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112672. */
  112673. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112674. /**
  112675. * Specifies the diffuse color of the material.
  112676. */
  112677. diffuseColor: Color3;
  112678. /**
  112679. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112680. * channel.
  112681. */
  112682. diffuseTexture: BaseTexture;
  112683. /**
  112684. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112685. */
  112686. specularColor: Color3;
  112687. /**
  112688. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112689. */
  112690. glossiness: number;
  112691. /**
  112692. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112693. */
  112694. specularGlossinessTexture: BaseTexture;
  112695. /**
  112696. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112697. *
  112698. * @param name The material name
  112699. * @param scene The scene the material will be use in.
  112700. */
  112701. constructor(name: string, scene: Scene);
  112702. /**
  112703. * Return the currrent class name of the material.
  112704. */
  112705. getClassName(): string;
  112706. /**
  112707. * Makes a duplicate of the current material.
  112708. * @param name - name to use for the new material.
  112709. */
  112710. clone(name: string): PBRSpecularGlossinessMaterial;
  112711. /**
  112712. * Serialize the material to a parsable JSON object.
  112713. */
  112714. serialize(): any;
  112715. /**
  112716. * Parses a JSON object correponding to the serialize function.
  112717. */
  112718. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112719. }
  112720. }
  112721. declare module BABYLON {
  112722. /**
  112723. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112724. * It can help converting any input color in a desired output one. This can then be used to create effects
  112725. * from sepia, black and white to sixties or futuristic rendering...
  112726. *
  112727. * The only supported format is currently 3dl.
  112728. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112729. */
  112730. export class ColorGradingTexture extends BaseTexture {
  112731. /**
  112732. * The current texture matrix. (will always be identity in color grading texture)
  112733. */
  112734. private _textureMatrix;
  112735. /**
  112736. * The texture URL.
  112737. */
  112738. url: string;
  112739. /**
  112740. * Empty line regex stored for GC.
  112741. */
  112742. private static _noneEmptyLineRegex;
  112743. private _engine;
  112744. /**
  112745. * Instantiates a ColorGradingTexture from the following parameters.
  112746. *
  112747. * @param url The location of the color gradind data (currently only supporting 3dl)
  112748. * @param scene The scene the texture will be used in
  112749. */
  112750. constructor(url: string, scene: Scene);
  112751. /**
  112752. * Returns the texture matrix used in most of the material.
  112753. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112754. */
  112755. getTextureMatrix(): Matrix;
  112756. /**
  112757. * Occurs when the file being loaded is a .3dl LUT file.
  112758. */
  112759. private load3dlTexture;
  112760. /**
  112761. * Starts the loading process of the texture.
  112762. */
  112763. private loadTexture;
  112764. /**
  112765. * Clones the color gradind texture.
  112766. */
  112767. clone(): ColorGradingTexture;
  112768. /**
  112769. * Called during delayed load for textures.
  112770. */
  112771. delayLoad(): void;
  112772. /**
  112773. * Parses a color grading texture serialized by Babylon.
  112774. * @param parsedTexture The texture information being parsedTexture
  112775. * @param scene The scene to load the texture in
  112776. * @param rootUrl The root url of the data assets to load
  112777. * @return A color gradind texture
  112778. */
  112779. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112780. /**
  112781. * Serializes the LUT texture to json format.
  112782. */
  112783. serialize(): any;
  112784. }
  112785. }
  112786. declare module BABYLON {
  112787. /**
  112788. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112789. */
  112790. export class EquiRectangularCubeTexture extends BaseTexture {
  112791. /** The six faces of the cube. */
  112792. private static _FacesMapping;
  112793. private _noMipmap;
  112794. private _onLoad;
  112795. private _onError;
  112796. /** The size of the cubemap. */
  112797. private _size;
  112798. /** The buffer of the image. */
  112799. private _buffer;
  112800. /** The width of the input image. */
  112801. private _width;
  112802. /** The height of the input image. */
  112803. private _height;
  112804. /** The URL to the image. */
  112805. url: string;
  112806. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112807. coordinatesMode: number;
  112808. /**
  112809. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112810. * @param url The location of the image
  112811. * @param scene The scene the texture will be used in
  112812. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112813. * @param noMipmap Forces to not generate the mipmap if true
  112814. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112815. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112816. * @param onLoad — defines a callback called when texture is loaded
  112817. * @param onError — defines a callback called if there is an error
  112818. */
  112819. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112820. /**
  112821. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112822. */
  112823. private loadImage;
  112824. /**
  112825. * Convert the image buffer into a cubemap and create a CubeTexture.
  112826. */
  112827. private loadTexture;
  112828. /**
  112829. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112830. * @param buffer The ArrayBuffer that should be converted.
  112831. * @returns The buffer as Float32Array.
  112832. */
  112833. private getFloat32ArrayFromArrayBuffer;
  112834. /**
  112835. * Get the current class name of the texture useful for serialization or dynamic coding.
  112836. * @returns "EquiRectangularCubeTexture"
  112837. */
  112838. getClassName(): string;
  112839. /**
  112840. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112841. * @returns A clone of the current EquiRectangularCubeTexture.
  112842. */
  112843. clone(): EquiRectangularCubeTexture;
  112844. }
  112845. }
  112846. declare module BABYLON {
  112847. /**
  112848. * Based on jsTGALoader - Javascript loader for TGA file
  112849. * By Vincent Thibault
  112850. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112851. */
  112852. export class TGATools {
  112853. private static _TYPE_INDEXED;
  112854. private static _TYPE_RGB;
  112855. private static _TYPE_GREY;
  112856. private static _TYPE_RLE_INDEXED;
  112857. private static _TYPE_RLE_RGB;
  112858. private static _TYPE_RLE_GREY;
  112859. private static _ORIGIN_MASK;
  112860. private static _ORIGIN_SHIFT;
  112861. private static _ORIGIN_BL;
  112862. private static _ORIGIN_BR;
  112863. private static _ORIGIN_UL;
  112864. private static _ORIGIN_UR;
  112865. /**
  112866. * Gets the header of a TGA file
  112867. * @param data defines the TGA data
  112868. * @returns the header
  112869. */
  112870. static GetTGAHeader(data: Uint8Array): any;
  112871. /**
  112872. * Uploads TGA content to a Babylon Texture
  112873. * @hidden
  112874. */
  112875. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112876. /** @hidden */
  112877. 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;
  112878. /** @hidden */
  112879. 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;
  112880. /** @hidden */
  112881. 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;
  112882. /** @hidden */
  112883. 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;
  112884. /** @hidden */
  112885. 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;
  112886. /** @hidden */
  112887. 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;
  112888. }
  112889. }
  112890. declare module BABYLON {
  112891. /**
  112892. * Implementation of the TGA Texture Loader.
  112893. * @hidden
  112894. */
  112895. export class _TGATextureLoader implements IInternalTextureLoader {
  112896. /**
  112897. * Defines wether the loader supports cascade loading the different faces.
  112898. */
  112899. readonly supportCascades: boolean;
  112900. /**
  112901. * This returns if the loader support the current file information.
  112902. * @param extension defines the file extension of the file being loaded
  112903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112904. * @param fallback defines the fallback internal texture if any
  112905. * @param isBase64 defines whether the texture is encoded as a base64
  112906. * @param isBuffer defines whether the texture data are stored as a buffer
  112907. * @returns true if the loader can load the specified file
  112908. */
  112909. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112910. /**
  112911. * Transform the url before loading if required.
  112912. * @param rootUrl the url of the texture
  112913. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112914. * @returns the transformed texture
  112915. */
  112916. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112917. /**
  112918. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112919. * @param rootUrl the url of the texture
  112920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112921. * @returns the fallback texture
  112922. */
  112923. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112924. /**
  112925. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112926. * @param data contains the texture data
  112927. * @param texture defines the BabylonJS internal texture
  112928. * @param createPolynomials will be true if polynomials have been requested
  112929. * @param onLoad defines the callback to trigger once the texture is ready
  112930. * @param onError defines the callback to trigger in case of error
  112931. */
  112932. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112933. /**
  112934. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112935. * @param data contains the texture data
  112936. * @param texture defines the BabylonJS internal texture
  112937. * @param callback defines the method to call once ready to upload
  112938. */
  112939. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112940. }
  112941. }
  112942. declare module BABYLON {
  112943. /**
  112944. * Info about the .basis files
  112945. */
  112946. class BasisFileInfo {
  112947. /**
  112948. * If the file has alpha
  112949. */
  112950. hasAlpha: boolean;
  112951. /**
  112952. * Info about each image of the basis file
  112953. */
  112954. images: Array<{
  112955. levels: Array<{
  112956. width: number;
  112957. height: number;
  112958. transcodedPixels: ArrayBufferView;
  112959. }>;
  112960. }>;
  112961. }
  112962. /**
  112963. * Result of transcoding a basis file
  112964. */
  112965. class TranscodeResult {
  112966. /**
  112967. * Info about the .basis file
  112968. */
  112969. fileInfo: BasisFileInfo;
  112970. /**
  112971. * Format to use when loading the file
  112972. */
  112973. format: number;
  112974. }
  112975. /**
  112976. * Configuration options for the Basis transcoder
  112977. */
  112978. export class BasisTranscodeConfiguration {
  112979. /**
  112980. * Supported compression formats used to determine the supported output format of the transcoder
  112981. */
  112982. supportedCompressionFormats?: {
  112983. /**
  112984. * etc1 compression format
  112985. */
  112986. etc1?: boolean;
  112987. /**
  112988. * s3tc compression format
  112989. */
  112990. s3tc?: boolean;
  112991. /**
  112992. * pvrtc compression format
  112993. */
  112994. pvrtc?: boolean;
  112995. /**
  112996. * etc2 compression format
  112997. */
  112998. etc2?: boolean;
  112999. };
  113000. /**
  113001. * If mipmap levels should be loaded for transcoded images (Default: true)
  113002. */
  113003. loadMipmapLevels?: boolean;
  113004. /**
  113005. * Index of a single image to load (Default: all images)
  113006. */
  113007. loadSingleImage?: number;
  113008. }
  113009. /**
  113010. * Used to load .Basis files
  113011. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113012. */
  113013. export class BasisTools {
  113014. private static _IgnoreSupportedFormats;
  113015. /**
  113016. * URL to use when loading the basis transcoder
  113017. */
  113018. static JSModuleURL: string;
  113019. /**
  113020. * URL to use when loading the wasm module for the transcoder
  113021. */
  113022. static WasmModuleURL: string;
  113023. /**
  113024. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113025. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113026. * @returns internal format corresponding to the Basis format
  113027. */
  113028. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113029. private static _WorkerPromise;
  113030. private static _Worker;
  113031. private static _actionId;
  113032. private static _CreateWorkerAsync;
  113033. /**
  113034. * Transcodes a loaded image file to compressed pixel data
  113035. * @param imageData image data to transcode
  113036. * @param config configuration options for the transcoding
  113037. * @returns a promise resulting in the transcoded image
  113038. */
  113039. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113040. /**
  113041. * Loads a texture from the transcode result
  113042. * @param texture texture load to
  113043. * @param transcodeResult the result of transcoding the basis file to load from
  113044. */
  113045. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113046. }
  113047. }
  113048. declare module BABYLON {
  113049. /**
  113050. * Loader for .basis file format
  113051. */
  113052. export class _BasisTextureLoader implements IInternalTextureLoader {
  113053. /**
  113054. * Defines whether the loader supports cascade loading the different faces.
  113055. */
  113056. readonly supportCascades: boolean;
  113057. /**
  113058. * This returns if the loader support the current file information.
  113059. * @param extension defines the file extension of the file being loaded
  113060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113061. * @param fallback defines the fallback internal texture if any
  113062. * @param isBase64 defines whether the texture is encoded as a base64
  113063. * @param isBuffer defines whether the texture data are stored as a buffer
  113064. * @returns true if the loader can load the specified file
  113065. */
  113066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113067. /**
  113068. * Transform the url before loading if required.
  113069. * @param rootUrl the url of the texture
  113070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113071. * @returns the transformed texture
  113072. */
  113073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113074. /**
  113075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113076. * @param rootUrl the url of the texture
  113077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113078. * @returns the fallback texture
  113079. */
  113080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113081. /**
  113082. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113083. * @param data contains the texture data
  113084. * @param texture defines the BabylonJS internal texture
  113085. * @param createPolynomials will be true if polynomials have been requested
  113086. * @param onLoad defines the callback to trigger once the texture is ready
  113087. * @param onError defines the callback to trigger in case of error
  113088. */
  113089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113090. /**
  113091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113092. * @param data contains the texture data
  113093. * @param texture defines the BabylonJS internal texture
  113094. * @param callback defines the method to call once ready to upload
  113095. */
  113096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113097. }
  113098. }
  113099. declare module BABYLON {
  113100. /**
  113101. * 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.
  113102. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113103. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113104. */
  113105. export class CustomProceduralTexture extends ProceduralTexture {
  113106. private _animate;
  113107. private _time;
  113108. private _config;
  113109. private _texturePath;
  113110. /**
  113111. * Instantiates a new Custom Procedural Texture.
  113112. * 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.
  113113. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113115. * @param name Define the name of the texture
  113116. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113117. * @param size Define the size of the texture to create
  113118. * @param scene Define the scene the texture belongs to
  113119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113120. * @param generateMipMaps Define if the texture should creates mip maps or not
  113121. */
  113122. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113123. private _loadJson;
  113124. /**
  113125. * Is the texture ready to be used ? (rendered at least once)
  113126. * @returns true if ready, otherwise, false.
  113127. */
  113128. isReady(): boolean;
  113129. /**
  113130. * Render the texture to its associated render target.
  113131. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113132. */
  113133. render(useCameraPostProcess?: boolean): void;
  113134. /**
  113135. * Update the list of dependant textures samplers in the shader.
  113136. */
  113137. updateTextures(): void;
  113138. /**
  113139. * Update the uniform values of the procedural texture in the shader.
  113140. */
  113141. updateShaderUniforms(): void;
  113142. /**
  113143. * Define if the texture animates or not.
  113144. */
  113145. animate: boolean;
  113146. }
  113147. }
  113148. declare module BABYLON {
  113149. /** @hidden */
  113150. export var noisePixelShader: {
  113151. name: string;
  113152. shader: string;
  113153. };
  113154. }
  113155. declare module BABYLON {
  113156. /**
  113157. * Class used to generate noise procedural textures
  113158. */
  113159. export class NoiseProceduralTexture extends ProceduralTexture {
  113160. private _time;
  113161. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113162. brightness: number;
  113163. /** Defines the number of octaves to process */
  113164. octaves: number;
  113165. /** Defines the level of persistence (0.8 by default) */
  113166. persistence: number;
  113167. /** Gets or sets animation speed factor (default is 1) */
  113168. animationSpeedFactor: number;
  113169. /**
  113170. * Creates a new NoiseProceduralTexture
  113171. * @param name defines the name fo the texture
  113172. * @param size defines the size of the texture (default is 256)
  113173. * @param scene defines the hosting scene
  113174. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113175. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113176. */
  113177. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113178. private _updateShaderUniforms;
  113179. protected _getDefines(): string;
  113180. /** Generate the current state of the procedural texture */
  113181. render(useCameraPostProcess?: boolean): void;
  113182. /**
  113183. * Serializes this noise procedural texture
  113184. * @returns a serialized noise procedural texture object
  113185. */
  113186. serialize(): any;
  113187. /**
  113188. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113189. * @param parsedTexture defines parsed texture data
  113190. * @param scene defines the current scene
  113191. * @param rootUrl defines the root URL containing noise procedural texture information
  113192. * @returns a parsed NoiseProceduralTexture
  113193. */
  113194. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113195. }
  113196. }
  113197. declare module BABYLON {
  113198. /**
  113199. * Raw cube texture where the raw buffers are passed in
  113200. */
  113201. export class RawCubeTexture extends CubeTexture {
  113202. /**
  113203. * Creates a cube texture where the raw buffers are passed in.
  113204. * @param scene defines the scene the texture is attached to
  113205. * @param data defines the array of data to use to create each face
  113206. * @param size defines the size of the textures
  113207. * @param format defines the format of the data
  113208. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113209. * @param generateMipMaps defines if the engine should generate the mip levels
  113210. * @param invertY defines if data must be stored with Y axis inverted
  113211. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113212. * @param compression defines the compression used (null by default)
  113213. */
  113214. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113215. /**
  113216. * Updates the raw cube texture.
  113217. * @param data defines the data to store
  113218. * @param format defines the data format
  113219. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113220. * @param invertY defines if data must be stored with Y axis inverted
  113221. * @param compression defines the compression used (null by default)
  113222. * @param level defines which level of the texture to update
  113223. */
  113224. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113225. /**
  113226. * Updates a raw cube texture with RGBD encoded data.
  113227. * @param data defines the array of data [mipmap][face] to use to create each face
  113228. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113229. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113230. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113231. * @returns a promsie that resolves when the operation is complete
  113232. */
  113233. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113234. /**
  113235. * Clones the raw cube texture.
  113236. * @return a new cube texture
  113237. */
  113238. clone(): CubeTexture;
  113239. /** @hidden */
  113240. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113241. }
  113242. }
  113243. declare module BABYLON {
  113244. /**
  113245. * Class used to store 3D textures containing user data
  113246. */
  113247. export class RawTexture3D extends Texture {
  113248. /** Gets or sets the texture format to use */
  113249. format: number;
  113250. private _engine;
  113251. /**
  113252. * Create a new RawTexture3D
  113253. * @param data defines the data of the texture
  113254. * @param width defines the width of the texture
  113255. * @param height defines the height of the texture
  113256. * @param depth defines the depth of the texture
  113257. * @param format defines the texture format to use
  113258. * @param scene defines the hosting scene
  113259. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113260. * @param invertY defines if texture must be stored with Y axis inverted
  113261. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113262. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113263. */
  113264. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113265. /** Gets or sets the texture format to use */
  113266. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113267. /**
  113268. * Update the texture with new data
  113269. * @param data defines the data to store in the texture
  113270. */
  113271. update(data: ArrayBufferView): void;
  113272. }
  113273. }
  113274. declare module BABYLON {
  113275. /**
  113276. * Creates a refraction texture used by refraction channel of the standard material.
  113277. * It is like a mirror but to see through a material.
  113278. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113279. */
  113280. export class RefractionTexture extends RenderTargetTexture {
  113281. /**
  113282. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113283. * 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.
  113284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113285. */
  113286. refractionPlane: Plane;
  113287. /**
  113288. * Define how deep under the surface we should see.
  113289. */
  113290. depth: number;
  113291. /**
  113292. * Creates a refraction texture used by refraction channel of the standard material.
  113293. * It is like a mirror but to see through a material.
  113294. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113295. * @param name Define the texture name
  113296. * @param size Define the size of the underlying texture
  113297. * @param scene Define the scene the refraction belongs to
  113298. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113299. */
  113300. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113301. /**
  113302. * Clone the refraction texture.
  113303. * @returns the cloned texture
  113304. */
  113305. clone(): RefractionTexture;
  113306. /**
  113307. * Serialize the texture to a JSON representation you could use in Parse later on
  113308. * @returns the serialized JSON representation
  113309. */
  113310. serialize(): any;
  113311. }
  113312. }
  113313. declare module BABYLON {
  113314. /**
  113315. * Defines the options related to the creation of an HtmlElementTexture
  113316. */
  113317. export interface IHtmlElementTextureOptions {
  113318. /**
  113319. * Defines wether mip maps should be created or not.
  113320. */
  113321. generateMipMaps?: boolean;
  113322. /**
  113323. * Defines the sampling mode of the texture.
  113324. */
  113325. samplingMode?: number;
  113326. /**
  113327. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113328. */
  113329. engine: Nullable<Engine>;
  113330. /**
  113331. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113332. */
  113333. scene: Nullable<Scene>;
  113334. }
  113335. /**
  113336. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113337. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113338. * is automatically managed.
  113339. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113340. * in your application.
  113341. *
  113342. * As the update is not automatic, you need to call them manually.
  113343. */
  113344. export class HtmlElementTexture extends BaseTexture {
  113345. /**
  113346. * The texture URL.
  113347. */
  113348. element: HTMLVideoElement | HTMLCanvasElement;
  113349. private static readonly DefaultOptions;
  113350. private _textureMatrix;
  113351. private _engine;
  113352. private _isVideo;
  113353. private _generateMipMaps;
  113354. private _samplingMode;
  113355. /**
  113356. * Instantiates a HtmlElementTexture from the following parameters.
  113357. *
  113358. * @param name Defines the name of the texture
  113359. * @param element Defines the video or canvas the texture is filled with
  113360. * @param options Defines the other none mandatory texture creation options
  113361. */
  113362. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113363. private _createInternalTexture;
  113364. /**
  113365. * Returns the texture matrix used in most of the material.
  113366. */
  113367. getTextureMatrix(): Matrix;
  113368. /**
  113369. * Updates the content of the texture.
  113370. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113371. */
  113372. update(invertY?: Nullable<boolean>): void;
  113373. }
  113374. }
  113375. declare module BABYLON {
  113376. /**
  113377. * Enum used to define the target of a block
  113378. */
  113379. export enum NodeMaterialBlockTargets {
  113380. /** Vertex shader */
  113381. Vertex = 1,
  113382. /** Fragment shader */
  113383. Fragment = 2,
  113384. /** Vertex and Fragment */
  113385. VertexAndFragment = 3
  113386. }
  113387. }
  113388. declare module BABYLON {
  113389. /**
  113390. * Defines the kind of connection point for node based material
  113391. */
  113392. export enum NodeMaterialBlockConnectionPointTypes {
  113393. /** Float */
  113394. Float = 1,
  113395. /** Int */
  113396. Int = 2,
  113397. /** Vector2 */
  113398. Vector2 = 4,
  113399. /** Vector3 */
  113400. Vector3 = 8,
  113401. /** Vector4 */
  113402. Vector4 = 16,
  113403. /** Color3 */
  113404. Color3 = 32,
  113405. /** Color4 */
  113406. Color4 = 64,
  113407. /** Matrix */
  113408. Matrix = 128,
  113409. /** Texture */
  113410. Texture = 256,
  113411. /** Texture3D */
  113412. Texture3D = 512,
  113413. /** Vector3 or Color3 */
  113414. Vector3OrColor3 = 40,
  113415. /** Vector3 or Vector4 */
  113416. Vector3OrVector4 = 24,
  113417. /** Vector4 or Color4 */
  113418. Vector4OrColor4 = 80,
  113419. /** Color3 or Color4 */
  113420. Color3OrColor4 = 96,
  113421. /** Vector3 or Color3 */
  113422. Vector3OrColor3OrVector4OrColor4 = 120,
  113423. /** Detect type based on connection */
  113424. AutoDetect = 1024,
  113425. /** Output type that will be defined by input type */
  113426. BasedOnInput = 2048,
  113427. /** Light */
  113428. Light = 4096
  113429. }
  113430. }
  113431. declare module BABYLON {
  113432. /**
  113433. * Enum used to define well known values e.g. values automatically provided by the system
  113434. */
  113435. export enum NodeMaterialWellKnownValues {
  113436. /** World */
  113437. World = 1,
  113438. /** View */
  113439. View = 2,
  113440. /** Projection */
  113441. Projection = 3,
  113442. /** ViewProjection */
  113443. ViewProjection = 4,
  113444. /** WorldView */
  113445. WorldView = 5,
  113446. /** WorldViewProjection */
  113447. WorldViewProjection = 6,
  113448. /** CameraPosition */
  113449. CameraPosition = 7,
  113450. /** Will be filled by the block itself */
  113451. Automatic = 8
  113452. }
  113453. }
  113454. declare module BABYLON {
  113455. /**
  113456. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113457. */
  113458. export enum NodeMaterialBlockConnectionPointMode {
  113459. /** Value is an uniform */
  113460. Uniform = 0,
  113461. /** Value is a mesh attribute */
  113462. Attribute = 1,
  113463. /** Value is a varying between vertex and fragment shaders */
  113464. Varying = 2,
  113465. /** Mode is undefined */
  113466. Undefined = 3
  113467. }
  113468. }
  113469. declare module BABYLON {
  113470. /**
  113471. * Class used to store shared data between 2 NodeMaterialBuildState
  113472. */
  113473. export class NodeMaterialBuildStateSharedData {
  113474. /**
  113475. * Gets the list of emitted varyings
  113476. */
  113477. varyings: string[];
  113478. /**
  113479. * Gets the varying declaration string
  113480. */
  113481. varyingDeclaration: string;
  113482. /**
  113483. * Uniform connection points
  113484. */
  113485. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113486. /**
  113487. * Bindable blocks (Blocks that need to set data to the effect)
  113488. */
  113489. bindableBlocks: NodeMaterialBlock[];
  113490. /**
  113491. * List of blocks that can provide a compilation fallback
  113492. */
  113493. blocksWithFallbacks: NodeMaterialBlock[];
  113494. /**
  113495. * List of blocks that can provide a define update
  113496. */
  113497. blocksWithDefines: NodeMaterialBlock[];
  113498. /**
  113499. * List of blocks that can provide a repeatable content
  113500. */
  113501. repeatableContentBlocks: NodeMaterialBlock[];
  113502. /**
  113503. * List of blocks that can provide a dynamic list of uniforms
  113504. */
  113505. dynamicUniformBlocks: NodeMaterialBlock[];
  113506. /**
  113507. * List of blocks that can block the isReady function for the material
  113508. */
  113509. blockingBlocks: NodeMaterialBlock[];
  113510. /**
  113511. * Build Id used to avoid multiple recompilations
  113512. */
  113513. buildId: number;
  113514. /** List of emitted variables */
  113515. variableNames: {
  113516. [key: string]: number;
  113517. };
  113518. /** List of emitted defines */
  113519. defineNames: {
  113520. [key: string]: number;
  113521. };
  113522. /** Should emit comments? */
  113523. emitComments: boolean;
  113524. /** Emit build activity */
  113525. verbose: boolean;
  113526. /**
  113527. * Gets the compilation hints emitted at compilation time
  113528. */
  113529. hints: {
  113530. needWorldViewMatrix: boolean;
  113531. needWorldViewProjectionMatrix: boolean;
  113532. needAlphaBlending: boolean;
  113533. needAlphaTesting: boolean;
  113534. };
  113535. /**
  113536. * List of compilation checks
  113537. */
  113538. checks: {
  113539. emitVertex: boolean;
  113540. emitFragment: boolean;
  113541. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113542. };
  113543. /** Creates a new shared data */
  113544. constructor();
  113545. /**
  113546. * Emits console errors and exceptions if there is a failing check
  113547. */
  113548. emitErrors(): void;
  113549. }
  113550. }
  113551. declare module BABYLON {
  113552. /**
  113553. * Class used to store node based material build state
  113554. */
  113555. export class NodeMaterialBuildState {
  113556. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113557. supportUniformBuffers: boolean;
  113558. /**
  113559. * Gets the list of emitted attributes
  113560. */
  113561. attributes: string[];
  113562. /**
  113563. * Gets the list of emitted uniforms
  113564. */
  113565. uniforms: string[];
  113566. /**
  113567. * Gets the list of emitted uniform buffers
  113568. */
  113569. uniformBuffers: string[];
  113570. /**
  113571. * Gets the list of emitted samplers
  113572. */
  113573. samplers: string[];
  113574. /**
  113575. * Gets the list of emitted functions
  113576. */
  113577. functions: {
  113578. [key: string]: string;
  113579. };
  113580. /**
  113581. * Gets the target of the compilation state
  113582. */
  113583. target: NodeMaterialBlockTargets;
  113584. /**
  113585. * Gets the list of emitted counters
  113586. */
  113587. counters: {
  113588. [key: string]: number;
  113589. };
  113590. /**
  113591. * Shared data between multiple NodeMaterialBuildState instances
  113592. */
  113593. sharedData: NodeMaterialBuildStateSharedData;
  113594. /** @hidden */
  113595. _vertexState: NodeMaterialBuildState;
  113596. private _attributeDeclaration;
  113597. private _uniformDeclaration;
  113598. private _samplerDeclaration;
  113599. private _varyingTransfer;
  113600. private _repeatableContentAnchorIndex;
  113601. /** @hidden */
  113602. _builtCompilationString: string;
  113603. /**
  113604. * Gets the emitted compilation strings
  113605. */
  113606. compilationString: string;
  113607. /**
  113608. * Finalize the compilation strings
  113609. * @param state defines the current compilation state
  113610. */
  113611. finalize(state: NodeMaterialBuildState): void;
  113612. /** @hidden */
  113613. readonly _repeatableContentAnchor: string;
  113614. /** @hidden */
  113615. _getFreeVariableName(prefix: string): string;
  113616. /** @hidden */
  113617. _getFreeDefineName(prefix: string): string;
  113618. /** @hidden */
  113619. _excludeVariableName(name: string): void;
  113620. /** @hidden */
  113621. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113622. /** @hidden */
  113623. _emitFunction(name: string, code: string, comments: string): void;
  113624. /** @hidden */
  113625. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113626. replaceStrings?: {
  113627. search: RegExp;
  113628. replace: string;
  113629. }[];
  113630. repeatKey?: string;
  113631. }): string;
  113632. /** @hidden */
  113633. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113634. repeatKey?: string;
  113635. removeAttributes?: boolean;
  113636. removeUniforms?: boolean;
  113637. removeVaryings?: boolean;
  113638. removeIfDef?: boolean;
  113639. replaceStrings?: {
  113640. search: RegExp;
  113641. replace: string;
  113642. }[];
  113643. }, storeKey?: string): void;
  113644. /** @hidden */
  113645. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113646. private _emitDefine;
  113647. /** @hidden */
  113648. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113649. }
  113650. }
  113651. declare module BABYLON {
  113652. /**
  113653. * Root class for all node material optimizers
  113654. */
  113655. export class NodeMaterialOptimizer {
  113656. /**
  113657. * Function used to optimize a NodeMaterial graph
  113658. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113659. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113660. */
  113661. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113662. }
  113663. }
  113664. declare module BABYLON {
  113665. /**
  113666. * Block used to transform a vector4 with a matrix
  113667. */
  113668. export class Vector4TransformBlock extends NodeMaterialBlock {
  113669. /**
  113670. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113671. */
  113672. complementW: number;
  113673. /**
  113674. * Creates a new Vector4TransformBlock
  113675. * @param name defines the block name
  113676. */
  113677. constructor(name: string);
  113678. /**
  113679. * Gets the current class name
  113680. * @returns the class name
  113681. */
  113682. getClassName(): string;
  113683. /**
  113684. * Gets the vector input
  113685. */
  113686. readonly vector: NodeMaterialConnectionPoint;
  113687. /**
  113688. * Gets the output component
  113689. */
  113690. readonly output: NodeMaterialConnectionPoint;
  113691. /**
  113692. * Gets the matrix transform input
  113693. */
  113694. readonly transform: NodeMaterialConnectionPoint;
  113695. protected _buildBlock(state: NodeMaterialBuildState): this;
  113696. }
  113697. }
  113698. declare module BABYLON {
  113699. /**
  113700. * Block used to output the vertex position
  113701. */
  113702. export class VertexOutputBlock extends NodeMaterialBlock {
  113703. /**
  113704. * Creates a new VertexOutputBlock
  113705. * @param name defines the block name
  113706. */
  113707. constructor(name: string);
  113708. /**
  113709. * Gets the current class name
  113710. * @returns the class name
  113711. */
  113712. getClassName(): string;
  113713. /**
  113714. * Gets the vector input component
  113715. */
  113716. readonly vector: NodeMaterialConnectionPoint;
  113717. protected _buildBlock(state: NodeMaterialBuildState): this;
  113718. }
  113719. }
  113720. declare module BABYLON {
  113721. /**
  113722. * Block used to output the final color
  113723. */
  113724. export class FragmentOutputBlock extends NodeMaterialBlock {
  113725. /**
  113726. * Gets or sets a boolean indicating if this block will output an alpha value
  113727. */
  113728. alphaBlendingEnabled: boolean;
  113729. /**
  113730. * Create a new FragmentOutputBlock
  113731. * @param name defines the block name
  113732. */
  113733. constructor(name: string);
  113734. /**
  113735. * Gets the current class name
  113736. * @returns the class name
  113737. */
  113738. getClassName(): string;
  113739. /**
  113740. * Gets the color input component
  113741. */
  113742. readonly color: NodeMaterialConnectionPoint;
  113743. protected _buildBlock(state: NodeMaterialBuildState): this;
  113744. }
  113745. }
  113746. declare module BABYLON {
  113747. /**
  113748. * Interface used to configure the node material editor
  113749. */
  113750. export interface INodeMaterialEditorOptions {
  113751. /** Define the URl to load node editor script */
  113752. editorURL?: string;
  113753. }
  113754. /** @hidden */
  113755. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113756. /** BONES */
  113757. NUM_BONE_INFLUENCERS: number;
  113758. BonesPerMesh: number;
  113759. BONETEXTURE: boolean;
  113760. /** MORPH TARGETS */
  113761. MORPHTARGETS: boolean;
  113762. MORPHTARGETS_NORMAL: boolean;
  113763. MORPHTARGETS_TANGENT: boolean;
  113764. MORPHTARGETS_UV: boolean;
  113765. NUM_MORPH_INFLUENCERS: number;
  113766. /** IMAGE PROCESSING */
  113767. IMAGEPROCESSING: boolean;
  113768. VIGNETTE: boolean;
  113769. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113770. VIGNETTEBLENDMODEOPAQUE: boolean;
  113771. TONEMAPPING: boolean;
  113772. TONEMAPPING_ACES: boolean;
  113773. CONTRAST: boolean;
  113774. EXPOSURE: boolean;
  113775. COLORCURVES: boolean;
  113776. COLORGRADING: boolean;
  113777. COLORGRADING3D: boolean;
  113778. SAMPLER3DGREENDEPTH: boolean;
  113779. SAMPLER3DBGRMAP: boolean;
  113780. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113781. constructor();
  113782. setValue(name: string, value: boolean): void;
  113783. }
  113784. /**
  113785. * Class used to configure NodeMaterial
  113786. */
  113787. export interface INodeMaterialOptions {
  113788. /**
  113789. * Defines if blocks should emit comments
  113790. */
  113791. emitComments: boolean;
  113792. }
  113793. /**
  113794. * Class used to create a node based material built by assembling shader blocks
  113795. */
  113796. export class NodeMaterial extends PushMaterial {
  113797. private _options;
  113798. private _vertexCompilationState;
  113799. private _fragmentCompilationState;
  113800. private _sharedData;
  113801. private _buildId;
  113802. private _buildWasSuccessful;
  113803. private _cachedWorldViewMatrix;
  113804. private _cachedWorldViewProjectionMatrix;
  113805. private _textureConnectionPoints;
  113806. private _optimizers;
  113807. /** Define the URl to load node editor script */
  113808. static EditorURL: string;
  113809. private BJSNODEMATERIALEDITOR;
  113810. /** Get the inspector from bundle or global */
  113811. private _getGlobalNodeMaterialEditor;
  113812. /**
  113813. * Defines the maximum number of lights that can be used in the material
  113814. */
  113815. maxSimultaneousLights: number;
  113816. /**
  113817. * Observable raised when the material is built
  113818. */
  113819. onBuildObservable: Observable<NodeMaterial>;
  113820. /**
  113821. * Gets or sets the root nodes of the material vertex shader
  113822. */
  113823. _vertexOutputNodes: NodeMaterialBlock[];
  113824. /**
  113825. * Gets or sets the root nodes of the material fragment (pixel) shader
  113826. */
  113827. _fragmentOutputNodes: NodeMaterialBlock[];
  113828. /** Gets or sets options to control the node material overall behavior */
  113829. options: INodeMaterialOptions;
  113830. /**
  113831. * Default configuration related to image processing available in the standard Material.
  113832. */
  113833. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113834. /**
  113835. * Gets the image processing configuration used either in this material.
  113836. */
  113837. /**
  113838. * Sets the Default image processing configuration used either in the this material.
  113839. *
  113840. * If sets to null, the scene one is in use.
  113841. */
  113842. imageProcessingConfiguration: ImageProcessingConfiguration;
  113843. /**
  113844. * Create a new node based material
  113845. * @param name defines the material name
  113846. * @param scene defines the hosting scene
  113847. * @param options defines creation option
  113848. */
  113849. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113850. /**
  113851. * Gets the current class name of the material e.g. "NodeMaterial"
  113852. * @returns the class name
  113853. */
  113854. getClassName(): string;
  113855. /**
  113856. * Keep track of the image processing observer to allow dispose and replace.
  113857. */
  113858. private _imageProcessingObserver;
  113859. /**
  113860. * Attaches a new image processing configuration to the Standard Material.
  113861. * @param configuration
  113862. */
  113863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113864. /**
  113865. * Adds a new optimizer to the list of optimizers
  113866. * @param optimizer defines the optimizers to add
  113867. * @returns the current material
  113868. */
  113869. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113870. /**
  113871. * Remove an optimizer from the list of optimizers
  113872. * @param optimizer defines the optimizers to remove
  113873. * @returns the current material
  113874. */
  113875. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113876. /**
  113877. * Add a new block to the list of output nodes
  113878. * @param node defines the node to add
  113879. * @returns the current material
  113880. */
  113881. addOutputNode(node: NodeMaterialBlock): this;
  113882. /**
  113883. * Remove a block from the list of root nodes
  113884. * @param node defines the node to remove
  113885. * @returns the current material
  113886. */
  113887. removeOutputNode(node: NodeMaterialBlock): this;
  113888. private _addVertexOutputNode;
  113889. private _removeVertexOutputNode;
  113890. private _addFragmentOutputNode;
  113891. private _removeFragmentOutputNode;
  113892. /**
  113893. * Specifies if the material will require alpha blending
  113894. * @returns a boolean specifying if alpha blending is needed
  113895. */
  113896. needAlphaBlending(): boolean;
  113897. /**
  113898. * Specifies if this material should be rendered in alpha test mode
  113899. * @returns a boolean specifying if an alpha test is needed.
  113900. */
  113901. needAlphaTesting(): boolean;
  113902. private _initializeBlock;
  113903. private _resetDualBlocks;
  113904. /**
  113905. * Build the material and generates the inner effect
  113906. * @param verbose defines if the build should log activity
  113907. */
  113908. build(verbose?: boolean): void;
  113909. /**
  113910. * Runs an otpimization phase to try to improve the shader code
  113911. */
  113912. optimize(): void;
  113913. private _prepareDefinesForAttributes;
  113914. /**
  113915. * Get if the submesh is ready to be used and all its information available.
  113916. * Child classes can use it to update shaders
  113917. * @param mesh defines the mesh to check
  113918. * @param subMesh defines which submesh to check
  113919. * @param useInstances specifies that instances should be used
  113920. * @returns a boolean indicating that the submesh is ready or not
  113921. */
  113922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113923. /**
  113924. * Binds the world matrix to the material
  113925. * @param world defines the world transformation matrix
  113926. */
  113927. bindOnlyWorldMatrix(world: Matrix): void;
  113928. /**
  113929. * Binds the submesh to this material by preparing the effect and shader to draw
  113930. * @param world defines the world transformation matrix
  113931. * @param mesh defines the mesh containing the submesh
  113932. * @param subMesh defines the submesh to bind the material to
  113933. */
  113934. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113935. /**
  113936. * Gets the active textures from the material
  113937. * @returns an array of textures
  113938. */
  113939. getActiveTextures(): BaseTexture[];
  113940. /**
  113941. * Specifies if the material uses a texture
  113942. * @param texture defines the texture to check against the material
  113943. * @returns a boolean specifying if the material uses the texture
  113944. */
  113945. hasTexture(texture: BaseTexture): boolean;
  113946. /**
  113947. * Disposes the material
  113948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113950. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113951. */
  113952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113953. /** Creates the node editor window. */
  113954. private _createNodeEditor;
  113955. /**
  113956. * Launch the node material editor
  113957. * @param config Define the configuration of the editor
  113958. * @return a promise fulfilled when the node editor is visible
  113959. */
  113960. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113961. /**
  113962. * Clear the current material
  113963. */
  113964. clear(): void;
  113965. /**
  113966. * Clear the current material and set it to a default state
  113967. */
  113968. setToDefault(): void;
  113969. }
  113970. }
  113971. declare module BABYLON {
  113972. /**
  113973. * Defines a block that can be used inside a node based material
  113974. */
  113975. export class NodeMaterialBlock {
  113976. private _buildId;
  113977. private _target;
  113978. private _isFinalMerger;
  113979. /** @hidden */
  113980. _inputs: NodeMaterialConnectionPoint[];
  113981. /** @hidden */
  113982. _outputs: NodeMaterialConnectionPoint[];
  113983. /**
  113984. * Gets or sets the name of the block
  113985. */
  113986. name: string;
  113987. /**
  113988. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113989. */
  113990. readonly isFinalMerger: boolean;
  113991. /**
  113992. * Gets or sets the build Id
  113993. */
  113994. buildId: number;
  113995. /**
  113996. * Gets or sets the target of the block
  113997. */
  113998. target: NodeMaterialBlockTargets;
  113999. /**
  114000. * Gets the list of input points
  114001. */
  114002. readonly inputs: NodeMaterialConnectionPoint[];
  114003. /** Gets the list of output points */
  114004. readonly outputs: NodeMaterialConnectionPoint[];
  114005. /**
  114006. * Find an input by its name
  114007. * @param name defines the name of the input to look for
  114008. * @returns the input or null if not found
  114009. */
  114010. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114011. /**
  114012. * Find an output by its name
  114013. * @param name defines the name of the outputto look for
  114014. * @returns the output or null if not found
  114015. */
  114016. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114017. /**
  114018. * Creates a new NodeMaterialBlock
  114019. * @param name defines the block name
  114020. * @param target defines the target of that block (Vertex by default)
  114021. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114022. */
  114023. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  114024. /**
  114025. * Initialize the block and prepare the context for build
  114026. * @param state defines the state that will be used for the build
  114027. */
  114028. initialize(state: NodeMaterialBuildState): void;
  114029. /**
  114030. * Bind data to effect. Will only be called for blocks with isBindable === true
  114031. * @param effect defines the effect to bind data to
  114032. * @param nodeMaterial defines the hosting NodeMaterial
  114033. * @param mesh defines the mesh that will be rendered
  114034. */
  114035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114036. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114037. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114038. protected _writeFloat(value: number): string;
  114039. /**
  114040. * Gets the current class name e.g. "NodeMaterialBlock"
  114041. * @returns the class name
  114042. */
  114043. getClassName(): string;
  114044. /**
  114045. * Register a new input. Must be called inside a block constructor
  114046. * @param name defines the connection point name
  114047. * @param type defines the connection point type
  114048. * @param isOptional defines a boolean indicating that this input can be omitted
  114049. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114050. * @returns the current block
  114051. */
  114052. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114053. /**
  114054. * Register a new output. Must be called inside a block constructor
  114055. * @param name defines the connection point name
  114056. * @param type defines the connection point type
  114057. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114058. * @returns the current block
  114059. */
  114060. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114061. /**
  114062. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114063. * @param forOutput defines an optional connection point to check compatibility with
  114064. * @returns the first available input or null
  114065. */
  114066. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114067. /**
  114068. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114069. * @param forBlock defines an optional block to check compatibility with
  114070. * @returns the first available input or null
  114071. */
  114072. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114073. /**
  114074. * Connect current block with another block
  114075. * @param other defines the block to connect with
  114076. * @param options define the various options to help pick the right connections
  114077. * @returns the current block
  114078. */
  114079. connectTo(other: NodeMaterialBlock, options?: {
  114080. input?: string;
  114081. output?: string;
  114082. outputSwizzle?: string;
  114083. }): this | undefined;
  114084. protected _buildBlock(state: NodeMaterialBuildState): void;
  114085. /**
  114086. * Add uniforms, samplers and uniform buffers at compilation time
  114087. * @param state defines the state to update
  114088. * @param nodeMaterial defines the node material requesting the update
  114089. * @param defines defines the material defines to update
  114090. */
  114091. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114092. /**
  114093. * Add potential fallbacks if shader compilation fails
  114094. * @param mesh defines the mesh to be rendered
  114095. * @param fallbacks defines the current prioritized list of fallbacks
  114096. */
  114097. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114098. /**
  114099. * Update defines for shader compilation
  114100. * @param mesh defines the mesh to be rendered
  114101. * @param nodeMaterial defines the node material requesting the update
  114102. * @param defines defines the material defines to update
  114103. * @param useInstances specifies that instances should be used
  114104. */
  114105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114106. /**
  114107. * Lets the block try to connect some inputs automatically
  114108. */
  114109. autoConfigure(): void;
  114110. /**
  114111. * Function called when a block is declared as repeatable content generator
  114112. * @param vertexShaderState defines the current compilation state for the vertex shader
  114113. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114114. * @param mesh defines the mesh to be rendered
  114115. * @param defines defines the material defines to update
  114116. */
  114117. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114118. /**
  114119. * Checks if the block is ready
  114120. * @param mesh defines the mesh to be rendered
  114121. * @param nodeMaterial defines the node material requesting the update
  114122. * @param defines defines the material defines to update
  114123. * @param useInstances specifies that instances should be used
  114124. * @returns true if the block is ready
  114125. */
  114126. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114127. /**
  114128. * Compile the current node and generate the shader code
  114129. * @param state defines the current compilation state (uniforms, samplers, current string)
  114130. * @returns the current block
  114131. */
  114132. build(state: NodeMaterialBuildState): this | undefined;
  114133. }
  114134. }
  114135. declare module BABYLON {
  114136. /**
  114137. * Defines a connection point for a block
  114138. */
  114139. export class NodeMaterialConnectionPoint {
  114140. /** @hidden */
  114141. _ownerBlock: NodeMaterialBlock;
  114142. /** @hidden */
  114143. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114144. private _associatedVariableName;
  114145. private _endpoints;
  114146. private _storedValue;
  114147. private _valueCallback;
  114148. private _mode;
  114149. /** @hidden */
  114150. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114151. /** @hidden */
  114152. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114153. /** @hidden */
  114154. _needToEmitVarying: boolean;
  114155. /** @hidden */
  114156. _forceUniformInVertexShaderOnly: boolean;
  114157. private _type;
  114158. /**
  114159. * Gets or sets the connection point type (default is float)
  114160. */
  114161. type: NodeMaterialBlockConnectionPointTypes;
  114162. /**
  114163. * Gets or sets the connection point name
  114164. */
  114165. name: string;
  114166. /**
  114167. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114168. */
  114169. swizzle: string;
  114170. /**
  114171. * Gets or sets a boolean indicating that this connection point can be omitted
  114172. */
  114173. isOptional: boolean;
  114174. /**
  114175. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114176. */
  114177. define: string;
  114178. /** Gets or sets the target of that connection point */
  114179. target: NodeMaterialBlockTargets;
  114180. /**
  114181. * Gets or sets the value of that point.
  114182. * Please note that this value will be ignored if valueCallback is defined
  114183. */
  114184. value: any;
  114185. /**
  114186. * Gets or sets a callback used to get the value of that point.
  114187. * Please note that setting this value will force the connection point to ignore the value property
  114188. */
  114189. valueCallback: () => any;
  114190. /**
  114191. * Gets or sets the associated variable name in the shader
  114192. */
  114193. associatedVariableName: string;
  114194. /**
  114195. * Gets a boolean indicating that this connection point not defined yet
  114196. */
  114197. readonly isUndefined: boolean;
  114198. /**
  114199. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114200. * In this case the connection point name must be the name of the uniform to use.
  114201. * Can only be set on inputs
  114202. */
  114203. isUniform: boolean;
  114204. /**
  114205. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114206. * In this case the connection point name must be the name of the attribute to use
  114207. * Can only be set on inputs
  114208. */
  114209. isAttribute: boolean;
  114210. /**
  114211. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114212. * Can only be set on exit points
  114213. */
  114214. isVarying: boolean;
  114215. /** Get the other side of the connection (if any) */
  114216. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114217. /** Get the block that owns this connection point */
  114218. readonly ownerBlock: NodeMaterialBlock;
  114219. /** Get the block connected on the other side of this connection (if any) */
  114220. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114221. /** Get the block connected on the endpoints of this connection (if any) */
  114222. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114223. /**
  114224. * Creates a new connection point
  114225. * @param name defines the connection point name
  114226. * @param ownerBlock defines the block hosting this connection point
  114227. */
  114228. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114229. /**
  114230. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114231. * @returns the class name
  114232. */
  114233. getClassName(): string;
  114234. /**
  114235. * Set the source of this connection point to a vertex attribute
  114236. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114237. * @returns the current connection point
  114238. */
  114239. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114240. /**
  114241. * Set the source of this connection point to a well known value
  114242. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114243. * @returns the current connection point
  114244. */
  114245. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114246. /**
  114247. * Gets a boolean indicating that the current connection point is a well known value
  114248. */
  114249. readonly isWellKnownValue: boolean;
  114250. /**
  114251. * Gets or sets the current well known value or null if not defined as well know value
  114252. */
  114253. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114254. private _getTypeLength;
  114255. /**
  114256. * Gets an boolean indicating if the current point can be connected to another point
  114257. * @param connectionPoint defines the other connection point
  114258. * @returns true if the connection is possible
  114259. */
  114260. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114261. /**
  114262. * Connect this point to another connection point
  114263. * @param connectionPoint defines the other connection point
  114264. * @returns the current connection point
  114265. */
  114266. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114267. /**
  114268. * Disconnect this point from one of his endpoint
  114269. * @param endpoint defines the other connection point
  114270. * @returns the current connection point
  114271. */
  114272. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114273. /**
  114274. * When connection point is an uniform, this function will send its value to the effect
  114275. * @param effect defines the effect to transmit value to
  114276. * @param world defines the world matrix
  114277. * @param worldView defines the worldxview matrix
  114278. * @param worldViewProjection defines the worldxviewxprojection matrix
  114279. */
  114280. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114281. /**
  114282. * When connection point is an uniform, this function will send its value to the effect
  114283. * @param effect defines the effect to transmit value to
  114284. * @param scene defines the hosting scene
  114285. */
  114286. transmit(effect: Effect, scene: Scene): void;
  114287. }
  114288. }
  114289. declare module BABYLON {
  114290. /**
  114291. * Block used to add support for vertex skinning (bones)
  114292. */
  114293. export class BonesBlock extends NodeMaterialBlock {
  114294. /**
  114295. * Creates a new BonesBlock
  114296. * @param name defines the block name
  114297. */
  114298. constructor(name: string);
  114299. /**
  114300. * Initialize the block and prepare the context for build
  114301. * @param state defines the state that will be used for the build
  114302. */
  114303. initialize(state: NodeMaterialBuildState): void;
  114304. /**
  114305. * Gets the current class name
  114306. * @returns the class name
  114307. */
  114308. getClassName(): string;
  114309. /**
  114310. * Gets the matrix indices input component
  114311. */
  114312. readonly matricesIndices: NodeMaterialConnectionPoint;
  114313. /**
  114314. * Gets the matrix weights input component
  114315. */
  114316. readonly matricesWeights: NodeMaterialConnectionPoint;
  114317. /**
  114318. * Gets the extra matrix indices input component
  114319. */
  114320. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114321. /**
  114322. * Gets the extra matrix weights input component
  114323. */
  114324. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114325. /**
  114326. * Gets the world input component
  114327. */
  114328. readonly world: NodeMaterialConnectionPoint;
  114329. /**
  114330. * Gets the output component
  114331. */
  114332. readonly output: NodeMaterialConnectionPoint;
  114333. autoConfigure(): void;
  114334. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114337. protected _buildBlock(state: NodeMaterialBuildState): this;
  114338. }
  114339. }
  114340. declare module BABYLON {
  114341. /**
  114342. * Block used to add support for instances
  114343. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114344. */
  114345. export class InstancesBlock extends NodeMaterialBlock {
  114346. /**
  114347. * Creates a new InstancesBlock
  114348. * @param name defines the block name
  114349. */
  114350. constructor(name: string);
  114351. /**
  114352. * Gets the current class name
  114353. * @returns the class name
  114354. */
  114355. getClassName(): string;
  114356. /**
  114357. * Gets the first world row input component
  114358. */
  114359. readonly world0: NodeMaterialConnectionPoint;
  114360. /**
  114361. * Gets the second world row input component
  114362. */
  114363. readonly world1: NodeMaterialConnectionPoint;
  114364. /**
  114365. * Gets the third world row input component
  114366. */
  114367. readonly world2: NodeMaterialConnectionPoint;
  114368. /**
  114369. * Gets the forth world row input component
  114370. */
  114371. readonly world3: NodeMaterialConnectionPoint;
  114372. /**
  114373. * Gets the world input component
  114374. */
  114375. readonly world: NodeMaterialConnectionPoint;
  114376. /**
  114377. * Gets the output component
  114378. */
  114379. readonly output: NodeMaterialConnectionPoint;
  114380. autoConfigure(): void;
  114381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114382. protected _buildBlock(state: NodeMaterialBuildState): this;
  114383. }
  114384. }
  114385. declare module BABYLON {
  114386. /**
  114387. * Block used to add morph targets support to vertex shader
  114388. */
  114389. export class MorphTargetsBlock extends NodeMaterialBlock {
  114390. private _repeatableContentAnchor;
  114391. private _repeatebleContentGenerated;
  114392. /**
  114393. * Create a new MorphTargetsBlock
  114394. * @param name defines the block name
  114395. */
  114396. constructor(name: string);
  114397. /**
  114398. * Gets the current class name
  114399. * @returns the class name
  114400. */
  114401. getClassName(): string;
  114402. /**
  114403. * Gets the position input component
  114404. */
  114405. readonly position: NodeMaterialConnectionPoint;
  114406. /**
  114407. * Gets the normal input component
  114408. */
  114409. readonly normal: NodeMaterialConnectionPoint;
  114410. /**
  114411. * Gets the tangent input component
  114412. */
  114413. readonly tangent: NodeMaterialConnectionPoint;
  114414. /**
  114415. * Gets the tangent input component
  114416. */
  114417. readonly uv: NodeMaterialConnectionPoint;
  114418. /**
  114419. * Gets the position output component
  114420. */
  114421. readonly positionOutput: NodeMaterialConnectionPoint;
  114422. /**
  114423. * Gets the normal output component
  114424. */
  114425. readonly normalOutput: NodeMaterialConnectionPoint;
  114426. /**
  114427. * Gets the tangent output component
  114428. */
  114429. readonly tangentOutput: NodeMaterialConnectionPoint;
  114430. /**
  114431. * Gets the tangent output component
  114432. */
  114433. readonly uvOutput: NodeMaterialConnectionPoint;
  114434. initialize(state: NodeMaterialBuildState): void;
  114435. autoConfigure(): void;
  114436. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114437. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114438. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114439. protected _buildBlock(state: NodeMaterialBuildState): this;
  114440. }
  114441. }
  114442. declare module BABYLON {
  114443. /**
  114444. * Block used to add an alpha test in the fragment shader
  114445. */
  114446. export class AlphaTestBlock extends NodeMaterialBlock {
  114447. /**
  114448. * Gets or sets the alpha value where alpha testing happens
  114449. */
  114450. alphaCutOff: number;
  114451. /**
  114452. * Create a new AlphaTestBlock
  114453. * @param name defines the block name
  114454. */
  114455. constructor(name: string);
  114456. /**
  114457. * Gets the current class name
  114458. * @returns the class name
  114459. */
  114460. getClassName(): string;
  114461. /**
  114462. * Gets the color input component
  114463. */
  114464. readonly color: NodeMaterialConnectionPoint;
  114465. protected _buildBlock(state: NodeMaterialBuildState): this;
  114466. }
  114467. }
  114468. declare module BABYLON {
  114469. /**
  114470. * Block used to create a Color4 out of 4 inputs (one for each component)
  114471. */
  114472. export class RGBAMergerBlock extends NodeMaterialBlock {
  114473. /**
  114474. * Create a new RGBAMergerBlock
  114475. * @param name defines the block name
  114476. */
  114477. constructor(name: string);
  114478. /**
  114479. * Gets the current class name
  114480. * @returns the class name
  114481. */
  114482. getClassName(): string;
  114483. /**
  114484. * Gets the R input component
  114485. */
  114486. readonly r: NodeMaterialConnectionPoint;
  114487. /**
  114488. * Gets the G input component
  114489. */
  114490. readonly g: NodeMaterialConnectionPoint;
  114491. /**
  114492. * Gets the B input component
  114493. */
  114494. readonly b: NodeMaterialConnectionPoint;
  114495. /**
  114496. * Gets the RGB input component
  114497. */
  114498. readonly rgb: NodeMaterialConnectionPoint;
  114499. /**
  114500. * Gets the R input component
  114501. */
  114502. readonly a: NodeMaterialConnectionPoint;
  114503. /**
  114504. * Gets the output component
  114505. */
  114506. readonly output: NodeMaterialConnectionPoint;
  114507. protected _buildBlock(state: NodeMaterialBuildState): this;
  114508. }
  114509. }
  114510. declare module BABYLON {
  114511. /**
  114512. * Block used to create a Color3 out of 3 inputs (one for each component)
  114513. */
  114514. export class RGBMergerBlock extends NodeMaterialBlock {
  114515. /**
  114516. * Create a new RGBMergerBlock
  114517. * @param name defines the block name
  114518. */
  114519. constructor(name: string);
  114520. /**
  114521. * Gets the current class name
  114522. * @returns the class name
  114523. */
  114524. getClassName(): string;
  114525. /**
  114526. * Gets the R component input
  114527. */
  114528. readonly r: NodeMaterialConnectionPoint;
  114529. /**
  114530. * Gets the G component input
  114531. */
  114532. readonly g: NodeMaterialConnectionPoint;
  114533. /**
  114534. * Gets the B component input
  114535. */
  114536. readonly b: NodeMaterialConnectionPoint;
  114537. /**
  114538. * Gets the output component
  114539. */
  114540. readonly output: NodeMaterialConnectionPoint;
  114541. protected _buildBlock(state: NodeMaterialBuildState): this;
  114542. }
  114543. }
  114544. declare module BABYLON {
  114545. /**
  114546. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114547. */
  114548. export class RGBASplitterBlock extends NodeMaterialBlock {
  114549. /**
  114550. * Create a new RGBASplitterBlock
  114551. * @param name defines the block name
  114552. */
  114553. constructor(name: string);
  114554. /**
  114555. * Gets the current class name
  114556. * @returns the class name
  114557. */
  114558. getClassName(): string;
  114559. /**
  114560. * Gets the input component
  114561. */
  114562. readonly input: NodeMaterialConnectionPoint;
  114563. protected _buildBlock(state: NodeMaterialBuildState): this;
  114564. }
  114565. }
  114566. declare module BABYLON {
  114567. /**
  114568. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114569. */
  114570. export class RGBSplitterBlock extends NodeMaterialBlock {
  114571. /**
  114572. * Create a new RGBSplitterBlock
  114573. * @param name defines the block name
  114574. */
  114575. constructor(name: string);
  114576. /**
  114577. * Gets the current class name
  114578. * @returns the class name
  114579. */
  114580. getClassName(): string;
  114581. /**
  114582. * Gets the input component
  114583. */
  114584. readonly input: NodeMaterialConnectionPoint;
  114585. protected _buildBlock(state: NodeMaterialBuildState): this;
  114586. }
  114587. }
  114588. declare module BABYLON {
  114589. /**
  114590. * Block used to read a texture from a sampler
  114591. */
  114592. export class TextureBlock extends NodeMaterialBlock {
  114593. private _defineName;
  114594. /**
  114595. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114596. */
  114597. autoConnectTextureMatrix: boolean;
  114598. /**
  114599. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114600. */
  114601. autoSelectUV: boolean;
  114602. /**
  114603. * Create a new TextureBlock
  114604. * @param name defines the block name
  114605. */
  114606. constructor(name: string);
  114607. /**
  114608. * Gets the current class name
  114609. * @returns the class name
  114610. */
  114611. getClassName(): string;
  114612. /**
  114613. * Gets the uv input component
  114614. */
  114615. readonly uv: NodeMaterialConnectionPoint;
  114616. /**
  114617. * Gets the texture information input component
  114618. */
  114619. readonly textureInfo: NodeMaterialConnectionPoint;
  114620. /**
  114621. * Gets the transformed uv input component
  114622. */
  114623. readonly transformedUV: NodeMaterialConnectionPoint;
  114624. /**
  114625. * Gets the texture input component
  114626. */
  114627. readonly texture: NodeMaterialConnectionPoint;
  114628. /**
  114629. * Gets the texture transform input component
  114630. */
  114631. readonly textureTransform: NodeMaterialConnectionPoint;
  114632. /**
  114633. * Gets the output component
  114634. */
  114635. readonly output: NodeMaterialConnectionPoint;
  114636. autoConfigure(): void;
  114637. initialize(state: NodeMaterialBuildState): void;
  114638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114639. isReady(): boolean;
  114640. private _injectVertexCode;
  114641. protected _buildBlock(state: NodeMaterialBuildState): this;
  114642. }
  114643. }
  114644. declare module BABYLON {
  114645. /**
  114646. * Block used to add image processing support to fragment shader
  114647. */
  114648. export class ImageProcessingBlock extends NodeMaterialBlock {
  114649. /**
  114650. * Create a new ImageProcessingBlock
  114651. * @param name defines the block name
  114652. */
  114653. constructor(name: string);
  114654. /**
  114655. * Gets the current class name
  114656. * @returns the class name
  114657. */
  114658. getClassName(): string;
  114659. /**
  114660. * Gets the color input component
  114661. */
  114662. readonly color: NodeMaterialConnectionPoint;
  114663. /**
  114664. * Gets the output component
  114665. */
  114666. readonly output: NodeMaterialConnectionPoint;
  114667. /**
  114668. * Initialize the block and prepare the context for build
  114669. * @param state defines the state that will be used for the build
  114670. */
  114671. initialize(state: NodeMaterialBuildState): void;
  114672. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114675. protected _buildBlock(state: NodeMaterialBuildState): this;
  114676. }
  114677. }
  114678. declare module BABYLON {
  114679. /**
  114680. * Block used to add support for scene fog
  114681. */
  114682. export class FogBlock extends NodeMaterialBlock {
  114683. /**
  114684. * Create a new FogBlock
  114685. * @param name defines the block name
  114686. */
  114687. constructor(name: string);
  114688. /**
  114689. * Gets the current class name
  114690. * @returns the class name
  114691. */
  114692. getClassName(): string;
  114693. /**
  114694. * Gets the world position input component
  114695. */
  114696. readonly worldPosition: NodeMaterialConnectionPoint;
  114697. /**
  114698. * Gets the view input component
  114699. */
  114700. readonly view: NodeMaterialConnectionPoint;
  114701. /**
  114702. * Gets the color input component
  114703. */
  114704. readonly color: NodeMaterialConnectionPoint;
  114705. /**
  114706. * Gets the fog color input component
  114707. */
  114708. readonly fogColor: NodeMaterialConnectionPoint;
  114709. /**
  114710. * Gets the for parameter input component
  114711. */
  114712. readonly fogParameters: NodeMaterialConnectionPoint;
  114713. /**
  114714. * Gets the output component
  114715. */
  114716. readonly output: NodeMaterialConnectionPoint;
  114717. autoConfigure(): void;
  114718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114720. protected _buildBlock(state: NodeMaterialBuildState): this;
  114721. }
  114722. }
  114723. declare module BABYLON {
  114724. /**
  114725. * Block used to add light in the fragment shader
  114726. */
  114727. export class LightBlock extends NodeMaterialBlock {
  114728. private _lightId;
  114729. /**
  114730. * Create a new LightBlock
  114731. * @param name defines the block name
  114732. */
  114733. constructor(name: string);
  114734. /**
  114735. * Gets the current class name
  114736. * @returns the class name
  114737. */
  114738. getClassName(): string;
  114739. /**
  114740. * Gets the world position input component
  114741. */
  114742. readonly worldPosition: NodeMaterialConnectionPoint;
  114743. /**
  114744. * Gets the world normal input component
  114745. */
  114746. readonly worldNormal: NodeMaterialConnectionPoint;
  114747. /**
  114748. * Gets the light input component.
  114749. * If not defined, all lights will be considered
  114750. */
  114751. readonly light: NodeMaterialConnectionPoint;
  114752. /**
  114753. * Gets the camera (or eye) position component
  114754. */
  114755. readonly cameraPosition: NodeMaterialConnectionPoint;
  114756. /**
  114757. * Gets the diffuse output component
  114758. */
  114759. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114760. /**
  114761. * Gets the specular output component
  114762. */
  114763. readonly specularOutput: NodeMaterialConnectionPoint;
  114764. autoConfigure(): void;
  114765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114766. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114768. private _injectVertexCode;
  114769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114770. }
  114771. }
  114772. declare module BABYLON {
  114773. /**
  114774. * Block used to multiply 2 values
  114775. */
  114776. export class MultiplyBlock extends NodeMaterialBlock {
  114777. /**
  114778. * Creates a new MultiplyBlock
  114779. * @param name defines the block name
  114780. */
  114781. constructor(name: string);
  114782. /**
  114783. * Gets the current class name
  114784. * @returns the class name
  114785. */
  114786. getClassName(): string;
  114787. /**
  114788. * Gets the left operand input component
  114789. */
  114790. readonly left: NodeMaterialConnectionPoint;
  114791. /**
  114792. * Gets the right operand input component
  114793. */
  114794. readonly right: NodeMaterialConnectionPoint;
  114795. /**
  114796. * Gets the output component
  114797. */
  114798. readonly output: NodeMaterialConnectionPoint;
  114799. protected _buildBlock(state: NodeMaterialBuildState): this;
  114800. }
  114801. }
  114802. declare module BABYLON {
  114803. /**
  114804. * Block used to add 2 vector4
  114805. */
  114806. export class AddBlock extends NodeMaterialBlock {
  114807. /**
  114808. * Creates a new AddBlock
  114809. * @param name defines the block name
  114810. */
  114811. constructor(name: string);
  114812. /**
  114813. * Gets the current class name
  114814. * @returns the class name
  114815. */
  114816. getClassName(): string;
  114817. /**
  114818. * Gets the left operand input component
  114819. */
  114820. readonly left: NodeMaterialConnectionPoint;
  114821. /**
  114822. * Gets the right operand input component
  114823. */
  114824. readonly right: NodeMaterialConnectionPoint;
  114825. /**
  114826. * Gets the output component
  114827. */
  114828. readonly output: NodeMaterialConnectionPoint;
  114829. protected _buildBlock(state: NodeMaterialBuildState): this;
  114830. }
  114831. }
  114832. declare module BABYLON {
  114833. /**
  114834. * Block used to clamp a float
  114835. */
  114836. export class ClampBlock extends NodeMaterialBlock {
  114837. /** Gets or sets the minimum range */
  114838. minimum: number;
  114839. /** Gets or sets the maximum range */
  114840. maximum: number;
  114841. /**
  114842. * Creates a new ClampBlock
  114843. * @param name defines the block name
  114844. */
  114845. constructor(name: string);
  114846. /**
  114847. * Gets the current class name
  114848. * @returns the class name
  114849. */
  114850. getClassName(): string;
  114851. /**
  114852. * Gets the value input component
  114853. */
  114854. readonly value: NodeMaterialConnectionPoint;
  114855. /**
  114856. * Gets the output component
  114857. */
  114858. readonly output: NodeMaterialConnectionPoint;
  114859. protected _buildBlock(state: NodeMaterialBuildState): this;
  114860. }
  114861. }
  114862. declare module BABYLON {
  114863. /**
  114864. * Block used to transform a vector2 with a matrix
  114865. */
  114866. export class Vector2TransformBlock extends NodeMaterialBlock {
  114867. /**
  114868. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114869. */
  114870. complementZ: number;
  114871. /**
  114872. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114873. */
  114874. complementW: number;
  114875. /**
  114876. * Creates a new Vector2TransformBlock
  114877. * @param name defines the block name
  114878. */
  114879. constructor(name: string);
  114880. /**
  114881. * Gets the vector input
  114882. */
  114883. readonly vector: NodeMaterialConnectionPoint;
  114884. /**
  114885. * Gets the matrix transform input
  114886. */
  114887. readonly transform: NodeMaterialConnectionPoint;
  114888. /**
  114889. * Gets the output component
  114890. */
  114891. readonly output: NodeMaterialConnectionPoint;
  114892. /**
  114893. * Gets the current class name
  114894. * @returns the class name
  114895. */
  114896. getClassName(): string;
  114897. protected _buildBlock(state: NodeMaterialBuildState): this;
  114898. }
  114899. }
  114900. declare module BABYLON {
  114901. /**
  114902. * Block used to transform a vector3 with a matrix
  114903. */
  114904. export class Vector3TransformBlock extends NodeMaterialBlock {
  114905. /**
  114906. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114907. */
  114908. complement: number;
  114909. /**
  114910. * Creates a new Vector3TransformBlock
  114911. * @param name defines the block name
  114912. */
  114913. constructor(name: string);
  114914. /**
  114915. * Gets the vector input
  114916. */
  114917. readonly vector: NodeMaterialConnectionPoint;
  114918. /**
  114919. * Gets the matrix transform input
  114920. */
  114921. readonly transform: NodeMaterialConnectionPoint;
  114922. /**
  114923. * Gets the output component
  114924. */
  114925. readonly output: NodeMaterialConnectionPoint;
  114926. /**
  114927. * Gets the current class name
  114928. * @returns the class name
  114929. */
  114930. getClassName(): string;
  114931. protected _buildBlock(state: NodeMaterialBuildState): this;
  114932. }
  114933. }
  114934. declare module BABYLON {
  114935. /**
  114936. * Helper class to render one or more effects
  114937. */
  114938. export class EffectRenderer {
  114939. private engine;
  114940. private static _Vertices;
  114941. private static _Indices;
  114942. private _vertexBuffers;
  114943. private _indexBuffer;
  114944. private _ringBufferIndex;
  114945. private _ringScreenBuffer;
  114946. private _getNextFrameBuffer;
  114947. /**
  114948. * Creates an effect renderer
  114949. * @param engine the engine to use for rendering
  114950. */
  114951. constructor(engine: Engine);
  114952. /**
  114953. * renders one or more effects to a specified texture
  114954. * @param effectWrappers list of effects to renderer
  114955. * @param outputTexture texture to draw to, if null it will render to the screen
  114956. */
  114957. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  114958. /**
  114959. * Disposes of the effect renderer
  114960. */
  114961. dispose(): void;
  114962. }
  114963. /**
  114964. * Options to create an EffectWrapper
  114965. */
  114966. interface EffectWrapperCreationOptions {
  114967. /**
  114968. * Engine to use to create the effect
  114969. */
  114970. engine: Engine;
  114971. /**
  114972. * Fragment shader for the effect
  114973. */
  114974. fragmentShader: string;
  114975. /**
  114976. * Attributes to use in the shader
  114977. */
  114978. attributeNames: Array<string>;
  114979. /**
  114980. * Uniforms to use in the shader
  114981. */
  114982. uniformNames: Array<string>;
  114983. /**
  114984. * Texture sampler names to use in the shader
  114985. */
  114986. samplerNames: Array<string>;
  114987. }
  114988. /**
  114989. * Wraps an effect to be used for rendering
  114990. */
  114991. export class EffectWrapper {
  114992. /**
  114993. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  114994. */
  114995. onApplyObservable: Observable<{}>;
  114996. /**
  114997. * The underlying effect
  114998. */
  114999. effect: Effect;
  115000. /**
  115001. * Creates an effect to be renderer
  115002. * @param creationOptions options to create the effect
  115003. */
  115004. constructor(creationOptions: EffectWrapperCreationOptions);
  115005. /**
  115006. * Disposes of the effect wrapper
  115007. */
  115008. dispose(): void;
  115009. }
  115010. }
  115011. declare module BABYLON {
  115012. /**
  115013. * Helper class to push actions to a pool of workers.
  115014. */
  115015. export class WorkerPool implements IDisposable {
  115016. private _workerInfos;
  115017. private _pendingActions;
  115018. /**
  115019. * Constructor
  115020. * @param workers Array of workers to use for actions
  115021. */
  115022. constructor(workers: Array<Worker>);
  115023. /**
  115024. * Terminates all workers and clears any pending actions.
  115025. */
  115026. dispose(): void;
  115027. /**
  115028. * Pushes an action to the worker pool. If all the workers are active, the action will be
  115029. * pended until a worker has completed its action.
  115030. * @param action The action to perform. Call onComplete when the action is complete.
  115031. */
  115032. push(action: (worker: Worker, onComplete: () => void) => void): void;
  115033. private _execute;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Configuration for Draco compression
  115039. */
  115040. export interface IDracoCompressionConfiguration {
  115041. /**
  115042. * Configuration for the decoder.
  115043. */
  115044. decoder: {
  115045. /**
  115046. * The url to the WebAssembly module.
  115047. */
  115048. wasmUrl?: string;
  115049. /**
  115050. * The url to the WebAssembly binary.
  115051. */
  115052. wasmBinaryUrl?: string;
  115053. /**
  115054. * The url to the fallback JavaScript module.
  115055. */
  115056. fallbackUrl?: string;
  115057. };
  115058. }
  115059. /**
  115060. * Draco compression (https://google.github.io/draco/)
  115061. *
  115062. * This class wraps the Draco module.
  115063. *
  115064. * **Encoder**
  115065. *
  115066. * The encoder is not currently implemented.
  115067. *
  115068. * **Decoder**
  115069. *
  115070. * 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.
  115071. *
  115072. * To update the configuration, use the following code:
  115073. * ```javascript
  115074. * DracoCompression.Configuration = {
  115075. * decoder: {
  115076. * wasmUrl: "<url to the WebAssembly library>",
  115077. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115078. * fallbackUrl: "<url to the fallback JavaScript library>",
  115079. * }
  115080. * };
  115081. * ```
  115082. *
  115083. * 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.
  115084. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115085. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115086. *
  115087. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115088. * ```javascript
  115089. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115090. * ```
  115091. *
  115092. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115093. */
  115094. export class DracoCompression implements IDisposable {
  115095. private _workerPoolPromise?;
  115096. private _decoderModulePromise?;
  115097. /**
  115098. * The configuration. Defaults to the following urls:
  115099. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115100. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115101. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115102. */
  115103. static Configuration: IDracoCompressionConfiguration;
  115104. /**
  115105. * Returns true if the decoder configuration is available.
  115106. */
  115107. static readonly DecoderAvailable: boolean;
  115108. /**
  115109. * Default number of workers to create when creating the draco compression object.
  115110. */
  115111. static DefaultNumWorkers: number;
  115112. private static GetDefaultNumWorkers;
  115113. private static _Default;
  115114. /**
  115115. * Default instance for the draco compression object.
  115116. */
  115117. static readonly Default: DracoCompression;
  115118. /**
  115119. * Constructor
  115120. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115121. */
  115122. constructor(numWorkers?: number);
  115123. /**
  115124. * Stop all async operations and release resources.
  115125. */
  115126. dispose(): void;
  115127. /**
  115128. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115129. * @returns a promise that resolves when ready
  115130. */
  115131. whenReadyAsync(): Promise<void>;
  115132. /**
  115133. * Decode Draco compressed mesh data to vertex data.
  115134. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115135. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115136. * @returns A promise that resolves with the decoded vertex data
  115137. */
  115138. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115139. [kind: string]: number;
  115140. }): Promise<VertexData>;
  115141. }
  115142. }
  115143. declare module BABYLON {
  115144. /**
  115145. * Class for building Constructive Solid Geometry
  115146. */
  115147. export class CSG {
  115148. private polygons;
  115149. /**
  115150. * The world matrix
  115151. */
  115152. matrix: Matrix;
  115153. /**
  115154. * Stores the position
  115155. */
  115156. position: Vector3;
  115157. /**
  115158. * Stores the rotation
  115159. */
  115160. rotation: Vector3;
  115161. /**
  115162. * Stores the rotation quaternion
  115163. */
  115164. rotationQuaternion: Nullable<Quaternion>;
  115165. /**
  115166. * Stores the scaling vector
  115167. */
  115168. scaling: Vector3;
  115169. /**
  115170. * Convert the Mesh to CSG
  115171. * @param mesh The Mesh to convert to CSG
  115172. * @returns A new CSG from the Mesh
  115173. */
  115174. static FromMesh(mesh: Mesh): CSG;
  115175. /**
  115176. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115177. * @param polygons Polygons used to construct a CSG solid
  115178. */
  115179. private static FromPolygons;
  115180. /**
  115181. * Clones, or makes a deep copy, of the CSG
  115182. * @returns A new CSG
  115183. */
  115184. clone(): CSG;
  115185. /**
  115186. * Unions this CSG with another CSG
  115187. * @param csg The CSG to union against this CSG
  115188. * @returns The unioned CSG
  115189. */
  115190. union(csg: CSG): CSG;
  115191. /**
  115192. * Unions this CSG with another CSG in place
  115193. * @param csg The CSG to union against this CSG
  115194. */
  115195. unionInPlace(csg: CSG): void;
  115196. /**
  115197. * Subtracts this CSG with another CSG
  115198. * @param csg The CSG to subtract against this CSG
  115199. * @returns A new CSG
  115200. */
  115201. subtract(csg: CSG): CSG;
  115202. /**
  115203. * Subtracts this CSG with another CSG in place
  115204. * @param csg The CSG to subtact against this CSG
  115205. */
  115206. subtractInPlace(csg: CSG): void;
  115207. /**
  115208. * Intersect this CSG with another CSG
  115209. * @param csg The CSG to intersect against this CSG
  115210. * @returns A new CSG
  115211. */
  115212. intersect(csg: CSG): CSG;
  115213. /**
  115214. * Intersects this CSG with another CSG in place
  115215. * @param csg The CSG to intersect against this CSG
  115216. */
  115217. intersectInPlace(csg: CSG): void;
  115218. /**
  115219. * Return a new CSG solid with solid and empty space switched. This solid is
  115220. * not modified.
  115221. * @returns A new CSG solid with solid and empty space switched
  115222. */
  115223. inverse(): CSG;
  115224. /**
  115225. * Inverses the CSG in place
  115226. */
  115227. inverseInPlace(): void;
  115228. /**
  115229. * This is used to keep meshes transformations so they can be restored
  115230. * when we build back a Babylon Mesh
  115231. * NB : All CSG operations are performed in world coordinates
  115232. * @param csg The CSG to copy the transform attributes from
  115233. * @returns This CSG
  115234. */
  115235. copyTransformAttributes(csg: CSG): CSG;
  115236. /**
  115237. * Build Raw mesh from CSG
  115238. * Coordinates here are in world space
  115239. * @param name The name of the mesh geometry
  115240. * @param scene The Scene
  115241. * @param keepSubMeshes Specifies if the submeshes should be kept
  115242. * @returns A new Mesh
  115243. */
  115244. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115245. /**
  115246. * Build Mesh from CSG taking material and transforms into account
  115247. * @param name The name of the Mesh
  115248. * @param material The material of the Mesh
  115249. * @param scene The Scene
  115250. * @param keepSubMeshes Specifies if submeshes should be kept
  115251. * @returns The new Mesh
  115252. */
  115253. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115254. }
  115255. }
  115256. declare module BABYLON {
  115257. /**
  115258. * Class used to create a trail following a mesh
  115259. */
  115260. export class TrailMesh extends Mesh {
  115261. private _generator;
  115262. private _autoStart;
  115263. private _running;
  115264. private _diameter;
  115265. private _length;
  115266. private _sectionPolygonPointsCount;
  115267. private _sectionVectors;
  115268. private _sectionNormalVectors;
  115269. private _beforeRenderObserver;
  115270. /**
  115271. * @constructor
  115272. * @param name The value used by scene.getMeshByName() to do a lookup.
  115273. * @param generator The mesh to generate a trail.
  115274. * @param scene The scene to add this mesh to.
  115275. * @param diameter Diameter of trailing mesh. Default is 1.
  115276. * @param length Length of trailing mesh. Default is 60.
  115277. * @param autoStart Automatically start trailing mesh. Default true.
  115278. */
  115279. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115280. /**
  115281. * "TrailMesh"
  115282. * @returns "TrailMesh"
  115283. */
  115284. getClassName(): string;
  115285. private _createMesh;
  115286. /**
  115287. * Start trailing mesh.
  115288. */
  115289. start(): void;
  115290. /**
  115291. * Stop trailing mesh.
  115292. */
  115293. stop(): void;
  115294. /**
  115295. * Update trailing mesh geometry.
  115296. */
  115297. update(): void;
  115298. /**
  115299. * Returns a new TrailMesh object.
  115300. * @param name is a string, the name given to the new mesh
  115301. * @param newGenerator use new generator object for cloned trail mesh
  115302. * @returns a new mesh
  115303. */
  115304. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115305. /**
  115306. * Serializes this trail mesh
  115307. * @param serializationObject object to write serialization to
  115308. */
  115309. serialize(serializationObject: any): void;
  115310. /**
  115311. * Parses a serialized trail mesh
  115312. * @param parsedMesh the serialized mesh
  115313. * @param scene the scene to create the trail mesh in
  115314. * @returns the created trail mesh
  115315. */
  115316. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115317. }
  115318. }
  115319. declare module BABYLON {
  115320. /**
  115321. * Class containing static functions to help procedurally build meshes
  115322. */
  115323. export class TiledBoxBuilder {
  115324. /**
  115325. * Creates a box mesh
  115326. * 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)
  115327. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115331. * @param name defines the name of the mesh
  115332. * @param options defines the options used to create the mesh
  115333. * @param scene defines the hosting scene
  115334. * @returns the box mesh
  115335. */
  115336. static CreateTiledBox(name: string, options: {
  115337. pattern?: number;
  115338. width?: number;
  115339. height?: number;
  115340. depth?: number;
  115341. tileSize?: number;
  115342. tileWidth?: number;
  115343. tileHeight?: number;
  115344. alignHorizontal?: number;
  115345. alignVertical?: number;
  115346. faceUV?: Vector4[];
  115347. faceColors?: Color4[];
  115348. sideOrientation?: number;
  115349. updatable?: boolean;
  115350. }, scene?: Nullable<Scene>): Mesh;
  115351. }
  115352. }
  115353. declare module BABYLON {
  115354. /**
  115355. * Class containing static functions to help procedurally build meshes
  115356. */
  115357. export class TorusKnotBuilder {
  115358. /**
  115359. * Creates a torus knot mesh
  115360. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115361. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115362. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115363. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115367. * @param name defines the name of the mesh
  115368. * @param options defines the options used to create the mesh
  115369. * @param scene defines the hosting scene
  115370. * @returns the torus knot mesh
  115371. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115372. */
  115373. static CreateTorusKnot(name: string, options: {
  115374. radius?: number;
  115375. tube?: number;
  115376. radialSegments?: number;
  115377. tubularSegments?: number;
  115378. p?: number;
  115379. q?: number;
  115380. updatable?: boolean;
  115381. sideOrientation?: number;
  115382. frontUVs?: Vector4;
  115383. backUVs?: Vector4;
  115384. }, scene: any): Mesh;
  115385. }
  115386. }
  115387. declare module BABYLON {
  115388. /**
  115389. * Polygon
  115390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115391. */
  115392. export class Polygon {
  115393. /**
  115394. * Creates a rectangle
  115395. * @param xmin bottom X coord
  115396. * @param ymin bottom Y coord
  115397. * @param xmax top X coord
  115398. * @param ymax top Y coord
  115399. * @returns points that make the resulting rectation
  115400. */
  115401. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115402. /**
  115403. * Creates a circle
  115404. * @param radius radius of circle
  115405. * @param cx scale in x
  115406. * @param cy scale in y
  115407. * @param numberOfSides number of sides that make up the circle
  115408. * @returns points that make the resulting circle
  115409. */
  115410. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115411. /**
  115412. * Creates a polygon from input string
  115413. * @param input Input polygon data
  115414. * @returns the parsed points
  115415. */
  115416. static Parse(input: string): Vector2[];
  115417. /**
  115418. * Starts building a polygon from x and y coordinates
  115419. * @param x x coordinate
  115420. * @param y y coordinate
  115421. * @returns the started path2
  115422. */
  115423. static StartingAt(x: number, y: number): Path2;
  115424. }
  115425. /**
  115426. * Builds a polygon
  115427. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115428. */
  115429. export class PolygonMeshBuilder {
  115430. private _points;
  115431. private _outlinepoints;
  115432. private _holes;
  115433. private _name;
  115434. private _scene;
  115435. private _epoints;
  115436. private _eholes;
  115437. private _addToepoint;
  115438. /**
  115439. * Babylon reference to the earcut plugin.
  115440. */
  115441. bjsEarcut: any;
  115442. /**
  115443. * Creates a PolygonMeshBuilder
  115444. * @param name name of the builder
  115445. * @param contours Path of the polygon
  115446. * @param scene scene to add to when creating the mesh
  115447. * @param earcutInjection can be used to inject your own earcut reference
  115448. */
  115449. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115450. /**
  115451. * Adds a whole within the polygon
  115452. * @param hole Array of points defining the hole
  115453. * @returns this
  115454. */
  115455. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115456. /**
  115457. * Creates the polygon
  115458. * @param updatable If the mesh should be updatable
  115459. * @param depth The depth of the mesh created
  115460. * @returns the created mesh
  115461. */
  115462. build(updatable?: boolean, depth?: number): Mesh;
  115463. /**
  115464. * Creates the polygon
  115465. * @param depth The depth of the mesh created
  115466. * @returns the created VertexData
  115467. */
  115468. buildVertexData(depth?: number): VertexData;
  115469. /**
  115470. * Adds a side to the polygon
  115471. * @param positions points that make the polygon
  115472. * @param normals normals of the polygon
  115473. * @param uvs uvs of the polygon
  115474. * @param indices indices of the polygon
  115475. * @param bounds bounds of the polygon
  115476. * @param points points of the polygon
  115477. * @param depth depth of the polygon
  115478. * @param flip flip of the polygon
  115479. */
  115480. private addSide;
  115481. }
  115482. }
  115483. declare module BABYLON {
  115484. /**
  115485. * Class containing static functions to help procedurally build meshes
  115486. */
  115487. export class PolygonBuilder {
  115488. /**
  115489. * Creates a polygon mesh
  115490. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115491. * * 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
  115492. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115495. * * Remember you can only change the shape positions, not their number when updating a polygon
  115496. * @param name defines the name of the mesh
  115497. * @param options defines the options used to create the mesh
  115498. * @param scene defines the hosting scene
  115499. * @param earcutInjection can be used to inject your own earcut reference
  115500. * @returns the polygon mesh
  115501. */
  115502. static CreatePolygon(name: string, options: {
  115503. shape: Vector3[];
  115504. holes?: Vector3[][];
  115505. depth?: number;
  115506. faceUV?: Vector4[];
  115507. faceColors?: Color4[];
  115508. updatable?: boolean;
  115509. sideOrientation?: number;
  115510. frontUVs?: Vector4;
  115511. backUVs?: Vector4;
  115512. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115513. /**
  115514. * Creates an extruded polygon mesh, with depth in the Y direction.
  115515. * * 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)
  115516. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115517. * @param name defines the name of the mesh
  115518. * @param options defines the options used to create the mesh
  115519. * @param scene defines the hosting scene
  115520. * @param earcutInjection can be used to inject your own earcut reference
  115521. * @returns the polygon mesh
  115522. */
  115523. static ExtrudePolygon(name: string, options: {
  115524. shape: Vector3[];
  115525. holes?: Vector3[][];
  115526. depth?: number;
  115527. faceUV?: Vector4[];
  115528. faceColors?: Color4[];
  115529. updatable?: boolean;
  115530. sideOrientation?: number;
  115531. frontUVs?: Vector4;
  115532. backUVs?: Vector4;
  115533. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115534. }
  115535. }
  115536. declare module BABYLON {
  115537. /**
  115538. * Class containing static functions to help procedurally build meshes
  115539. */
  115540. export class LatheBuilder {
  115541. /**
  115542. * Creates lathe mesh.
  115543. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115544. * * 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
  115545. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115546. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115547. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115548. * * 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
  115549. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115550. * * 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
  115551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115555. * @param name defines the name of the mesh
  115556. * @param options defines the options used to create the mesh
  115557. * @param scene defines the hosting scene
  115558. * @returns the lathe mesh
  115559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115560. */
  115561. static CreateLathe(name: string, options: {
  115562. shape: Vector3[];
  115563. radius?: number;
  115564. tessellation?: number;
  115565. clip?: number;
  115566. arc?: number;
  115567. closed?: boolean;
  115568. updatable?: boolean;
  115569. sideOrientation?: number;
  115570. frontUVs?: Vector4;
  115571. backUVs?: Vector4;
  115572. cap?: number;
  115573. invertUV?: boolean;
  115574. }, scene?: Nullable<Scene>): Mesh;
  115575. }
  115576. }
  115577. declare module BABYLON {
  115578. /**
  115579. * Class containing static functions to help procedurally build meshes
  115580. */
  115581. export class TiledPlaneBuilder {
  115582. /**
  115583. * Creates a tiled plane mesh
  115584. * * The parameter `pattern` will, depending on value, do nothing or
  115585. * * * flip (reflect about central vertical) alternate tiles across and up
  115586. * * * flip every tile on alternate rows
  115587. * * * rotate (180 degs) alternate tiles across and up
  115588. * * * rotate every tile on alternate rows
  115589. * * * flip and rotate alternate tiles across and up
  115590. * * * flip and rotate every tile on alternate rows
  115591. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115592. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115595. * * 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)
  115596. * * 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)
  115597. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115598. * @param name defines the name of the mesh
  115599. * @param options defines the options used to create the mesh
  115600. * @param scene defines the hosting scene
  115601. * @returns the box mesh
  115602. */
  115603. static CreateTiledPlane(name: string, options: {
  115604. pattern?: number;
  115605. tileSize?: number;
  115606. tileWidth?: number;
  115607. tileHeight?: number;
  115608. size?: number;
  115609. width?: number;
  115610. height?: number;
  115611. alignHorizontal?: number;
  115612. alignVertical?: number;
  115613. sideOrientation?: number;
  115614. frontUVs?: Vector4;
  115615. backUVs?: Vector4;
  115616. updatable?: boolean;
  115617. }, scene?: Nullable<Scene>): Mesh;
  115618. }
  115619. }
  115620. declare module BABYLON {
  115621. /**
  115622. * Class containing static functions to help procedurally build meshes
  115623. */
  115624. export class TubeBuilder {
  115625. /**
  115626. * Creates a tube mesh.
  115627. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115628. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115629. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115630. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115631. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115632. * * 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)
  115633. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115634. * * 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
  115635. * * 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
  115636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115640. * @param name defines the name of the mesh
  115641. * @param options defines the options used to create the mesh
  115642. * @param scene defines the hosting scene
  115643. * @returns the tube mesh
  115644. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115645. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115646. */
  115647. static CreateTube(name: string, options: {
  115648. path: Vector3[];
  115649. radius?: number;
  115650. tessellation?: number;
  115651. radiusFunction?: {
  115652. (i: number, distance: number): number;
  115653. };
  115654. cap?: number;
  115655. arc?: number;
  115656. updatable?: boolean;
  115657. sideOrientation?: number;
  115658. frontUVs?: Vector4;
  115659. backUVs?: Vector4;
  115660. instance?: Mesh;
  115661. invertUV?: boolean;
  115662. }, scene?: Nullable<Scene>): Mesh;
  115663. }
  115664. }
  115665. declare module BABYLON {
  115666. /**
  115667. * Class containing static functions to help procedurally build meshes
  115668. */
  115669. export class IcoSphereBuilder {
  115670. /**
  115671. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115672. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115673. * * 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`)
  115674. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115675. * * 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
  115676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115679. * @param name defines the name of the mesh
  115680. * @param options defines the options used to create the mesh
  115681. * @param scene defines the hosting scene
  115682. * @returns the icosahedron mesh
  115683. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115684. */
  115685. static CreateIcoSphere(name: string, options: {
  115686. radius?: number;
  115687. radiusX?: number;
  115688. radiusY?: number;
  115689. radiusZ?: number;
  115690. flat?: boolean;
  115691. subdivisions?: number;
  115692. sideOrientation?: number;
  115693. frontUVs?: Vector4;
  115694. backUVs?: Vector4;
  115695. updatable?: boolean;
  115696. }, scene?: Nullable<Scene>): Mesh;
  115697. }
  115698. }
  115699. declare module BABYLON {
  115700. /**
  115701. * Class containing static functions to help procedurally build meshes
  115702. */
  115703. export class DecalBuilder {
  115704. /**
  115705. * Creates a decal mesh.
  115706. * 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
  115707. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115708. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115709. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115710. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115711. * @param name defines the name of the mesh
  115712. * @param sourceMesh defines the mesh where the decal must be applied
  115713. * @param options defines the options used to create the mesh
  115714. * @param scene defines the hosting scene
  115715. * @returns the decal mesh
  115716. * @see https://doc.babylonjs.com/how_to/decals
  115717. */
  115718. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115719. position?: Vector3;
  115720. normal?: Vector3;
  115721. size?: Vector3;
  115722. angle?: number;
  115723. }): Mesh;
  115724. }
  115725. }
  115726. declare module BABYLON {
  115727. /**
  115728. * Class containing static functions to help procedurally build meshes
  115729. */
  115730. export class MeshBuilder {
  115731. /**
  115732. * Creates a box mesh
  115733. * * The parameter `size` sets the size (float) of each box side (default 1)
  115734. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115735. * * 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)
  115736. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115740. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115741. * @param name defines the name of the mesh
  115742. * @param options defines the options used to create the mesh
  115743. * @param scene defines the hosting scene
  115744. * @returns the box mesh
  115745. */
  115746. static CreateBox(name: string, options: {
  115747. size?: number;
  115748. width?: number;
  115749. height?: number;
  115750. depth?: number;
  115751. faceUV?: Vector4[];
  115752. faceColors?: Color4[];
  115753. sideOrientation?: number;
  115754. frontUVs?: Vector4;
  115755. backUVs?: Vector4;
  115756. updatable?: boolean;
  115757. }, scene?: Nullable<Scene>): Mesh;
  115758. /**
  115759. * Creates a tiled box mesh
  115760. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115762. * @param name defines the name of the mesh
  115763. * @param options defines the options used to create the mesh
  115764. * @param scene defines the hosting scene
  115765. * @returns the tiled box mesh
  115766. */
  115767. static CreateTiledBox(name: string, options: {
  115768. pattern?: number;
  115769. size?: number;
  115770. width?: number;
  115771. height?: number;
  115772. depth: number;
  115773. tileSize?: number;
  115774. tileWidth?: number;
  115775. tileHeight?: number;
  115776. faceUV?: Vector4[];
  115777. faceColors?: Color4[];
  115778. alignHorizontal?: number;
  115779. alignVertical?: number;
  115780. sideOrientation?: number;
  115781. updatable?: boolean;
  115782. }, scene?: Nullable<Scene>): Mesh;
  115783. /**
  115784. * Creates a sphere mesh
  115785. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115786. * * 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`)
  115787. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115788. * * 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
  115789. * * 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)
  115790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115793. * @param name defines the name of the mesh
  115794. * @param options defines the options used to create the mesh
  115795. * @param scene defines the hosting scene
  115796. * @returns the sphere mesh
  115797. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115798. */
  115799. static CreateSphere(name: string, options: {
  115800. segments?: number;
  115801. diameter?: number;
  115802. diameterX?: number;
  115803. diameterY?: number;
  115804. diameterZ?: number;
  115805. arc?: number;
  115806. slice?: number;
  115807. sideOrientation?: number;
  115808. frontUVs?: Vector4;
  115809. backUVs?: Vector4;
  115810. updatable?: boolean;
  115811. }, scene?: Nullable<Scene>): Mesh;
  115812. /**
  115813. * Creates a plane polygonal mesh. By default, this is a disc
  115814. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115815. * * 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
  115816. * * 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
  115817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115820. * @param name defines the name of the mesh
  115821. * @param options defines the options used to create the mesh
  115822. * @param scene defines the hosting scene
  115823. * @returns the plane polygonal mesh
  115824. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115825. */
  115826. static CreateDisc(name: string, options: {
  115827. radius?: number;
  115828. tessellation?: number;
  115829. arc?: number;
  115830. updatable?: boolean;
  115831. sideOrientation?: number;
  115832. frontUVs?: Vector4;
  115833. backUVs?: Vector4;
  115834. }, scene?: Nullable<Scene>): Mesh;
  115835. /**
  115836. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115837. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115838. * * 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`)
  115839. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115840. * * 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
  115841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115844. * @param name defines the name of the mesh
  115845. * @param options defines the options used to create the mesh
  115846. * @param scene defines the hosting scene
  115847. * @returns the icosahedron mesh
  115848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115849. */
  115850. static CreateIcoSphere(name: string, options: {
  115851. radius?: number;
  115852. radiusX?: number;
  115853. radiusY?: number;
  115854. radiusZ?: number;
  115855. flat?: boolean;
  115856. subdivisions?: number;
  115857. sideOrientation?: number;
  115858. frontUVs?: Vector4;
  115859. backUVs?: Vector4;
  115860. updatable?: boolean;
  115861. }, scene?: Nullable<Scene>): Mesh;
  115862. /**
  115863. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115864. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115865. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115866. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115867. * * 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
  115868. * * 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
  115869. * * 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
  115870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115873. * * 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
  115874. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115875. * * 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
  115876. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115878. * @param name defines the name of the mesh
  115879. * @param options defines the options used to create the mesh
  115880. * @param scene defines the hosting scene
  115881. * @returns the ribbon mesh
  115882. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115883. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115884. */
  115885. static CreateRibbon(name: string, options: {
  115886. pathArray: Vector3[][];
  115887. closeArray?: boolean;
  115888. closePath?: boolean;
  115889. offset?: number;
  115890. updatable?: boolean;
  115891. sideOrientation?: number;
  115892. frontUVs?: Vector4;
  115893. backUVs?: Vector4;
  115894. instance?: Mesh;
  115895. invertUV?: boolean;
  115896. uvs?: Vector2[];
  115897. colors?: Color4[];
  115898. }, scene?: Nullable<Scene>): Mesh;
  115899. /**
  115900. * Creates a cylinder or a cone mesh
  115901. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115902. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115903. * * 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.
  115904. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115905. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115906. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115907. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115908. * * 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).
  115909. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115910. * * 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).
  115911. * * 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
  115912. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115913. * * 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
  115914. * * 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.
  115915. * * If `enclose` is false, a ring surface is one element.
  115916. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115917. * * 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
  115918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115921. * @param name defines the name of the mesh
  115922. * @param options defines the options used to create the mesh
  115923. * @param scene defines the hosting scene
  115924. * @returns the cylinder mesh
  115925. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115926. */
  115927. static CreateCylinder(name: string, options: {
  115928. height?: number;
  115929. diameterTop?: number;
  115930. diameterBottom?: number;
  115931. diameter?: number;
  115932. tessellation?: number;
  115933. subdivisions?: number;
  115934. arc?: number;
  115935. faceColors?: Color4[];
  115936. faceUV?: Vector4[];
  115937. updatable?: boolean;
  115938. hasRings?: boolean;
  115939. enclose?: boolean;
  115940. cap?: number;
  115941. sideOrientation?: number;
  115942. frontUVs?: Vector4;
  115943. backUVs?: Vector4;
  115944. }, scene?: Nullable<Scene>): Mesh;
  115945. /**
  115946. * Creates a torus mesh
  115947. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115948. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115949. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115953. * @param name defines the name of the mesh
  115954. * @param options defines the options used to create the mesh
  115955. * @param scene defines the hosting scene
  115956. * @returns the torus mesh
  115957. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115958. */
  115959. static CreateTorus(name: string, options: {
  115960. diameter?: number;
  115961. thickness?: number;
  115962. tessellation?: number;
  115963. updatable?: boolean;
  115964. sideOrientation?: number;
  115965. frontUVs?: Vector4;
  115966. backUVs?: Vector4;
  115967. }, scene?: Nullable<Scene>): Mesh;
  115968. /**
  115969. * Creates a torus knot mesh
  115970. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115971. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115972. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115973. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115977. * @param name defines the name of the mesh
  115978. * @param options defines the options used to create the mesh
  115979. * @param scene defines the hosting scene
  115980. * @returns the torus knot mesh
  115981. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115982. */
  115983. static CreateTorusKnot(name: string, options: {
  115984. radius?: number;
  115985. tube?: number;
  115986. radialSegments?: number;
  115987. tubularSegments?: number;
  115988. p?: number;
  115989. q?: number;
  115990. updatable?: boolean;
  115991. sideOrientation?: number;
  115992. frontUVs?: Vector4;
  115993. backUVs?: Vector4;
  115994. }, scene?: Nullable<Scene>): Mesh;
  115995. /**
  115996. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115997. * * 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
  115998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115999. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116000. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116001. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116002. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116003. * * 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
  116004. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116007. * @param name defines the name of the new line system
  116008. * @param options defines the options used to create the line system
  116009. * @param scene defines the hosting scene
  116010. * @returns a new line system mesh
  116011. */
  116012. static CreateLineSystem(name: string, options: {
  116013. lines: Vector3[][];
  116014. updatable?: boolean;
  116015. instance?: Nullable<LinesMesh>;
  116016. colors?: Nullable<Color4[][]>;
  116017. useVertexAlpha?: boolean;
  116018. }, scene: Nullable<Scene>): LinesMesh;
  116019. /**
  116020. * Creates a line mesh
  116021. * 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
  116022. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116023. * * The parameter `points` is an array successive Vector3
  116024. * * 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
  116025. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116026. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116027. * * When updating an instance, remember that only point positions can change, not the number of points
  116028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116030. * @param name defines the name of the new line system
  116031. * @param options defines the options used to create the line system
  116032. * @param scene defines the hosting scene
  116033. * @returns a new line mesh
  116034. */
  116035. static CreateLines(name: string, options: {
  116036. points: Vector3[];
  116037. updatable?: boolean;
  116038. instance?: Nullable<LinesMesh>;
  116039. colors?: Color4[];
  116040. useVertexAlpha?: boolean;
  116041. }, scene?: Nullable<Scene>): LinesMesh;
  116042. /**
  116043. * Creates a dashed line mesh
  116044. * * 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
  116045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116046. * * The parameter `points` is an array successive Vector3
  116047. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116048. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116049. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116050. * * 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
  116051. * * When updating an instance, remember that only point positions can change, not the number of points
  116052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116053. * @param name defines the name of the mesh
  116054. * @param options defines the options used to create the mesh
  116055. * @param scene defines the hosting scene
  116056. * @returns the dashed line mesh
  116057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116058. */
  116059. static CreateDashedLines(name: string, options: {
  116060. points: Vector3[];
  116061. dashSize?: number;
  116062. gapSize?: number;
  116063. dashNb?: number;
  116064. updatable?: boolean;
  116065. instance?: LinesMesh;
  116066. }, scene?: Nullable<Scene>): LinesMesh;
  116067. /**
  116068. * 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.
  116069. * * 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.
  116070. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116071. * * 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.
  116072. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116073. * * 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
  116074. * * 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
  116075. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116078. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116080. * @param name defines the name of the mesh
  116081. * @param options defines the options used to create the mesh
  116082. * @param scene defines the hosting scene
  116083. * @returns the extruded shape mesh
  116084. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116086. */
  116087. static ExtrudeShape(name: string, options: {
  116088. shape: Vector3[];
  116089. path: Vector3[];
  116090. scale?: number;
  116091. rotation?: number;
  116092. cap?: number;
  116093. updatable?: boolean;
  116094. sideOrientation?: number;
  116095. frontUVs?: Vector4;
  116096. backUVs?: Vector4;
  116097. instance?: Mesh;
  116098. invertUV?: boolean;
  116099. }, scene?: Nullable<Scene>): Mesh;
  116100. /**
  116101. * Creates an custom extruded shape mesh.
  116102. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116103. * * 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.
  116104. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116105. * * 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
  116106. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116107. * * 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
  116108. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116109. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116110. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116111. * * 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
  116112. * * 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
  116113. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116118. * @param name defines the name of the mesh
  116119. * @param options defines the options used to create the mesh
  116120. * @param scene defines the hosting scene
  116121. * @returns the custom extruded shape mesh
  116122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116123. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116125. */
  116126. static ExtrudeShapeCustom(name: string, options: {
  116127. shape: Vector3[];
  116128. path: Vector3[];
  116129. scaleFunction?: any;
  116130. rotationFunction?: any;
  116131. ribbonCloseArray?: boolean;
  116132. ribbonClosePath?: boolean;
  116133. cap?: number;
  116134. updatable?: boolean;
  116135. sideOrientation?: number;
  116136. frontUVs?: Vector4;
  116137. backUVs?: Vector4;
  116138. instance?: Mesh;
  116139. invertUV?: boolean;
  116140. }, scene?: Nullable<Scene>): Mesh;
  116141. /**
  116142. * Creates lathe mesh.
  116143. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116144. * * 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
  116145. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116146. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116147. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116148. * * 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
  116149. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116150. * * 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
  116151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116155. * @param name defines the name of the mesh
  116156. * @param options defines the options used to create the mesh
  116157. * @param scene defines the hosting scene
  116158. * @returns the lathe mesh
  116159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116160. */
  116161. static CreateLathe(name: string, options: {
  116162. shape: Vector3[];
  116163. radius?: number;
  116164. tessellation?: number;
  116165. clip?: number;
  116166. arc?: number;
  116167. closed?: boolean;
  116168. updatable?: boolean;
  116169. sideOrientation?: number;
  116170. frontUVs?: Vector4;
  116171. backUVs?: Vector4;
  116172. cap?: number;
  116173. invertUV?: boolean;
  116174. }, scene?: Nullable<Scene>): Mesh;
  116175. /**
  116176. * Creates a tiled plane mesh
  116177. * * You can set a limited pattern arrangement with the tiles
  116178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116181. * @param name defines the name of the mesh
  116182. * @param options defines the options used to create the mesh
  116183. * @param scene defines the hosting scene
  116184. * @returns the plane mesh
  116185. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116186. */
  116187. static CreateTiledPlane(name: string, options: {
  116188. pattern?: number;
  116189. tileSize?: number;
  116190. tileWidth?: number;
  116191. tileHeight?: number;
  116192. size?: number;
  116193. width?: number;
  116194. height?: number;
  116195. alignHorizontal?: number;
  116196. alignVertical?: number;
  116197. sideOrientation?: number;
  116198. frontUVs?: Vector4;
  116199. backUVs?: Vector4;
  116200. updatable?: boolean;
  116201. }, scene?: Nullable<Scene>): Mesh;
  116202. /**
  116203. * Creates a plane mesh
  116204. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116205. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116206. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116210. * @param name defines the name of the mesh
  116211. * @param options defines the options used to create the mesh
  116212. * @param scene defines the hosting scene
  116213. * @returns the plane mesh
  116214. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116215. */
  116216. static CreatePlane(name: string, options: {
  116217. size?: number;
  116218. width?: number;
  116219. height?: number;
  116220. sideOrientation?: number;
  116221. frontUVs?: Vector4;
  116222. backUVs?: Vector4;
  116223. updatable?: boolean;
  116224. sourcePlane?: Plane;
  116225. }, scene?: Nullable<Scene>): Mesh;
  116226. /**
  116227. * Creates a ground mesh
  116228. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116229. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116231. * @param name defines the name of the mesh
  116232. * @param options defines the options used to create the mesh
  116233. * @param scene defines the hosting scene
  116234. * @returns the ground mesh
  116235. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116236. */
  116237. static CreateGround(name: string, options: {
  116238. width?: number;
  116239. height?: number;
  116240. subdivisions?: number;
  116241. subdivisionsX?: number;
  116242. subdivisionsY?: number;
  116243. updatable?: boolean;
  116244. }, scene?: Nullable<Scene>): Mesh;
  116245. /**
  116246. * Creates a tiled ground mesh
  116247. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116248. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116249. * * 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
  116250. * * 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
  116251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116252. * @param name defines the name of the mesh
  116253. * @param options defines the options used to create the mesh
  116254. * @param scene defines the hosting scene
  116255. * @returns the tiled ground mesh
  116256. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116257. */
  116258. static CreateTiledGround(name: string, options: {
  116259. xmin: number;
  116260. zmin: number;
  116261. xmax: number;
  116262. zmax: number;
  116263. subdivisions?: {
  116264. w: number;
  116265. h: number;
  116266. };
  116267. precision?: {
  116268. w: number;
  116269. h: number;
  116270. };
  116271. updatable?: boolean;
  116272. }, scene?: Nullable<Scene>): Mesh;
  116273. /**
  116274. * Creates a ground mesh from a height map
  116275. * * The parameter `url` sets the URL of the height map image resource.
  116276. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116277. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116278. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116279. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116280. * * 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.
  116281. * * 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).
  116282. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116284. * @param name defines the name of the mesh
  116285. * @param url defines the url to the height map
  116286. * @param options defines the options used to create the mesh
  116287. * @param scene defines the hosting scene
  116288. * @returns the ground mesh
  116289. * @see https://doc.babylonjs.com/babylon101/height_map
  116290. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116291. */
  116292. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116293. width?: number;
  116294. height?: number;
  116295. subdivisions?: number;
  116296. minHeight?: number;
  116297. maxHeight?: number;
  116298. colorFilter?: Color3;
  116299. alphaFilter?: number;
  116300. updatable?: boolean;
  116301. onReady?: (mesh: GroundMesh) => void;
  116302. }, scene?: Nullable<Scene>): GroundMesh;
  116303. /**
  116304. * Creates a polygon mesh
  116305. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116306. * * 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
  116307. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116310. * * Remember you can only change the shape positions, not their number when updating a polygon
  116311. * @param name defines the name of the mesh
  116312. * @param options defines the options used to create the mesh
  116313. * @param scene defines the hosting scene
  116314. * @param earcutInjection can be used to inject your own earcut reference
  116315. * @returns the polygon mesh
  116316. */
  116317. static CreatePolygon(name: string, options: {
  116318. shape: Vector3[];
  116319. holes?: Vector3[][];
  116320. depth?: number;
  116321. faceUV?: Vector4[];
  116322. faceColors?: Color4[];
  116323. updatable?: boolean;
  116324. sideOrientation?: number;
  116325. frontUVs?: Vector4;
  116326. backUVs?: Vector4;
  116327. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116328. /**
  116329. * Creates an extruded polygon mesh, with depth in the Y direction.
  116330. * * 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)
  116331. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116332. * @param name defines the name of the mesh
  116333. * @param options defines the options used to create the mesh
  116334. * @param scene defines the hosting scene
  116335. * @param earcutInjection can be used to inject your own earcut reference
  116336. * @returns the polygon mesh
  116337. */
  116338. static ExtrudePolygon(name: string, options: {
  116339. shape: Vector3[];
  116340. holes?: Vector3[][];
  116341. depth?: number;
  116342. faceUV?: Vector4[];
  116343. faceColors?: Color4[];
  116344. updatable?: boolean;
  116345. sideOrientation?: number;
  116346. frontUVs?: Vector4;
  116347. backUVs?: Vector4;
  116348. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116349. /**
  116350. * Creates a tube mesh.
  116351. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116352. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116353. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116354. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116355. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116356. * * 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)
  116357. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116358. * * 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
  116359. * * 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
  116360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116364. * @param name defines the name of the mesh
  116365. * @param options defines the options used to create the mesh
  116366. * @param scene defines the hosting scene
  116367. * @returns the tube mesh
  116368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116369. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116370. */
  116371. static CreateTube(name: string, options: {
  116372. path: Vector3[];
  116373. radius?: number;
  116374. tessellation?: number;
  116375. radiusFunction?: {
  116376. (i: number, distance: number): number;
  116377. };
  116378. cap?: number;
  116379. arc?: number;
  116380. updatable?: boolean;
  116381. sideOrientation?: number;
  116382. frontUVs?: Vector4;
  116383. backUVs?: Vector4;
  116384. instance?: Mesh;
  116385. invertUV?: boolean;
  116386. }, scene?: Nullable<Scene>): Mesh;
  116387. /**
  116388. * Creates a polyhedron mesh
  116389. * * 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
  116390. * * The parameter `size` (positive float, default 1) sets the polygon size
  116391. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116392. * * 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`
  116393. * * 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
  116394. * * 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)`)
  116395. * * 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
  116396. * * 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
  116397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116400. * @param name defines the name of the mesh
  116401. * @param options defines the options used to create the mesh
  116402. * @param scene defines the hosting scene
  116403. * @returns the polyhedron mesh
  116404. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116405. */
  116406. static CreatePolyhedron(name: string, options: {
  116407. type?: number;
  116408. size?: number;
  116409. sizeX?: number;
  116410. sizeY?: number;
  116411. sizeZ?: number;
  116412. custom?: any;
  116413. faceUV?: Vector4[];
  116414. faceColors?: Color4[];
  116415. flat?: boolean;
  116416. updatable?: boolean;
  116417. sideOrientation?: number;
  116418. frontUVs?: Vector4;
  116419. backUVs?: Vector4;
  116420. }, scene?: Nullable<Scene>): Mesh;
  116421. /**
  116422. * Creates a decal mesh.
  116423. * 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
  116424. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116425. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116426. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116427. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116428. * @param name defines the name of the mesh
  116429. * @param sourceMesh defines the mesh where the decal must be applied
  116430. * @param options defines the options used to create the mesh
  116431. * @param scene defines the hosting scene
  116432. * @returns the decal mesh
  116433. * @see https://doc.babylonjs.com/how_to/decals
  116434. */
  116435. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116436. position?: Vector3;
  116437. normal?: Vector3;
  116438. size?: Vector3;
  116439. angle?: number;
  116440. }): Mesh;
  116441. }
  116442. }
  116443. declare module BABYLON {
  116444. /**
  116445. * A simplifier interface for future simplification implementations
  116446. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116447. */
  116448. export interface ISimplifier {
  116449. /**
  116450. * Simplification of a given mesh according to the given settings.
  116451. * Since this requires computation, it is assumed that the function runs async.
  116452. * @param settings The settings of the simplification, including quality and distance
  116453. * @param successCallback A callback that will be called after the mesh was simplified.
  116454. * @param errorCallback in case of an error, this callback will be called. optional.
  116455. */
  116456. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116457. }
  116458. /**
  116459. * Expected simplification settings.
  116460. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116461. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116462. */
  116463. export interface ISimplificationSettings {
  116464. /**
  116465. * Gets or sets the expected quality
  116466. */
  116467. quality: number;
  116468. /**
  116469. * Gets or sets the distance when this optimized version should be used
  116470. */
  116471. distance: number;
  116472. /**
  116473. * Gets an already optimized mesh
  116474. */
  116475. optimizeMesh?: boolean;
  116476. }
  116477. /**
  116478. * Class used to specify simplification options
  116479. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116480. */
  116481. export class SimplificationSettings implements ISimplificationSettings {
  116482. /** expected quality */
  116483. quality: number;
  116484. /** distance when this optimized version should be used */
  116485. distance: number;
  116486. /** already optimized mesh */
  116487. optimizeMesh?: boolean | undefined;
  116488. /**
  116489. * Creates a SimplificationSettings
  116490. * @param quality expected quality
  116491. * @param distance distance when this optimized version should be used
  116492. * @param optimizeMesh already optimized mesh
  116493. */
  116494. constructor(
  116495. /** expected quality */
  116496. quality: number,
  116497. /** distance when this optimized version should be used */
  116498. distance: number,
  116499. /** already optimized mesh */
  116500. optimizeMesh?: boolean | undefined);
  116501. }
  116502. /**
  116503. * Interface used to define a simplification task
  116504. */
  116505. export interface ISimplificationTask {
  116506. /**
  116507. * Array of settings
  116508. */
  116509. settings: Array<ISimplificationSettings>;
  116510. /**
  116511. * Simplification type
  116512. */
  116513. simplificationType: SimplificationType;
  116514. /**
  116515. * Mesh to simplify
  116516. */
  116517. mesh: Mesh;
  116518. /**
  116519. * Callback called on success
  116520. */
  116521. successCallback?: () => void;
  116522. /**
  116523. * Defines if parallel processing can be used
  116524. */
  116525. parallelProcessing: boolean;
  116526. }
  116527. /**
  116528. * Queue used to order the simplification tasks
  116529. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116530. */
  116531. export class SimplificationQueue {
  116532. private _simplificationArray;
  116533. /**
  116534. * Gets a boolean indicating that the process is still running
  116535. */
  116536. running: boolean;
  116537. /**
  116538. * Creates a new queue
  116539. */
  116540. constructor();
  116541. /**
  116542. * Adds a new simplification task
  116543. * @param task defines a task to add
  116544. */
  116545. addTask(task: ISimplificationTask): void;
  116546. /**
  116547. * Execute next task
  116548. */
  116549. executeNext(): void;
  116550. /**
  116551. * Execute a simplification task
  116552. * @param task defines the task to run
  116553. */
  116554. runSimplification(task: ISimplificationTask): void;
  116555. private getSimplifier;
  116556. }
  116557. /**
  116558. * The implemented types of simplification
  116559. * At the moment only Quadratic Error Decimation is implemented
  116560. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116561. */
  116562. export enum SimplificationType {
  116563. /** Quadratic error decimation */
  116564. QUADRATIC = 0
  116565. }
  116566. }
  116567. declare module BABYLON {
  116568. interface Scene {
  116569. /** @hidden (Backing field) */
  116570. _simplificationQueue: SimplificationQueue;
  116571. /**
  116572. * Gets or sets the simplification queue attached to the scene
  116573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116574. */
  116575. simplificationQueue: SimplificationQueue;
  116576. }
  116577. interface Mesh {
  116578. /**
  116579. * Simplify the mesh according to the given array of settings.
  116580. * Function will return immediately and will simplify async
  116581. * @param settings a collection of simplification settings
  116582. * @param parallelProcessing should all levels calculate parallel or one after the other
  116583. * @param simplificationType the type of simplification to run
  116584. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116585. * @returns the current mesh
  116586. */
  116587. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116588. }
  116589. /**
  116590. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116591. * created in a scene
  116592. */
  116593. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116594. /**
  116595. * The component name helpfull to identify the component in the list of scene components.
  116596. */
  116597. readonly name: string;
  116598. /**
  116599. * The scene the component belongs to.
  116600. */
  116601. scene: Scene;
  116602. /**
  116603. * Creates a new instance of the component for the given scene
  116604. * @param scene Defines the scene to register the component in
  116605. */
  116606. constructor(scene: Scene);
  116607. /**
  116608. * Registers the component in a given scene
  116609. */
  116610. register(): void;
  116611. /**
  116612. * Rebuilds the elements related to this component in case of
  116613. * context lost for instance.
  116614. */
  116615. rebuild(): void;
  116616. /**
  116617. * Disposes the component and the associated ressources
  116618. */
  116619. dispose(): void;
  116620. private _beforeCameraUpdate;
  116621. }
  116622. }
  116623. declare module BABYLON {
  116624. /**
  116625. * Class used to enable access to IndexedDB
  116626. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116627. */
  116628. export class Database implements IOfflineProvider {
  116629. private _callbackManifestChecked;
  116630. private _currentSceneUrl;
  116631. private _db;
  116632. private _enableSceneOffline;
  116633. private _enableTexturesOffline;
  116634. private _manifestVersionFound;
  116635. private _mustUpdateRessources;
  116636. private _hasReachedQuota;
  116637. private _isSupported;
  116638. private _idbFactory;
  116639. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116640. private static IsUASupportingBlobStorage;
  116641. /**
  116642. * Gets a boolean indicating if Database storate is enabled (off by default)
  116643. */
  116644. static IDBStorageEnabled: boolean;
  116645. /**
  116646. * Gets a boolean indicating if scene must be saved in the database
  116647. */
  116648. readonly enableSceneOffline: boolean;
  116649. /**
  116650. * Gets a boolean indicating if textures must be saved in the database
  116651. */
  116652. readonly enableTexturesOffline: boolean;
  116653. /**
  116654. * Creates a new Database
  116655. * @param urlToScene defines the url to load the scene
  116656. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116657. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116658. */
  116659. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116660. private static _ParseURL;
  116661. private static _ReturnFullUrlLocation;
  116662. private _checkManifestFile;
  116663. /**
  116664. * Open the database and make it available
  116665. * @param successCallback defines the callback to call on success
  116666. * @param errorCallback defines the callback to call on error
  116667. */
  116668. open(successCallback: () => void, errorCallback: () => void): void;
  116669. /**
  116670. * Loads an image from the database
  116671. * @param url defines the url to load from
  116672. * @param image defines the target DOM image
  116673. */
  116674. loadImage(url: string, image: HTMLImageElement): void;
  116675. private _loadImageFromDBAsync;
  116676. private _saveImageIntoDBAsync;
  116677. private _checkVersionFromDB;
  116678. private _loadVersionFromDBAsync;
  116679. private _saveVersionIntoDBAsync;
  116680. /**
  116681. * Loads a file from database
  116682. * @param url defines the URL to load from
  116683. * @param sceneLoaded defines a callback to call on success
  116684. * @param progressCallBack defines a callback to call when progress changed
  116685. * @param errorCallback defines a callback to call on error
  116686. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116687. */
  116688. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116689. private _loadFileAsync;
  116690. private _saveFileAsync;
  116691. /**
  116692. * Validates if xhr data is correct
  116693. * @param xhr defines the request to validate
  116694. * @param dataType defines the expected data type
  116695. * @returns true if data is correct
  116696. */
  116697. private static _ValidateXHRData;
  116698. }
  116699. }
  116700. declare module BABYLON {
  116701. /** @hidden */
  116702. export var gpuUpdateParticlesPixelShader: {
  116703. name: string;
  116704. shader: string;
  116705. };
  116706. }
  116707. declare module BABYLON {
  116708. /** @hidden */
  116709. export var gpuUpdateParticlesVertexShader: {
  116710. name: string;
  116711. shader: string;
  116712. };
  116713. }
  116714. declare module BABYLON {
  116715. /** @hidden */
  116716. export var clipPlaneFragmentDeclaration2: {
  116717. name: string;
  116718. shader: string;
  116719. };
  116720. }
  116721. declare module BABYLON {
  116722. /** @hidden */
  116723. export var gpuRenderParticlesPixelShader: {
  116724. name: string;
  116725. shader: string;
  116726. };
  116727. }
  116728. declare module BABYLON {
  116729. /** @hidden */
  116730. export var clipPlaneVertexDeclaration2: {
  116731. name: string;
  116732. shader: string;
  116733. };
  116734. }
  116735. declare module BABYLON {
  116736. /** @hidden */
  116737. export var gpuRenderParticlesVertexShader: {
  116738. name: string;
  116739. shader: string;
  116740. };
  116741. }
  116742. declare module BABYLON {
  116743. /**
  116744. * This represents a GPU particle system in Babylon
  116745. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116746. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116747. */
  116748. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116749. /**
  116750. * The layer mask we are rendering the particles through.
  116751. */
  116752. layerMask: number;
  116753. private _capacity;
  116754. private _activeCount;
  116755. private _currentActiveCount;
  116756. private _accumulatedCount;
  116757. private _renderEffect;
  116758. private _updateEffect;
  116759. private _buffer0;
  116760. private _buffer1;
  116761. private _spriteBuffer;
  116762. private _updateVAO;
  116763. private _renderVAO;
  116764. private _targetIndex;
  116765. private _sourceBuffer;
  116766. private _targetBuffer;
  116767. private _engine;
  116768. private _currentRenderId;
  116769. private _started;
  116770. private _stopped;
  116771. private _timeDelta;
  116772. private _randomTexture;
  116773. private _randomTexture2;
  116774. private _attributesStrideSize;
  116775. private _updateEffectOptions;
  116776. private _randomTextureSize;
  116777. private _actualFrame;
  116778. private readonly _rawTextureWidth;
  116779. /**
  116780. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116781. */
  116782. static readonly IsSupported: boolean;
  116783. /**
  116784. * An event triggered when the system is disposed.
  116785. */
  116786. onDisposeObservable: Observable<GPUParticleSystem>;
  116787. /**
  116788. * Gets the maximum number of particles active at the same time.
  116789. * @returns The max number of active particles.
  116790. */
  116791. getCapacity(): number;
  116792. /**
  116793. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116794. * to override the particles.
  116795. */
  116796. forceDepthWrite: boolean;
  116797. /**
  116798. * Gets or set the number of active particles
  116799. */
  116800. activeParticleCount: number;
  116801. private _preWarmDone;
  116802. /**
  116803. * Is this system ready to be used/rendered
  116804. * @return true if the system is ready
  116805. */
  116806. isReady(): boolean;
  116807. /**
  116808. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116809. * @returns True if it has been started, otherwise false.
  116810. */
  116811. isStarted(): boolean;
  116812. /**
  116813. * Starts the particle system and begins to emit
  116814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116815. */
  116816. start(delay?: number): void;
  116817. /**
  116818. * Stops the particle system.
  116819. */
  116820. stop(): void;
  116821. /**
  116822. * Remove all active particles
  116823. */
  116824. reset(): void;
  116825. /**
  116826. * Returns the string "GPUParticleSystem"
  116827. * @returns a string containing the class name
  116828. */
  116829. getClassName(): string;
  116830. private _colorGradientsTexture;
  116831. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116832. /**
  116833. * Adds a new color gradient
  116834. * @param gradient defines the gradient to use (between 0 and 1)
  116835. * @param color1 defines the color to affect to the specified gradient
  116836. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116837. * @returns the current particle system
  116838. */
  116839. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116840. /**
  116841. * Remove a specific color gradient
  116842. * @param gradient defines the gradient to remove
  116843. * @returns the current particle system
  116844. */
  116845. removeColorGradient(gradient: number): GPUParticleSystem;
  116846. private _angularSpeedGradientsTexture;
  116847. private _sizeGradientsTexture;
  116848. private _velocityGradientsTexture;
  116849. private _limitVelocityGradientsTexture;
  116850. private _dragGradientsTexture;
  116851. private _addFactorGradient;
  116852. /**
  116853. * Adds a new size gradient
  116854. * @param gradient defines the gradient to use (between 0 and 1)
  116855. * @param factor defines the size factor to affect to the specified gradient
  116856. * @returns the current particle system
  116857. */
  116858. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116859. /**
  116860. * Remove a specific size gradient
  116861. * @param gradient defines the gradient to remove
  116862. * @returns the current particle system
  116863. */
  116864. removeSizeGradient(gradient: number): GPUParticleSystem;
  116865. /**
  116866. * Adds a new angular speed gradient
  116867. * @param gradient defines the gradient to use (between 0 and 1)
  116868. * @param factor defines the angular speed to affect to the specified gradient
  116869. * @returns the current particle system
  116870. */
  116871. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116872. /**
  116873. * Remove a specific angular speed gradient
  116874. * @param gradient defines the gradient to remove
  116875. * @returns the current particle system
  116876. */
  116877. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116878. /**
  116879. * Adds a new velocity gradient
  116880. * @param gradient defines the gradient to use (between 0 and 1)
  116881. * @param factor defines the velocity to affect to the specified gradient
  116882. * @returns the current particle system
  116883. */
  116884. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116885. /**
  116886. * Remove a specific velocity gradient
  116887. * @param gradient defines the gradient to remove
  116888. * @returns the current particle system
  116889. */
  116890. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116891. /**
  116892. * Adds a new limit velocity gradient
  116893. * @param gradient defines the gradient to use (between 0 and 1)
  116894. * @param factor defines the limit velocity value to affect to the specified gradient
  116895. * @returns the current particle system
  116896. */
  116897. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116898. /**
  116899. * Remove a specific limit velocity gradient
  116900. * @param gradient defines the gradient to remove
  116901. * @returns the current particle system
  116902. */
  116903. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116904. /**
  116905. * Adds a new drag gradient
  116906. * @param gradient defines the gradient to use (between 0 and 1)
  116907. * @param factor defines the drag value to affect to the specified gradient
  116908. * @returns the current particle system
  116909. */
  116910. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116911. /**
  116912. * Remove a specific drag gradient
  116913. * @param gradient defines the gradient to remove
  116914. * @returns the current particle system
  116915. */
  116916. removeDragGradient(gradient: number): GPUParticleSystem;
  116917. /**
  116918. * Not supported by GPUParticleSystem
  116919. * @param gradient defines the gradient to use (between 0 and 1)
  116920. * @param factor defines the emit rate value to affect to the specified gradient
  116921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116922. * @returns the current particle system
  116923. */
  116924. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116925. /**
  116926. * Not supported by GPUParticleSystem
  116927. * @param gradient defines the gradient to remove
  116928. * @returns the current particle system
  116929. */
  116930. removeEmitRateGradient(gradient: number): IParticleSystem;
  116931. /**
  116932. * Not supported by GPUParticleSystem
  116933. * @param gradient defines the gradient to use (between 0 and 1)
  116934. * @param factor defines the start size value to affect to the specified gradient
  116935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116936. * @returns the current particle system
  116937. */
  116938. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116939. /**
  116940. * Not supported by GPUParticleSystem
  116941. * @param gradient defines the gradient to remove
  116942. * @returns the current particle system
  116943. */
  116944. removeStartSizeGradient(gradient: number): IParticleSystem;
  116945. /**
  116946. * Not supported by GPUParticleSystem
  116947. * @param gradient defines the gradient to use (between 0 and 1)
  116948. * @param min defines the color remap minimal range
  116949. * @param max defines the color remap maximal range
  116950. * @returns the current particle system
  116951. */
  116952. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116953. /**
  116954. * Not supported by GPUParticleSystem
  116955. * @param gradient defines the gradient to remove
  116956. * @returns the current particle system
  116957. */
  116958. removeColorRemapGradient(): IParticleSystem;
  116959. /**
  116960. * Not supported by GPUParticleSystem
  116961. * @param gradient defines the gradient to use (between 0 and 1)
  116962. * @param min defines the alpha remap minimal range
  116963. * @param max defines the alpha remap maximal range
  116964. * @returns the current particle system
  116965. */
  116966. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116967. /**
  116968. * Not supported by GPUParticleSystem
  116969. * @param gradient defines the gradient to remove
  116970. * @returns the current particle system
  116971. */
  116972. removeAlphaRemapGradient(): IParticleSystem;
  116973. /**
  116974. * Not supported by GPUParticleSystem
  116975. * @param gradient defines the gradient to use (between 0 and 1)
  116976. * @param color defines the color to affect to the specified gradient
  116977. * @returns the current particle system
  116978. */
  116979. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116980. /**
  116981. * Not supported by GPUParticleSystem
  116982. * @param gradient defines the gradient to remove
  116983. * @returns the current particle system
  116984. */
  116985. removeRampGradient(): IParticleSystem;
  116986. /**
  116987. * Not supported by GPUParticleSystem
  116988. * @returns the list of ramp gradients
  116989. */
  116990. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116991. /**
  116992. * Not supported by GPUParticleSystem
  116993. * Gets or sets a boolean indicating that ramp gradients must be used
  116994. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116995. */
  116996. useRampGradients: boolean;
  116997. /**
  116998. * Not supported by GPUParticleSystem
  116999. * @param gradient defines the gradient to use (between 0 and 1)
  117000. * @param factor defines the life time factor to affect to the specified gradient
  117001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117002. * @returns the current particle system
  117003. */
  117004. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117005. /**
  117006. * Not supported by GPUParticleSystem
  117007. * @param gradient defines the gradient to remove
  117008. * @returns the current particle system
  117009. */
  117010. removeLifeTimeGradient(gradient: number): IParticleSystem;
  117011. /**
  117012. * Instantiates a GPU particle system.
  117013. * 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.
  117014. * @param name The name of the particle system
  117015. * @param options The options used to create the system
  117016. * @param scene The scene the particle system belongs to
  117017. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  117018. */
  117019. constructor(name: string, options: Partial<{
  117020. capacity: number;
  117021. randomTextureSize: number;
  117022. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  117023. protected _reset(): void;
  117024. private _createUpdateVAO;
  117025. private _createRenderVAO;
  117026. private _initialize;
  117027. /** @hidden */
  117028. _recreateUpdateEffect(): void;
  117029. /** @hidden */
  117030. _recreateRenderEffect(): void;
  117031. /**
  117032. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  117033. * @param preWarm defines if we are in the pre-warmimg phase
  117034. */
  117035. animate(preWarm?: boolean): void;
  117036. private _createFactorGradientTexture;
  117037. private _createSizeGradientTexture;
  117038. private _createAngularSpeedGradientTexture;
  117039. private _createVelocityGradientTexture;
  117040. private _createLimitVelocityGradientTexture;
  117041. private _createDragGradientTexture;
  117042. private _createColorGradientTexture;
  117043. /**
  117044. * Renders the particle system in its current state
  117045. * @param preWarm defines if the system should only update the particles but not render them
  117046. * @returns the current number of particles
  117047. */
  117048. render(preWarm?: boolean): number;
  117049. /**
  117050. * Rebuilds the particle system
  117051. */
  117052. rebuild(): void;
  117053. private _releaseBuffers;
  117054. private _releaseVAOs;
  117055. /**
  117056. * Disposes the particle system and free the associated resources
  117057. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117058. */
  117059. dispose(disposeTexture?: boolean): void;
  117060. /**
  117061. * Clones the particle system.
  117062. * @param name The name of the cloned object
  117063. * @param newEmitter The new emitter to use
  117064. * @returns the cloned particle system
  117065. */
  117066. clone(name: string, newEmitter: any): GPUParticleSystem;
  117067. /**
  117068. * Serializes the particle system to a JSON object.
  117069. * @returns the JSON object
  117070. */
  117071. serialize(): any;
  117072. /**
  117073. * Parses a JSON object to create a GPU particle system.
  117074. * @param parsedParticleSystem The JSON object to parse
  117075. * @param scene The scene to create the particle system in
  117076. * @param rootUrl The root url to use to load external dependencies like texture
  117077. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117078. * @returns the parsed GPU particle system
  117079. */
  117080. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117081. }
  117082. }
  117083. declare module BABYLON {
  117084. /**
  117085. * Represents a set of particle systems working together to create a specific effect
  117086. */
  117087. export class ParticleSystemSet implements IDisposable {
  117088. private _emitterCreationOptions;
  117089. private _emitterNode;
  117090. /**
  117091. * Gets the particle system list
  117092. */
  117093. systems: IParticleSystem[];
  117094. /**
  117095. * Gets the emitter node used with this set
  117096. */
  117097. readonly emitterNode: Nullable<TransformNode>;
  117098. /**
  117099. * Creates a new emitter mesh as a sphere
  117100. * @param options defines the options used to create the sphere
  117101. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117102. * @param scene defines the hosting scene
  117103. */
  117104. setEmitterAsSphere(options: {
  117105. diameter: number;
  117106. segments: number;
  117107. color: Color3;
  117108. }, renderingGroupId: number, scene: Scene): void;
  117109. /**
  117110. * Starts all particle systems of the set
  117111. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117112. */
  117113. start(emitter?: AbstractMesh): void;
  117114. /**
  117115. * Release all associated resources
  117116. */
  117117. dispose(): void;
  117118. /**
  117119. * Serialize the set into a JSON compatible object
  117120. * @returns a JSON compatible representation of the set
  117121. */
  117122. serialize(): any;
  117123. /**
  117124. * Parse a new ParticleSystemSet from a serialized source
  117125. * @param data defines a JSON compatible representation of the set
  117126. * @param scene defines the hosting scene
  117127. * @param gpu defines if we want GPU particles or CPU particles
  117128. * @returns a new ParticleSystemSet
  117129. */
  117130. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117131. }
  117132. }
  117133. declare module BABYLON {
  117134. /**
  117135. * This class is made for on one-liner static method to help creating particle system set.
  117136. */
  117137. export class ParticleHelper {
  117138. /**
  117139. * Gets or sets base Assets URL
  117140. */
  117141. static BaseAssetsUrl: string;
  117142. /**
  117143. * Create a default particle system that you can tweak
  117144. * @param emitter defines the emitter to use
  117145. * @param capacity defines the system capacity (default is 500 particles)
  117146. * @param scene defines the hosting scene
  117147. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117148. * @returns the new Particle system
  117149. */
  117150. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117151. /**
  117152. * This is the main static method (one-liner) of this helper to create different particle systems
  117153. * @param type This string represents the type to the particle system to create
  117154. * @param scene The scene where the particle system should live
  117155. * @param gpu If the system will use gpu
  117156. * @returns the ParticleSystemSet created
  117157. */
  117158. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117159. /**
  117160. * Static function used to export a particle system to a ParticleSystemSet variable.
  117161. * Please note that the emitter shape is not exported
  117162. * @param systems defines the particle systems to export
  117163. * @returns the created particle system set
  117164. */
  117165. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117166. }
  117167. }
  117168. declare module BABYLON {
  117169. interface Engine {
  117170. /**
  117171. * Create an effect to use with particle systems.
  117172. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117173. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117174. * @param uniformsNames defines a list of attribute names
  117175. * @param samplers defines an array of string used to represent textures
  117176. * @param defines defines the string containing the defines to use to compile the shaders
  117177. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117178. * @param onCompiled defines a function to call when the effect creation is successful
  117179. * @param onError defines a function to call when the effect creation has failed
  117180. * @returns the new Effect
  117181. */
  117182. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117183. }
  117184. interface Mesh {
  117185. /**
  117186. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117187. * @returns an array of IParticleSystem
  117188. */
  117189. getEmittedParticleSystems(): IParticleSystem[];
  117190. /**
  117191. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117192. * @returns an array of IParticleSystem
  117193. */
  117194. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117195. }
  117196. /**
  117197. * @hidden
  117198. */
  117199. export var _IDoNeedToBeInTheBuild: number;
  117200. }
  117201. declare module BABYLON {
  117202. interface Scene {
  117203. /** @hidden (Backing field) */
  117204. _physicsEngine: Nullable<IPhysicsEngine>;
  117205. /**
  117206. * Gets the current physics engine
  117207. * @returns a IPhysicsEngine or null if none attached
  117208. */
  117209. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117210. /**
  117211. * Enables physics to the current scene
  117212. * @param gravity defines the scene's gravity for the physics engine
  117213. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117214. * @return a boolean indicating if the physics engine was initialized
  117215. */
  117216. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117217. /**
  117218. * Disables and disposes the physics engine associated with the scene
  117219. */
  117220. disablePhysicsEngine(): void;
  117221. /**
  117222. * Gets a boolean indicating if there is an active physics engine
  117223. * @returns a boolean indicating if there is an active physics engine
  117224. */
  117225. isPhysicsEnabled(): boolean;
  117226. /**
  117227. * Deletes a physics compound impostor
  117228. * @param compound defines the compound to delete
  117229. */
  117230. deleteCompoundImpostor(compound: any): void;
  117231. /**
  117232. * An event triggered when physic simulation is about to be run
  117233. */
  117234. onBeforePhysicsObservable: Observable<Scene>;
  117235. /**
  117236. * An event triggered when physic simulation has been done
  117237. */
  117238. onAfterPhysicsObservable: Observable<Scene>;
  117239. }
  117240. interface AbstractMesh {
  117241. /** @hidden */
  117242. _physicsImpostor: Nullable<PhysicsImpostor>;
  117243. /**
  117244. * Gets or sets impostor used for physic simulation
  117245. * @see http://doc.babylonjs.com/features/physics_engine
  117246. */
  117247. physicsImpostor: Nullable<PhysicsImpostor>;
  117248. /**
  117249. * Gets the current physics impostor
  117250. * @see http://doc.babylonjs.com/features/physics_engine
  117251. * @returns a physics impostor or null
  117252. */
  117253. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117254. /** Apply a physic impulse to the mesh
  117255. * @param force defines the force to apply
  117256. * @param contactPoint defines where to apply the force
  117257. * @returns the current mesh
  117258. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117259. */
  117260. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117261. /**
  117262. * Creates a physic joint between two meshes
  117263. * @param otherMesh defines the other mesh to use
  117264. * @param pivot1 defines the pivot to use on this mesh
  117265. * @param pivot2 defines the pivot to use on the other mesh
  117266. * @param options defines additional options (can be plugin dependent)
  117267. * @returns the current mesh
  117268. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117269. */
  117270. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117271. /** @hidden */
  117272. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117273. }
  117274. /**
  117275. * Defines the physics engine scene component responsible to manage a physics engine
  117276. */
  117277. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117278. /**
  117279. * The component name helpful to identify the component in the list of scene components.
  117280. */
  117281. readonly name: string;
  117282. /**
  117283. * The scene the component belongs to.
  117284. */
  117285. scene: Scene;
  117286. /**
  117287. * Creates a new instance of the component for the given scene
  117288. * @param scene Defines the scene to register the component in
  117289. */
  117290. constructor(scene: Scene);
  117291. /**
  117292. * Registers the component in a given scene
  117293. */
  117294. register(): void;
  117295. /**
  117296. * Rebuilds the elements related to this component in case of
  117297. * context lost for instance.
  117298. */
  117299. rebuild(): void;
  117300. /**
  117301. * Disposes the component and the associated ressources
  117302. */
  117303. dispose(): void;
  117304. }
  117305. }
  117306. declare module BABYLON {
  117307. /**
  117308. * A helper for physics simulations
  117309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117310. */
  117311. export class PhysicsHelper {
  117312. private _scene;
  117313. private _physicsEngine;
  117314. /**
  117315. * Initializes the Physics helper
  117316. * @param scene Babylon.js scene
  117317. */
  117318. constructor(scene: Scene);
  117319. /**
  117320. * Applies a radial explosion impulse
  117321. * @param origin the origin of the explosion
  117322. * @param radiusOrEventOptions the radius or the options of radial explosion
  117323. * @param strength the explosion strength
  117324. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117325. * @returns A physics radial explosion event, or null
  117326. */
  117327. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117328. /**
  117329. * Applies a radial explosion force
  117330. * @param origin the origin of the explosion
  117331. * @param radiusOrEventOptions the radius or the options of radial explosion
  117332. * @param strength the explosion strength
  117333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117334. * @returns A physics radial explosion event, or null
  117335. */
  117336. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117337. /**
  117338. * Creates a gravitational field
  117339. * @param origin the origin of the explosion
  117340. * @param radiusOrEventOptions the radius or the options of radial explosion
  117341. * @param strength the explosion strength
  117342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117343. * @returns A physics gravitational field event, or null
  117344. */
  117345. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117346. /**
  117347. * Creates a physics updraft event
  117348. * @param origin the origin of the updraft
  117349. * @param radiusOrEventOptions the radius or the options of the updraft
  117350. * @param strength the strength of the updraft
  117351. * @param height the height of the updraft
  117352. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117353. * @returns A physics updraft event, or null
  117354. */
  117355. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117356. /**
  117357. * Creates a physics vortex event
  117358. * @param origin the of the vortex
  117359. * @param radiusOrEventOptions the radius or the options of the vortex
  117360. * @param strength the strength of the vortex
  117361. * @param height the height of the vortex
  117362. * @returns a Physics vortex event, or null
  117363. * A physics vortex event or null
  117364. */
  117365. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117366. }
  117367. /**
  117368. * Represents a physics radial explosion event
  117369. */
  117370. class PhysicsRadialExplosionEvent {
  117371. private _scene;
  117372. private _options;
  117373. private _sphere;
  117374. private _dataFetched;
  117375. /**
  117376. * Initializes a radial explosioin event
  117377. * @param _scene BabylonJS scene
  117378. * @param _options The options for the vortex event
  117379. */
  117380. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117381. /**
  117382. * Returns the data related to the radial explosion event (sphere).
  117383. * @returns The radial explosion event data
  117384. */
  117385. getData(): PhysicsRadialExplosionEventData;
  117386. /**
  117387. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117388. * @param impostor A physics imposter
  117389. * @param origin the origin of the explosion
  117390. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117391. */
  117392. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117393. /**
  117394. * Triggers affecterd impostors callbacks
  117395. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117396. */
  117397. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117398. /**
  117399. * Disposes the sphere.
  117400. * @param force Specifies if the sphere should be disposed by force
  117401. */
  117402. dispose(force?: boolean): void;
  117403. /*** Helpers ***/
  117404. private _prepareSphere;
  117405. private _intersectsWithSphere;
  117406. }
  117407. /**
  117408. * Represents a gravitational field event
  117409. */
  117410. class PhysicsGravitationalFieldEvent {
  117411. private _physicsHelper;
  117412. private _scene;
  117413. private _origin;
  117414. private _options;
  117415. private _tickCallback;
  117416. private _sphere;
  117417. private _dataFetched;
  117418. /**
  117419. * Initializes the physics gravitational field event
  117420. * @param _physicsHelper A physics helper
  117421. * @param _scene BabylonJS scene
  117422. * @param _origin The origin position of the gravitational field event
  117423. * @param _options The options for the vortex event
  117424. */
  117425. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117426. /**
  117427. * Returns the data related to the gravitational field event (sphere).
  117428. * @returns A gravitational field event
  117429. */
  117430. getData(): PhysicsGravitationalFieldEventData;
  117431. /**
  117432. * Enables the gravitational field.
  117433. */
  117434. enable(): void;
  117435. /**
  117436. * Disables the gravitational field.
  117437. */
  117438. disable(): void;
  117439. /**
  117440. * Disposes the sphere.
  117441. * @param force The force to dispose from the gravitational field event
  117442. */
  117443. dispose(force?: boolean): void;
  117444. private _tick;
  117445. }
  117446. /**
  117447. * Represents a physics updraft event
  117448. */
  117449. class PhysicsUpdraftEvent {
  117450. private _scene;
  117451. private _origin;
  117452. private _options;
  117453. private _physicsEngine;
  117454. private _originTop;
  117455. private _originDirection;
  117456. private _tickCallback;
  117457. private _cylinder;
  117458. private _cylinderPosition;
  117459. private _dataFetched;
  117460. /**
  117461. * Initializes the physics updraft event
  117462. * @param _scene BabylonJS scene
  117463. * @param _origin The origin position of the updraft
  117464. * @param _options The options for the updraft event
  117465. */
  117466. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117467. /**
  117468. * Returns the data related to the updraft event (cylinder).
  117469. * @returns A physics updraft event
  117470. */
  117471. getData(): PhysicsUpdraftEventData;
  117472. /**
  117473. * Enables the updraft.
  117474. */
  117475. enable(): void;
  117476. /**
  117477. * Disables the updraft.
  117478. */
  117479. disable(): void;
  117480. /**
  117481. * Disposes the cylinder.
  117482. * @param force Specifies if the updraft should be disposed by force
  117483. */
  117484. dispose(force?: boolean): void;
  117485. private getImpostorHitData;
  117486. private _tick;
  117487. /*** Helpers ***/
  117488. private _prepareCylinder;
  117489. private _intersectsWithCylinder;
  117490. }
  117491. /**
  117492. * Represents a physics vortex event
  117493. */
  117494. class PhysicsVortexEvent {
  117495. private _scene;
  117496. private _origin;
  117497. private _options;
  117498. private _physicsEngine;
  117499. private _originTop;
  117500. private _tickCallback;
  117501. private _cylinder;
  117502. private _cylinderPosition;
  117503. private _dataFetched;
  117504. /**
  117505. * Initializes the physics vortex event
  117506. * @param _scene The BabylonJS scene
  117507. * @param _origin The origin position of the vortex
  117508. * @param _options The options for the vortex event
  117509. */
  117510. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117511. /**
  117512. * Returns the data related to the vortex event (cylinder).
  117513. * @returns The physics vortex event data
  117514. */
  117515. getData(): PhysicsVortexEventData;
  117516. /**
  117517. * Enables the vortex.
  117518. */
  117519. enable(): void;
  117520. /**
  117521. * Disables the cortex.
  117522. */
  117523. disable(): void;
  117524. /**
  117525. * Disposes the sphere.
  117526. * @param force
  117527. */
  117528. dispose(force?: boolean): void;
  117529. private getImpostorHitData;
  117530. private _tick;
  117531. /*** Helpers ***/
  117532. private _prepareCylinder;
  117533. private _intersectsWithCylinder;
  117534. }
  117535. /**
  117536. * Options fot the radial explosion event
  117537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117538. */
  117539. export class PhysicsRadialExplosionEventOptions {
  117540. /**
  117541. * The radius of the sphere for the radial explosion.
  117542. */
  117543. radius: number;
  117544. /**
  117545. * The strenth of the explosion.
  117546. */
  117547. strength: number;
  117548. /**
  117549. * The strenght of the force in correspondence to the distance of the affected object
  117550. */
  117551. falloff: PhysicsRadialImpulseFalloff;
  117552. /**
  117553. * Sphere options for the radial explosion.
  117554. */
  117555. sphere: {
  117556. segments: number;
  117557. diameter: number;
  117558. };
  117559. /**
  117560. * Sphere options for the radial explosion.
  117561. */
  117562. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117563. }
  117564. /**
  117565. * Options fot the updraft event
  117566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117567. */
  117568. export class PhysicsUpdraftEventOptions {
  117569. /**
  117570. * The radius of the cylinder for the vortex
  117571. */
  117572. radius: number;
  117573. /**
  117574. * The strenth of the updraft.
  117575. */
  117576. strength: number;
  117577. /**
  117578. * The height of the cylinder for the updraft.
  117579. */
  117580. height: number;
  117581. /**
  117582. * The mode for the the updraft.
  117583. */
  117584. updraftMode: PhysicsUpdraftMode;
  117585. }
  117586. /**
  117587. * Options fot the vortex event
  117588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117589. */
  117590. export class PhysicsVortexEventOptions {
  117591. /**
  117592. * The radius of the cylinder for the vortex
  117593. */
  117594. radius: number;
  117595. /**
  117596. * The strenth of the vortex.
  117597. */
  117598. strength: number;
  117599. /**
  117600. * The height of the cylinder for the vortex.
  117601. */
  117602. height: number;
  117603. /**
  117604. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117605. */
  117606. centripetalForceThreshold: number;
  117607. /**
  117608. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117609. */
  117610. centripetalForceMultiplier: number;
  117611. /**
  117612. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117613. */
  117614. centrifugalForceMultiplier: number;
  117615. /**
  117616. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117617. */
  117618. updraftForceMultiplier: number;
  117619. }
  117620. /**
  117621. * The strenght of the force in correspondence to the distance of the affected object
  117622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117623. */
  117624. export enum PhysicsRadialImpulseFalloff {
  117625. /** Defines that impulse is constant in strength across it's whole radius */
  117626. Constant = 0,
  117627. /** Defines that impulse gets weaker if it's further from the origin */
  117628. Linear = 1
  117629. }
  117630. /**
  117631. * The strength of the force in correspondence to the distance of the affected object
  117632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117633. */
  117634. export enum PhysicsUpdraftMode {
  117635. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117636. Center = 0,
  117637. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117638. Perpendicular = 1
  117639. }
  117640. /**
  117641. * Interface for a physics hit data
  117642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117643. */
  117644. export interface PhysicsHitData {
  117645. /**
  117646. * The force applied at the contact point
  117647. */
  117648. force: Vector3;
  117649. /**
  117650. * The contact point
  117651. */
  117652. contactPoint: Vector3;
  117653. /**
  117654. * The distance from the origin to the contact point
  117655. */
  117656. distanceFromOrigin: number;
  117657. }
  117658. /**
  117659. * Interface for radial explosion event data
  117660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117661. */
  117662. export interface PhysicsRadialExplosionEventData {
  117663. /**
  117664. * A sphere used for the radial explosion event
  117665. */
  117666. sphere: Mesh;
  117667. }
  117668. /**
  117669. * Interface for gravitational field event data
  117670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117671. */
  117672. export interface PhysicsGravitationalFieldEventData {
  117673. /**
  117674. * A sphere mesh used for the gravitational field event
  117675. */
  117676. sphere: Mesh;
  117677. }
  117678. /**
  117679. * Interface for updraft event data
  117680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117681. */
  117682. export interface PhysicsUpdraftEventData {
  117683. /**
  117684. * A cylinder used for the updraft event
  117685. */
  117686. cylinder: Mesh;
  117687. }
  117688. /**
  117689. * Interface for vortex event data
  117690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117691. */
  117692. export interface PhysicsVortexEventData {
  117693. /**
  117694. * A cylinder used for the vortex event
  117695. */
  117696. cylinder: Mesh;
  117697. }
  117698. /**
  117699. * Interface for an affected physics impostor
  117700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117701. */
  117702. export interface PhysicsAffectedImpostorWithData {
  117703. /**
  117704. * The impostor affected by the effect
  117705. */
  117706. impostor: PhysicsImpostor;
  117707. /**
  117708. * The data about the hit/horce from the explosion
  117709. */
  117710. hitData: PhysicsHitData;
  117711. }
  117712. }
  117713. declare module BABYLON {
  117714. /** @hidden */
  117715. export var blackAndWhitePixelShader: {
  117716. name: string;
  117717. shader: string;
  117718. };
  117719. }
  117720. declare module BABYLON {
  117721. /**
  117722. * Post process used to render in black and white
  117723. */
  117724. export class BlackAndWhitePostProcess extends PostProcess {
  117725. /**
  117726. * Linear about to convert he result to black and white (default: 1)
  117727. */
  117728. degree: number;
  117729. /**
  117730. * Creates a black and white post process
  117731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117732. * @param name The name of the effect.
  117733. * @param options The required width/height ratio to downsize to before computing the render pass.
  117734. * @param camera The camera to apply the render pass to.
  117735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117736. * @param engine The engine which the post process will be applied. (default: current engine)
  117737. * @param reusable If the post process can be reused on the same frame. (default: false)
  117738. */
  117739. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117740. }
  117741. }
  117742. declare module BABYLON {
  117743. /**
  117744. * This represents a set of one or more post processes in Babylon.
  117745. * A post process can be used to apply a shader to a texture after it is rendered.
  117746. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117747. */
  117748. export class PostProcessRenderEffect {
  117749. private _postProcesses;
  117750. private _getPostProcesses;
  117751. private _singleInstance;
  117752. private _cameras;
  117753. private _indicesForCamera;
  117754. /**
  117755. * Name of the effect
  117756. * @hidden
  117757. */
  117758. _name: string;
  117759. /**
  117760. * Instantiates a post process render effect.
  117761. * A post process can be used to apply a shader to a texture after it is rendered.
  117762. * @param engine The engine the effect is tied to
  117763. * @param name The name of the effect
  117764. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117765. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117766. */
  117767. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117768. /**
  117769. * Checks if all the post processes in the effect are supported.
  117770. */
  117771. readonly isSupported: boolean;
  117772. /**
  117773. * Updates the current state of the effect
  117774. * @hidden
  117775. */
  117776. _update(): void;
  117777. /**
  117778. * Attaches the effect on cameras
  117779. * @param cameras The camera to attach to.
  117780. * @hidden
  117781. */
  117782. _attachCameras(cameras: Camera): void;
  117783. /**
  117784. * Attaches the effect on cameras
  117785. * @param cameras The camera to attach to.
  117786. * @hidden
  117787. */
  117788. _attachCameras(cameras: Camera[]): void;
  117789. /**
  117790. * Detaches the effect on cameras
  117791. * @param cameras The camera to detatch from.
  117792. * @hidden
  117793. */
  117794. _detachCameras(cameras: Camera): void;
  117795. /**
  117796. * Detatches the effect on cameras
  117797. * @param cameras The camera to detatch from.
  117798. * @hidden
  117799. */
  117800. _detachCameras(cameras: Camera[]): void;
  117801. /**
  117802. * Enables the effect on given cameras
  117803. * @param cameras The camera to enable.
  117804. * @hidden
  117805. */
  117806. _enable(cameras: Camera): void;
  117807. /**
  117808. * Enables the effect on given cameras
  117809. * @param cameras The camera to enable.
  117810. * @hidden
  117811. */
  117812. _enable(cameras: Nullable<Camera[]>): void;
  117813. /**
  117814. * Disables the effect on the given cameras
  117815. * @param cameras The camera to disable.
  117816. * @hidden
  117817. */
  117818. _disable(cameras: Camera): void;
  117819. /**
  117820. * Disables the effect on the given cameras
  117821. * @param cameras The camera to disable.
  117822. * @hidden
  117823. */
  117824. _disable(cameras: Nullable<Camera[]>): void;
  117825. /**
  117826. * Gets a list of the post processes contained in the effect.
  117827. * @param camera The camera to get the post processes on.
  117828. * @returns The list of the post processes in the effect.
  117829. */
  117830. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117831. }
  117832. }
  117833. declare module BABYLON {
  117834. /** @hidden */
  117835. export var extractHighlightsPixelShader: {
  117836. name: string;
  117837. shader: string;
  117838. };
  117839. }
  117840. declare module BABYLON {
  117841. /**
  117842. * 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.
  117843. */
  117844. export class ExtractHighlightsPostProcess extends PostProcess {
  117845. /**
  117846. * The luminance threshold, pixels below this value will be set to black.
  117847. */
  117848. threshold: number;
  117849. /** @hidden */
  117850. _exposure: number;
  117851. /**
  117852. * Post process which has the input texture to be used when performing highlight extraction
  117853. * @hidden
  117854. */
  117855. _inputPostProcess: Nullable<PostProcess>;
  117856. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117857. }
  117858. }
  117859. declare module BABYLON {
  117860. /** @hidden */
  117861. export var bloomMergePixelShader: {
  117862. name: string;
  117863. shader: string;
  117864. };
  117865. }
  117866. declare module BABYLON {
  117867. /**
  117868. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117869. */
  117870. export class BloomMergePostProcess extends PostProcess {
  117871. /** Weight of the bloom to be added to the original input. */
  117872. weight: number;
  117873. /**
  117874. * Creates a new instance of @see BloomMergePostProcess
  117875. * @param name The name of the effect.
  117876. * @param originalFromInput Post process which's input will be used for the merge.
  117877. * @param blurred Blurred highlights post process which's output will be used.
  117878. * @param weight Weight of the bloom to be added to the original input.
  117879. * @param options The required width/height ratio to downsize to before computing the render pass.
  117880. * @param camera The camera to apply the render pass to.
  117881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117882. * @param engine The engine which the post process will be applied. (default: current engine)
  117883. * @param reusable If the post process can be reused on the same frame. (default: false)
  117884. * @param textureType Type of textures used when performing the post process. (default: 0)
  117885. * @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)
  117886. */
  117887. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117888. /** Weight of the bloom to be added to the original input. */
  117889. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117890. }
  117891. }
  117892. declare module BABYLON {
  117893. /**
  117894. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117895. */
  117896. export class BloomEffect extends PostProcessRenderEffect {
  117897. private bloomScale;
  117898. /**
  117899. * @hidden Internal
  117900. */
  117901. _effects: Array<PostProcess>;
  117902. /**
  117903. * @hidden Internal
  117904. */
  117905. _downscale: ExtractHighlightsPostProcess;
  117906. private _blurX;
  117907. private _blurY;
  117908. private _merge;
  117909. /**
  117910. * The luminance threshold to find bright areas of the image to bloom.
  117911. */
  117912. threshold: number;
  117913. /**
  117914. * The strength of the bloom.
  117915. */
  117916. weight: number;
  117917. /**
  117918. * Specifies the size of the bloom blur kernel, relative to the final output size
  117919. */
  117920. kernel: number;
  117921. /**
  117922. * Creates a new instance of @see BloomEffect
  117923. * @param scene The scene the effect belongs to.
  117924. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117925. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117926. * @param bloomWeight The the strength of bloom.
  117927. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117928. * @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)
  117929. */
  117930. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117931. /**
  117932. * Disposes each of the internal effects for a given camera.
  117933. * @param camera The camera to dispose the effect on.
  117934. */
  117935. disposeEffects(camera: Camera): void;
  117936. /**
  117937. * @hidden Internal
  117938. */
  117939. _updateEffects(): void;
  117940. /**
  117941. * Internal
  117942. * @returns if all the contained post processes are ready.
  117943. * @hidden
  117944. */
  117945. _isReady(): boolean;
  117946. }
  117947. }
  117948. declare module BABYLON {
  117949. /** @hidden */
  117950. export var chromaticAberrationPixelShader: {
  117951. name: string;
  117952. shader: string;
  117953. };
  117954. }
  117955. declare module BABYLON {
  117956. /**
  117957. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117958. */
  117959. export class ChromaticAberrationPostProcess extends PostProcess {
  117960. /**
  117961. * The amount of seperation of rgb channels (default: 30)
  117962. */
  117963. aberrationAmount: number;
  117964. /**
  117965. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117966. */
  117967. radialIntensity: number;
  117968. /**
  117969. * 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))
  117970. */
  117971. direction: Vector2;
  117972. /**
  117973. * 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))
  117974. */
  117975. centerPosition: Vector2;
  117976. /**
  117977. * Creates a new instance ChromaticAberrationPostProcess
  117978. * @param name The name of the effect.
  117979. * @param screenWidth The width of the screen to apply the effect on.
  117980. * @param screenHeight The height of the screen to apply the effect on.
  117981. * @param options The required width/height ratio to downsize to before computing the render pass.
  117982. * @param camera The camera to apply the render pass to.
  117983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117984. * @param engine The engine which the post process will be applied. (default: current engine)
  117985. * @param reusable If the post process can be reused on the same frame. (default: false)
  117986. * @param textureType Type of textures used when performing the post process. (default: 0)
  117987. * @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)
  117988. */
  117989. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117990. }
  117991. }
  117992. declare module BABYLON {
  117993. /** @hidden */
  117994. export var circleOfConfusionPixelShader: {
  117995. name: string;
  117996. shader: string;
  117997. };
  117998. }
  117999. declare module BABYLON {
  118000. /**
  118001. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118002. */
  118003. export class CircleOfConfusionPostProcess extends PostProcess {
  118004. /**
  118005. * 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.
  118006. */
  118007. lensSize: number;
  118008. /**
  118009. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118010. */
  118011. fStop: number;
  118012. /**
  118013. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118014. */
  118015. focusDistance: number;
  118016. /**
  118017. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  118018. */
  118019. focalLength: number;
  118020. private _depthTexture;
  118021. /**
  118022. * Creates a new instance CircleOfConfusionPostProcess
  118023. * @param name The name of the effect.
  118024. * @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.
  118025. * @param options The required width/height ratio to downsize to before computing the render pass.
  118026. * @param camera The camera to apply the render pass to.
  118027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118028. * @param engine The engine which the post process will be applied. (default: current engine)
  118029. * @param reusable If the post process can be reused on the same frame. (default: false)
  118030. * @param textureType Type of textures used when performing the post process. (default: 0)
  118031. * @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)
  118032. */
  118033. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118034. /**
  118035. * 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.
  118036. */
  118037. depthTexture: RenderTargetTexture;
  118038. }
  118039. }
  118040. declare module BABYLON {
  118041. /** @hidden */
  118042. export var colorCorrectionPixelShader: {
  118043. name: string;
  118044. shader: string;
  118045. };
  118046. }
  118047. declare module BABYLON {
  118048. /**
  118049. *
  118050. * This post-process allows the modification of rendered colors by using
  118051. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118052. *
  118053. * The object needs to be provided an url to a texture containing the color
  118054. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118055. * Use an image editing software to tweak the LUT to match your needs.
  118056. *
  118057. * For an example of a color LUT, see here:
  118058. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118059. * For explanations on color grading, see here:
  118060. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118061. *
  118062. */
  118063. export class ColorCorrectionPostProcess extends PostProcess {
  118064. private _colorTableTexture;
  118065. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118066. }
  118067. }
  118068. declare module BABYLON {
  118069. /** @hidden */
  118070. export var convolutionPixelShader: {
  118071. name: string;
  118072. shader: string;
  118073. };
  118074. }
  118075. declare module BABYLON {
  118076. /**
  118077. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118078. * input texture to perform effects such as edge detection or sharpening
  118079. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118080. */
  118081. export class ConvolutionPostProcess extends PostProcess {
  118082. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118083. kernel: number[];
  118084. /**
  118085. * Creates a new instance ConvolutionPostProcess
  118086. * @param name The name of the effect.
  118087. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118088. * @param options The required width/height ratio to downsize to before computing the render pass.
  118089. * @param camera The camera to apply the render pass to.
  118090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118091. * @param engine The engine which the post process will be applied. (default: current engine)
  118092. * @param reusable If the post process can be reused on the same frame. (default: false)
  118093. * @param textureType Type of textures used when performing the post process. (default: 0)
  118094. */
  118095. constructor(name: string,
  118096. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118097. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118098. /**
  118099. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118100. */
  118101. static EdgeDetect0Kernel: number[];
  118102. /**
  118103. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118104. */
  118105. static EdgeDetect1Kernel: number[];
  118106. /**
  118107. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118108. */
  118109. static EdgeDetect2Kernel: number[];
  118110. /**
  118111. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118112. */
  118113. static SharpenKernel: number[];
  118114. /**
  118115. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118116. */
  118117. static EmbossKernel: number[];
  118118. /**
  118119. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118120. */
  118121. static GaussianKernel: number[];
  118122. }
  118123. }
  118124. declare module BABYLON {
  118125. /**
  118126. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118127. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118128. * based on samples that have a large difference in distance than the center pixel.
  118129. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118130. */
  118131. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118132. direction: Vector2;
  118133. /**
  118134. * Creates a new instance CircleOfConfusionPostProcess
  118135. * @param name The name of the effect.
  118136. * @param scene The scene the effect belongs to.
  118137. * @param direction The direction the blur should be applied.
  118138. * @param kernel The size of the kernel used to blur.
  118139. * @param options The required width/height ratio to downsize to before computing the render pass.
  118140. * @param camera The camera to apply the render pass to.
  118141. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118142. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118144. * @param engine The engine which the post process will be applied. (default: current engine)
  118145. * @param reusable If the post process can be reused on the same frame. (default: false)
  118146. * @param textureType Type of textures used when performing the post process. (default: 0)
  118147. * @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)
  118148. */
  118149. 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);
  118150. }
  118151. }
  118152. declare module BABYLON {
  118153. /** @hidden */
  118154. export var depthOfFieldMergePixelShader: {
  118155. name: string;
  118156. shader: string;
  118157. };
  118158. }
  118159. declare module BABYLON {
  118160. /**
  118161. * Options to be set when merging outputs from the default pipeline.
  118162. */
  118163. export class DepthOfFieldMergePostProcessOptions {
  118164. /**
  118165. * The original image to merge on top of
  118166. */
  118167. originalFromInput: PostProcess;
  118168. /**
  118169. * Parameters to perform the merge of the depth of field effect
  118170. */
  118171. depthOfField?: {
  118172. circleOfConfusion: PostProcess;
  118173. blurSteps: Array<PostProcess>;
  118174. };
  118175. /**
  118176. * Parameters to perform the merge of bloom effect
  118177. */
  118178. bloom?: {
  118179. blurred: PostProcess;
  118180. weight: number;
  118181. };
  118182. }
  118183. /**
  118184. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118185. */
  118186. export class DepthOfFieldMergePostProcess extends PostProcess {
  118187. private blurSteps;
  118188. /**
  118189. * Creates a new instance of DepthOfFieldMergePostProcess
  118190. * @param name The name of the effect.
  118191. * @param originalFromInput Post process which's input will be used for the merge.
  118192. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118193. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118194. * @param options The required width/height ratio to downsize to before computing the render pass.
  118195. * @param camera The camera to apply the render pass to.
  118196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118197. * @param engine The engine which the post process will be applied. (default: current engine)
  118198. * @param reusable If the post process can be reused on the same frame. (default: false)
  118199. * @param textureType Type of textures used when performing the post process. (default: 0)
  118200. * @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)
  118201. */
  118202. 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);
  118203. /**
  118204. * Updates the effect with the current post process compile time values and recompiles the shader.
  118205. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118206. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118207. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118208. * @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
  118209. * @param onCompiled Called when the shader has been compiled.
  118210. * @param onError Called if there is an error when compiling a shader.
  118211. */
  118212. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118213. }
  118214. }
  118215. declare module BABYLON {
  118216. /**
  118217. * Specifies the level of max blur that should be applied when using the depth of field effect
  118218. */
  118219. export enum DepthOfFieldEffectBlurLevel {
  118220. /**
  118221. * Subtle blur
  118222. */
  118223. Low = 0,
  118224. /**
  118225. * Medium blur
  118226. */
  118227. Medium = 1,
  118228. /**
  118229. * Large blur
  118230. */
  118231. High = 2
  118232. }
  118233. /**
  118234. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118235. */
  118236. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118237. private _circleOfConfusion;
  118238. /**
  118239. * @hidden Internal, blurs from high to low
  118240. */
  118241. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118242. private _depthOfFieldBlurY;
  118243. private _dofMerge;
  118244. /**
  118245. * @hidden Internal post processes in depth of field effect
  118246. */
  118247. _effects: Array<PostProcess>;
  118248. /**
  118249. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118250. */
  118251. focalLength: number;
  118252. /**
  118253. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118254. */
  118255. fStop: number;
  118256. /**
  118257. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118258. */
  118259. focusDistance: number;
  118260. /**
  118261. * 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.
  118262. */
  118263. lensSize: number;
  118264. /**
  118265. * Creates a new instance DepthOfFieldEffect
  118266. * @param scene The scene the effect belongs to.
  118267. * @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.
  118268. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118269. * @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)
  118270. */
  118271. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118272. /**
  118273. * Get the current class name of the current effet
  118274. * @returns "DepthOfFieldEffect"
  118275. */
  118276. getClassName(): string;
  118277. /**
  118278. * 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.
  118279. */
  118280. depthTexture: RenderTargetTexture;
  118281. /**
  118282. * Disposes each of the internal effects for a given camera.
  118283. * @param camera The camera to dispose the effect on.
  118284. */
  118285. disposeEffects(camera: Camera): void;
  118286. /**
  118287. * @hidden Internal
  118288. */
  118289. _updateEffects(): void;
  118290. /**
  118291. * Internal
  118292. * @returns if all the contained post processes are ready.
  118293. * @hidden
  118294. */
  118295. _isReady(): boolean;
  118296. }
  118297. }
  118298. declare module BABYLON {
  118299. /** @hidden */
  118300. export var displayPassPixelShader: {
  118301. name: string;
  118302. shader: string;
  118303. };
  118304. }
  118305. declare module BABYLON {
  118306. /**
  118307. * DisplayPassPostProcess which produces an output the same as it's input
  118308. */
  118309. export class DisplayPassPostProcess extends PostProcess {
  118310. /**
  118311. * Creates the DisplayPassPostProcess
  118312. * @param name The name of the effect.
  118313. * @param options The required width/height ratio to downsize to before computing the render pass.
  118314. * @param camera The camera to apply the render pass to.
  118315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118316. * @param engine The engine which the post process will be applied. (default: current engine)
  118317. * @param reusable If the post process can be reused on the same frame. (default: false)
  118318. */
  118319. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118320. }
  118321. }
  118322. declare module BABYLON {
  118323. /** @hidden */
  118324. export var filterPixelShader: {
  118325. name: string;
  118326. shader: string;
  118327. };
  118328. }
  118329. declare module BABYLON {
  118330. /**
  118331. * Applies a kernel filter to the image
  118332. */
  118333. export class FilterPostProcess extends PostProcess {
  118334. /** The matrix to be applied to the image */
  118335. kernelMatrix: Matrix;
  118336. /**
  118337. *
  118338. * @param name The name of the effect.
  118339. * @param kernelMatrix The matrix to be applied to the image
  118340. * @param options The required width/height ratio to downsize to before computing the render pass.
  118341. * @param camera The camera to apply the render pass to.
  118342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118343. * @param engine The engine which the post process will be applied. (default: current engine)
  118344. * @param reusable If the post process can be reused on the same frame. (default: false)
  118345. */
  118346. constructor(name: string,
  118347. /** The matrix to be applied to the image */
  118348. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118349. }
  118350. }
  118351. declare module BABYLON {
  118352. /** @hidden */
  118353. export var fxaaPixelShader: {
  118354. name: string;
  118355. shader: string;
  118356. };
  118357. }
  118358. declare module BABYLON {
  118359. /** @hidden */
  118360. export var fxaaVertexShader: {
  118361. name: string;
  118362. shader: string;
  118363. };
  118364. }
  118365. declare module BABYLON {
  118366. /**
  118367. * Fxaa post process
  118368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118369. */
  118370. export class FxaaPostProcess extends PostProcess {
  118371. /** @hidden */
  118372. texelWidth: number;
  118373. /** @hidden */
  118374. texelHeight: number;
  118375. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118376. private _getDefines;
  118377. }
  118378. }
  118379. declare module BABYLON {
  118380. /** @hidden */
  118381. export var grainPixelShader: {
  118382. name: string;
  118383. shader: string;
  118384. };
  118385. }
  118386. declare module BABYLON {
  118387. /**
  118388. * The GrainPostProcess adds noise to the image at mid luminance levels
  118389. */
  118390. export class GrainPostProcess extends PostProcess {
  118391. /**
  118392. * The intensity of the grain added (default: 30)
  118393. */
  118394. intensity: number;
  118395. /**
  118396. * If the grain should be randomized on every frame
  118397. */
  118398. animated: boolean;
  118399. /**
  118400. * Creates a new instance of @see GrainPostProcess
  118401. * @param name The name of the effect.
  118402. * @param options The required width/height ratio to downsize to before computing the render pass.
  118403. * @param camera The camera to apply the render pass to.
  118404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118405. * @param engine The engine which the post process will be applied. (default: current engine)
  118406. * @param reusable If the post process can be reused on the same frame. (default: false)
  118407. * @param textureType Type of textures used when performing the post process. (default: 0)
  118408. * @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)
  118409. */
  118410. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118411. }
  118412. }
  118413. declare module BABYLON {
  118414. /** @hidden */
  118415. export var highlightsPixelShader: {
  118416. name: string;
  118417. shader: string;
  118418. };
  118419. }
  118420. declare module BABYLON {
  118421. /**
  118422. * Extracts highlights from the image
  118423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118424. */
  118425. export class HighlightsPostProcess extends PostProcess {
  118426. /**
  118427. * Extracts highlights from the image
  118428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118429. * @param name The name of the effect.
  118430. * @param options The required width/height ratio to downsize to before computing the render pass.
  118431. * @param camera The camera to apply the render pass to.
  118432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118433. * @param engine The engine which the post process will be applied. (default: current engine)
  118434. * @param reusable If the post process can be reused on the same frame. (default: false)
  118435. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118436. */
  118437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118438. }
  118439. }
  118440. declare module BABYLON {
  118441. /** @hidden */
  118442. export var mrtFragmentDeclaration: {
  118443. name: string;
  118444. shader: string;
  118445. };
  118446. }
  118447. declare module BABYLON {
  118448. /** @hidden */
  118449. export var geometryPixelShader: {
  118450. name: string;
  118451. shader: string;
  118452. };
  118453. }
  118454. declare module BABYLON {
  118455. /** @hidden */
  118456. export var geometryVertexShader: {
  118457. name: string;
  118458. shader: string;
  118459. };
  118460. }
  118461. declare module BABYLON {
  118462. /** @hidden */
  118463. interface ISavedTransformationMatrix {
  118464. world: Matrix;
  118465. viewProjection: Matrix;
  118466. }
  118467. /**
  118468. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118469. */
  118470. export class GeometryBufferRenderer {
  118471. /**
  118472. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118473. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118474. */
  118475. static readonly POSITION_TEXTURE_TYPE: number;
  118476. /**
  118477. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118478. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118479. */
  118480. static readonly VELOCITY_TEXTURE_TYPE: number;
  118481. /**
  118482. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118483. * in order to compute objects velocities when enableVelocity is set to "true"
  118484. * @hidden
  118485. */
  118486. _previousTransformationMatrices: {
  118487. [index: number]: ISavedTransformationMatrix;
  118488. };
  118489. /**
  118490. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118491. * in order to compute objects velocities when enableVelocity is set to "true"
  118492. * @hidden
  118493. */
  118494. _previousBonesTransformationMatrices: {
  118495. [index: number]: Float32Array;
  118496. };
  118497. /**
  118498. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118499. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118500. */
  118501. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118502. private _scene;
  118503. private _multiRenderTarget;
  118504. private _ratio;
  118505. private _enablePosition;
  118506. private _enableVelocity;
  118507. private _positionIndex;
  118508. private _velocityIndex;
  118509. protected _effect: Effect;
  118510. protected _cachedDefines: string;
  118511. /**
  118512. * Set the render list (meshes to be rendered) used in the G buffer.
  118513. */
  118514. renderList: Mesh[];
  118515. /**
  118516. * Gets wether or not G buffer are supported by the running hardware.
  118517. * This requires draw buffer supports
  118518. */
  118519. readonly isSupported: boolean;
  118520. /**
  118521. * Returns the index of the given texture type in the G-Buffer textures array
  118522. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118523. * @returns the index of the given texture type in the G-Buffer textures array
  118524. */
  118525. getTextureIndex(textureType: number): number;
  118526. /**
  118527. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118528. */
  118529. /**
  118530. * Sets whether or not objects positions are enabled for the G buffer.
  118531. */
  118532. enablePosition: boolean;
  118533. /**
  118534. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118535. */
  118536. /**
  118537. * Sets wether or not objects velocities are enabled for the G buffer.
  118538. */
  118539. enableVelocity: boolean;
  118540. /**
  118541. * Gets the scene associated with the buffer.
  118542. */
  118543. readonly scene: Scene;
  118544. /**
  118545. * Gets the ratio used by the buffer during its creation.
  118546. * How big is the buffer related to the main canvas.
  118547. */
  118548. readonly ratio: number;
  118549. /** @hidden */
  118550. static _SceneComponentInitialization: (scene: Scene) => void;
  118551. /**
  118552. * Creates a new G Buffer for the scene
  118553. * @param scene The scene the buffer belongs to
  118554. * @param ratio How big is the buffer related to the main canvas.
  118555. */
  118556. constructor(scene: Scene, ratio?: number);
  118557. /**
  118558. * Checks wether everything is ready to render a submesh to the G buffer.
  118559. * @param subMesh the submesh to check readiness for
  118560. * @param useInstances is the mesh drawn using instance or not
  118561. * @returns true if ready otherwise false
  118562. */
  118563. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118564. /**
  118565. * Gets the current underlying G Buffer.
  118566. * @returns the buffer
  118567. */
  118568. getGBuffer(): MultiRenderTarget;
  118569. /**
  118570. * Gets the number of samples used to render the buffer (anti aliasing).
  118571. */
  118572. /**
  118573. * Sets the number of samples used to render the buffer (anti aliasing).
  118574. */
  118575. samples: number;
  118576. /**
  118577. * Disposes the renderer and frees up associated resources.
  118578. */
  118579. dispose(): void;
  118580. protected _createRenderTargets(): void;
  118581. private _copyBonesTransformationMatrices;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. interface Scene {
  118586. /** @hidden (Backing field) */
  118587. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118588. /**
  118589. * Gets or Sets the current geometry buffer associated to the scene.
  118590. */
  118591. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118592. /**
  118593. * Enables a GeometryBufferRender and associates it with the scene
  118594. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118595. * @returns the GeometryBufferRenderer
  118596. */
  118597. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118598. /**
  118599. * Disables the GeometryBufferRender associated with the scene
  118600. */
  118601. disableGeometryBufferRenderer(): void;
  118602. }
  118603. /**
  118604. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118605. * in several rendering techniques.
  118606. */
  118607. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118608. /**
  118609. * The component name helpful to identify the component in the list of scene components.
  118610. */
  118611. readonly name: string;
  118612. /**
  118613. * The scene the component belongs to.
  118614. */
  118615. scene: Scene;
  118616. /**
  118617. * Creates a new instance of the component for the given scene
  118618. * @param scene Defines the scene to register the component in
  118619. */
  118620. constructor(scene: Scene);
  118621. /**
  118622. * Registers the component in a given scene
  118623. */
  118624. register(): void;
  118625. /**
  118626. * Rebuilds the elements related to this component in case of
  118627. * context lost for instance.
  118628. */
  118629. rebuild(): void;
  118630. /**
  118631. * Disposes the component and the associated ressources
  118632. */
  118633. dispose(): void;
  118634. private _gatherRenderTargets;
  118635. }
  118636. }
  118637. declare module BABYLON {
  118638. /** @hidden */
  118639. export var motionBlurPixelShader: {
  118640. name: string;
  118641. shader: string;
  118642. };
  118643. }
  118644. declare module BABYLON {
  118645. /**
  118646. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118647. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118648. * As an example, all you have to do is to create the post-process:
  118649. * var mb = new BABYLON.MotionBlurPostProcess(
  118650. * 'mb', // The name of the effect.
  118651. * scene, // The scene containing the objects to blur according to their velocity.
  118652. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118653. * camera // The camera to apply the render pass to.
  118654. * );
  118655. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118656. */
  118657. export class MotionBlurPostProcess extends PostProcess {
  118658. /**
  118659. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118660. */
  118661. motionStrength: number;
  118662. /**
  118663. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118664. */
  118665. /**
  118666. * Sets the number of iterations to be used for motion blur quality
  118667. */
  118668. motionBlurSamples: number;
  118669. private _motionBlurSamples;
  118670. private _geometryBufferRenderer;
  118671. /**
  118672. * Creates a new instance MotionBlurPostProcess
  118673. * @param name The name of the effect.
  118674. * @param scene The scene containing the objects to blur according to their velocity.
  118675. * @param options The required width/height ratio to downsize to before computing the render pass.
  118676. * @param camera The camera to apply the render pass to.
  118677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118678. * @param engine The engine which the post process will be applied. (default: current engine)
  118679. * @param reusable If the post process can be reused on the same frame. (default: false)
  118680. * @param textureType Type of textures used when performing the post process. (default: 0)
  118681. * @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)
  118682. */
  118683. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118684. /**
  118685. * Excludes the given skinned mesh from computing bones velocities.
  118686. * 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.
  118687. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118688. */
  118689. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118690. /**
  118691. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118692. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118693. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118694. */
  118695. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118696. /**
  118697. * Disposes the post process.
  118698. * @param camera The camera to dispose the post process on.
  118699. */
  118700. dispose(camera?: Camera): void;
  118701. }
  118702. }
  118703. declare module BABYLON {
  118704. /** @hidden */
  118705. export var refractionPixelShader: {
  118706. name: string;
  118707. shader: string;
  118708. };
  118709. }
  118710. declare module BABYLON {
  118711. /**
  118712. * Post process which applies a refractin texture
  118713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118714. */
  118715. export class RefractionPostProcess extends PostProcess {
  118716. /** the base color of the refraction (used to taint the rendering) */
  118717. color: Color3;
  118718. /** simulated refraction depth */
  118719. depth: number;
  118720. /** the coefficient of the base color (0 to remove base color tainting) */
  118721. colorLevel: number;
  118722. private _refTexture;
  118723. private _ownRefractionTexture;
  118724. /**
  118725. * Gets or sets the refraction texture
  118726. * Please note that you are responsible for disposing the texture if you set it manually
  118727. */
  118728. refractionTexture: Texture;
  118729. /**
  118730. * Initializes the RefractionPostProcess
  118731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118732. * @param name The name of the effect.
  118733. * @param refractionTextureUrl Url of the refraction texture to use
  118734. * @param color the base color of the refraction (used to taint the rendering)
  118735. * @param depth simulated refraction depth
  118736. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118737. * @param camera The camera to apply the render pass to.
  118738. * @param options The required width/height ratio to downsize to before computing the render pass.
  118739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118740. * @param engine The engine which the post process will be applied. (default: current engine)
  118741. * @param reusable If the post process can be reused on the same frame. (default: false)
  118742. */
  118743. constructor(name: string, refractionTextureUrl: string,
  118744. /** the base color of the refraction (used to taint the rendering) */
  118745. color: Color3,
  118746. /** simulated refraction depth */
  118747. depth: number,
  118748. /** the coefficient of the base color (0 to remove base color tainting) */
  118749. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118750. /**
  118751. * Disposes of the post process
  118752. * @param camera Camera to dispose post process on
  118753. */
  118754. dispose(camera: Camera): void;
  118755. }
  118756. }
  118757. declare module BABYLON {
  118758. /** @hidden */
  118759. export var sharpenPixelShader: {
  118760. name: string;
  118761. shader: string;
  118762. };
  118763. }
  118764. declare module BABYLON {
  118765. /**
  118766. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118767. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118768. */
  118769. export class SharpenPostProcess extends PostProcess {
  118770. /**
  118771. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118772. */
  118773. colorAmount: number;
  118774. /**
  118775. * How much sharpness should be applied (default: 0.3)
  118776. */
  118777. edgeAmount: number;
  118778. /**
  118779. * Creates a new instance ConvolutionPostProcess
  118780. * @param name The name of the effect.
  118781. * @param options The required width/height ratio to downsize to before computing the render pass.
  118782. * @param camera The camera to apply the render pass to.
  118783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118784. * @param engine The engine which the post process will be applied. (default: current engine)
  118785. * @param reusable If the post process can be reused on the same frame. (default: false)
  118786. * @param textureType Type of textures used when performing the post process. (default: 0)
  118787. * @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)
  118788. */
  118789. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118790. }
  118791. }
  118792. declare module BABYLON {
  118793. /**
  118794. * PostProcessRenderPipeline
  118795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118796. */
  118797. export class PostProcessRenderPipeline {
  118798. private engine;
  118799. private _renderEffects;
  118800. private _renderEffectsForIsolatedPass;
  118801. /**
  118802. * List of inspectable custom properties (used by the Inspector)
  118803. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118804. */
  118805. inspectableCustomProperties: IInspectable[];
  118806. /**
  118807. * @hidden
  118808. */
  118809. protected _cameras: Camera[];
  118810. /** @hidden */
  118811. _name: string;
  118812. /**
  118813. * Gets pipeline name
  118814. */
  118815. readonly name: string;
  118816. /**
  118817. * Initializes a PostProcessRenderPipeline
  118818. * @param engine engine to add the pipeline to
  118819. * @param name name of the pipeline
  118820. */
  118821. constructor(engine: Engine, name: string);
  118822. /**
  118823. * Gets the class name
  118824. * @returns "PostProcessRenderPipeline"
  118825. */
  118826. getClassName(): string;
  118827. /**
  118828. * If all the render effects in the pipeline are supported
  118829. */
  118830. readonly isSupported: boolean;
  118831. /**
  118832. * Adds an effect to the pipeline
  118833. * @param renderEffect the effect to add
  118834. */
  118835. addEffect(renderEffect: PostProcessRenderEffect): void;
  118836. /** @hidden */
  118837. _rebuild(): void;
  118838. /** @hidden */
  118839. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118840. /** @hidden */
  118841. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118842. /** @hidden */
  118843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118844. /** @hidden */
  118845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118846. /** @hidden */
  118847. _attachCameras(cameras: Camera, unique: boolean): void;
  118848. /** @hidden */
  118849. _attachCameras(cameras: Camera[], unique: boolean): void;
  118850. /** @hidden */
  118851. _detachCameras(cameras: Camera): void;
  118852. /** @hidden */
  118853. _detachCameras(cameras: Nullable<Camera[]>): void;
  118854. /** @hidden */
  118855. _update(): void;
  118856. /** @hidden */
  118857. _reset(): void;
  118858. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118859. /**
  118860. * Disposes of the pipeline
  118861. */
  118862. dispose(): void;
  118863. }
  118864. }
  118865. declare module BABYLON {
  118866. /**
  118867. * PostProcessRenderPipelineManager class
  118868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118869. */
  118870. export class PostProcessRenderPipelineManager {
  118871. private _renderPipelines;
  118872. /**
  118873. * Initializes a PostProcessRenderPipelineManager
  118874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118875. */
  118876. constructor();
  118877. /**
  118878. * Gets the list of supported render pipelines
  118879. */
  118880. readonly supportedPipelines: PostProcessRenderPipeline[];
  118881. /**
  118882. * Adds a pipeline to the manager
  118883. * @param renderPipeline The pipeline to add
  118884. */
  118885. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118886. /**
  118887. * Attaches a camera to the pipeline
  118888. * @param renderPipelineName The name of the pipeline to attach to
  118889. * @param cameras the camera to attach
  118890. * @param unique if the camera can be attached multiple times to the pipeline
  118891. */
  118892. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118893. /**
  118894. * Detaches a camera from the pipeline
  118895. * @param renderPipelineName The name of the pipeline to detach from
  118896. * @param cameras the camera to detach
  118897. */
  118898. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118899. /**
  118900. * Enables an effect by name on a pipeline
  118901. * @param renderPipelineName the name of the pipeline to enable the effect in
  118902. * @param renderEffectName the name of the effect to enable
  118903. * @param cameras the cameras that the effect should be enabled on
  118904. */
  118905. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118906. /**
  118907. * Disables an effect by name on a pipeline
  118908. * @param renderPipelineName the name of the pipeline to disable the effect in
  118909. * @param renderEffectName the name of the effect to disable
  118910. * @param cameras the cameras that the effect should be disabled on
  118911. */
  118912. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118913. /**
  118914. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118915. */
  118916. update(): void;
  118917. /** @hidden */
  118918. _rebuild(): void;
  118919. /**
  118920. * Disposes of the manager and pipelines
  118921. */
  118922. dispose(): void;
  118923. }
  118924. }
  118925. declare module BABYLON {
  118926. interface Scene {
  118927. /** @hidden (Backing field) */
  118928. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118929. /**
  118930. * Gets the postprocess render pipeline manager
  118931. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118932. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118933. */
  118934. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118935. }
  118936. /**
  118937. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118938. */
  118939. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118940. /**
  118941. * The component name helpfull to identify the component in the list of scene components.
  118942. */
  118943. readonly name: string;
  118944. /**
  118945. * The scene the component belongs to.
  118946. */
  118947. scene: Scene;
  118948. /**
  118949. * Creates a new instance of the component for the given scene
  118950. * @param scene Defines the scene to register the component in
  118951. */
  118952. constructor(scene: Scene);
  118953. /**
  118954. * Registers the component in a given scene
  118955. */
  118956. register(): void;
  118957. /**
  118958. * Rebuilds the elements related to this component in case of
  118959. * context lost for instance.
  118960. */
  118961. rebuild(): void;
  118962. /**
  118963. * Disposes the component and the associated ressources
  118964. */
  118965. dispose(): void;
  118966. private _gatherRenderTargets;
  118967. }
  118968. }
  118969. declare module BABYLON {
  118970. /**
  118971. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118972. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118973. */
  118974. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118975. private _scene;
  118976. private _camerasToBeAttached;
  118977. /**
  118978. * ID of the sharpen post process,
  118979. */
  118980. private readonly SharpenPostProcessId;
  118981. /**
  118982. * @ignore
  118983. * ID of the image processing post process;
  118984. */
  118985. readonly ImageProcessingPostProcessId: string;
  118986. /**
  118987. * @ignore
  118988. * ID of the Fast Approximate Anti-Aliasing post process;
  118989. */
  118990. readonly FxaaPostProcessId: string;
  118991. /**
  118992. * ID of the chromatic aberration post process,
  118993. */
  118994. private readonly ChromaticAberrationPostProcessId;
  118995. /**
  118996. * ID of the grain post process
  118997. */
  118998. private readonly GrainPostProcessId;
  118999. /**
  119000. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119001. */
  119002. sharpen: SharpenPostProcess;
  119003. private _sharpenEffect;
  119004. private bloom;
  119005. /**
  119006. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119007. */
  119008. depthOfField: DepthOfFieldEffect;
  119009. /**
  119010. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119011. */
  119012. fxaa: FxaaPostProcess;
  119013. /**
  119014. * Image post processing pass used to perform operations such as tone mapping or color grading.
  119015. */
  119016. imageProcessing: ImageProcessingPostProcess;
  119017. /**
  119018. * Chromatic aberration post process which will shift rgb colors in the image
  119019. */
  119020. chromaticAberration: ChromaticAberrationPostProcess;
  119021. private _chromaticAberrationEffect;
  119022. /**
  119023. * Grain post process which add noise to the image
  119024. */
  119025. grain: GrainPostProcess;
  119026. private _grainEffect;
  119027. /**
  119028. * Glow post process which adds a glow to emissive areas of the image
  119029. */
  119030. private _glowLayer;
  119031. /**
  119032. * Animations which can be used to tweak settings over a period of time
  119033. */
  119034. animations: Animation[];
  119035. private _imageProcessingConfigurationObserver;
  119036. private _sharpenEnabled;
  119037. private _bloomEnabled;
  119038. private _depthOfFieldEnabled;
  119039. private _depthOfFieldBlurLevel;
  119040. private _fxaaEnabled;
  119041. private _imageProcessingEnabled;
  119042. private _defaultPipelineTextureType;
  119043. private _bloomScale;
  119044. private _chromaticAberrationEnabled;
  119045. private _grainEnabled;
  119046. private _buildAllowed;
  119047. /**
  119048. * Gets active scene
  119049. */
  119050. readonly scene: Scene;
  119051. /**
  119052. * Enable or disable the sharpen process from the pipeline
  119053. */
  119054. sharpenEnabled: boolean;
  119055. private _resizeObserver;
  119056. private _hardwareScaleLevel;
  119057. private _bloomKernel;
  119058. /**
  119059. * Specifies the size of the bloom blur kernel, relative to the final output size
  119060. */
  119061. bloomKernel: number;
  119062. /**
  119063. * Specifies the weight of the bloom in the final rendering
  119064. */
  119065. private _bloomWeight;
  119066. /**
  119067. * Specifies the luma threshold for the area that will be blurred by the bloom
  119068. */
  119069. private _bloomThreshold;
  119070. private _hdr;
  119071. /**
  119072. * The strength of the bloom.
  119073. */
  119074. bloomWeight: number;
  119075. /**
  119076. * The strength of the bloom.
  119077. */
  119078. bloomThreshold: number;
  119079. /**
  119080. * The scale of the bloom, lower value will provide better performance.
  119081. */
  119082. bloomScale: number;
  119083. /**
  119084. * Enable or disable the bloom from the pipeline
  119085. */
  119086. bloomEnabled: boolean;
  119087. private _rebuildBloom;
  119088. /**
  119089. * If the depth of field is enabled.
  119090. */
  119091. depthOfFieldEnabled: boolean;
  119092. /**
  119093. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119094. */
  119095. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119096. /**
  119097. * If the anti aliasing is enabled.
  119098. */
  119099. fxaaEnabled: boolean;
  119100. private _samples;
  119101. /**
  119102. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119103. */
  119104. samples: number;
  119105. /**
  119106. * If image processing is enabled.
  119107. */
  119108. imageProcessingEnabled: boolean;
  119109. /**
  119110. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119111. */
  119112. glowLayerEnabled: boolean;
  119113. /**
  119114. * Gets the glow layer (or null if not defined)
  119115. */
  119116. readonly glowLayer: Nullable<GlowLayer>;
  119117. /**
  119118. * Enable or disable the chromaticAberration process from the pipeline
  119119. */
  119120. chromaticAberrationEnabled: boolean;
  119121. /**
  119122. * Enable or disable the grain process from the pipeline
  119123. */
  119124. grainEnabled: boolean;
  119125. /**
  119126. * @constructor
  119127. * @param name - The rendering pipeline name (default: "")
  119128. * @param hdr - If high dynamic range textures should be used (default: true)
  119129. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119130. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119131. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119132. */
  119133. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119134. /**
  119135. * Get the class name
  119136. * @returns "DefaultRenderingPipeline"
  119137. */
  119138. getClassName(): string;
  119139. /**
  119140. * Force the compilation of the entire pipeline.
  119141. */
  119142. prepare(): void;
  119143. private _hasCleared;
  119144. private _prevPostProcess;
  119145. private _prevPrevPostProcess;
  119146. private _setAutoClearAndTextureSharing;
  119147. private _depthOfFieldSceneObserver;
  119148. private _buildPipeline;
  119149. private _disposePostProcesses;
  119150. /**
  119151. * Adds a camera to the pipeline
  119152. * @param camera the camera to be added
  119153. */
  119154. addCamera(camera: Camera): void;
  119155. /**
  119156. * Removes a camera from the pipeline
  119157. * @param camera the camera to remove
  119158. */
  119159. removeCamera(camera: Camera): void;
  119160. /**
  119161. * Dispose of the pipeline and stop all post processes
  119162. */
  119163. dispose(): void;
  119164. /**
  119165. * Serialize the rendering pipeline (Used when exporting)
  119166. * @returns the serialized object
  119167. */
  119168. serialize(): any;
  119169. /**
  119170. * Parse the serialized pipeline
  119171. * @param source Source pipeline.
  119172. * @param scene The scene to load the pipeline to.
  119173. * @param rootUrl The URL of the serialized pipeline.
  119174. * @returns An instantiated pipeline from the serialized object.
  119175. */
  119176. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119177. }
  119178. }
  119179. declare module BABYLON {
  119180. /** @hidden */
  119181. export var lensHighlightsPixelShader: {
  119182. name: string;
  119183. shader: string;
  119184. };
  119185. }
  119186. declare module BABYLON {
  119187. /** @hidden */
  119188. export var depthOfFieldPixelShader: {
  119189. name: string;
  119190. shader: string;
  119191. };
  119192. }
  119193. declare module BABYLON {
  119194. /**
  119195. * BABYLON.JS Chromatic Aberration GLSL Shader
  119196. * Author: Olivier Guyot
  119197. * Separates very slightly R, G and B colors on the edges of the screen
  119198. * Inspired by Francois Tarlier & Martins Upitis
  119199. */
  119200. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119201. /**
  119202. * @ignore
  119203. * The chromatic aberration PostProcess id in the pipeline
  119204. */
  119205. LensChromaticAberrationEffect: string;
  119206. /**
  119207. * @ignore
  119208. * The highlights enhancing PostProcess id in the pipeline
  119209. */
  119210. HighlightsEnhancingEffect: string;
  119211. /**
  119212. * @ignore
  119213. * The depth-of-field PostProcess id in the pipeline
  119214. */
  119215. LensDepthOfFieldEffect: string;
  119216. private _scene;
  119217. private _depthTexture;
  119218. private _grainTexture;
  119219. private _chromaticAberrationPostProcess;
  119220. private _highlightsPostProcess;
  119221. private _depthOfFieldPostProcess;
  119222. private _edgeBlur;
  119223. private _grainAmount;
  119224. private _chromaticAberration;
  119225. private _distortion;
  119226. private _highlightsGain;
  119227. private _highlightsThreshold;
  119228. private _dofDistance;
  119229. private _dofAperture;
  119230. private _dofDarken;
  119231. private _dofPentagon;
  119232. private _blurNoise;
  119233. /**
  119234. * @constructor
  119235. *
  119236. * Effect parameters are as follow:
  119237. * {
  119238. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119239. * edge_blur: number; // from 0 to x (1 for realism)
  119240. * distortion: number; // from 0 to x (1 for realism)
  119241. * grain_amount: number; // from 0 to 1
  119242. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119243. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119244. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119245. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119246. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119247. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119248. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119249. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119250. * }
  119251. * Note: if an effect parameter is unset, effect is disabled
  119252. *
  119253. * @param name The rendering pipeline name
  119254. * @param parameters - An object containing all parameters (see above)
  119255. * @param scene The scene linked to this pipeline
  119256. * @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)
  119257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119258. */
  119259. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119260. /**
  119261. * Get the class name
  119262. * @returns "LensRenderingPipeline"
  119263. */
  119264. getClassName(): string;
  119265. /**
  119266. * Gets associated scene
  119267. */
  119268. readonly scene: Scene;
  119269. /**
  119270. * Gets or sets the edge blur
  119271. */
  119272. edgeBlur: number;
  119273. /**
  119274. * Gets or sets the grain amount
  119275. */
  119276. grainAmount: number;
  119277. /**
  119278. * Gets or sets the chromatic aberration amount
  119279. */
  119280. chromaticAberration: number;
  119281. /**
  119282. * Gets or sets the depth of field aperture
  119283. */
  119284. dofAperture: number;
  119285. /**
  119286. * Gets or sets the edge distortion
  119287. */
  119288. edgeDistortion: number;
  119289. /**
  119290. * Gets or sets the depth of field distortion
  119291. */
  119292. dofDistortion: number;
  119293. /**
  119294. * Gets or sets the darken out of focus amount
  119295. */
  119296. darkenOutOfFocus: number;
  119297. /**
  119298. * Gets or sets a boolean indicating if blur noise is enabled
  119299. */
  119300. blurNoise: boolean;
  119301. /**
  119302. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119303. */
  119304. pentagonBokeh: boolean;
  119305. /**
  119306. * Gets or sets the highlight grain amount
  119307. */
  119308. highlightsGain: number;
  119309. /**
  119310. * Gets or sets the highlight threshold
  119311. */
  119312. highlightsThreshold: number;
  119313. /**
  119314. * Sets the amount of blur at the edges
  119315. * @param amount blur amount
  119316. */
  119317. setEdgeBlur(amount: number): void;
  119318. /**
  119319. * Sets edge blur to 0
  119320. */
  119321. disableEdgeBlur(): void;
  119322. /**
  119323. * Sets the amout of grain
  119324. * @param amount Amount of grain
  119325. */
  119326. setGrainAmount(amount: number): void;
  119327. /**
  119328. * Set grain amount to 0
  119329. */
  119330. disableGrain(): void;
  119331. /**
  119332. * Sets the chromatic aberration amount
  119333. * @param amount amount of chromatic aberration
  119334. */
  119335. setChromaticAberration(amount: number): void;
  119336. /**
  119337. * Sets chromatic aberration amount to 0
  119338. */
  119339. disableChromaticAberration(): void;
  119340. /**
  119341. * Sets the EdgeDistortion amount
  119342. * @param amount amount of EdgeDistortion
  119343. */
  119344. setEdgeDistortion(amount: number): void;
  119345. /**
  119346. * Sets edge distortion to 0
  119347. */
  119348. disableEdgeDistortion(): void;
  119349. /**
  119350. * Sets the FocusDistance amount
  119351. * @param amount amount of FocusDistance
  119352. */
  119353. setFocusDistance(amount: number): void;
  119354. /**
  119355. * Disables depth of field
  119356. */
  119357. disableDepthOfField(): void;
  119358. /**
  119359. * Sets the Aperture amount
  119360. * @param amount amount of Aperture
  119361. */
  119362. setAperture(amount: number): void;
  119363. /**
  119364. * Sets the DarkenOutOfFocus amount
  119365. * @param amount amount of DarkenOutOfFocus
  119366. */
  119367. setDarkenOutOfFocus(amount: number): void;
  119368. private _pentagonBokehIsEnabled;
  119369. /**
  119370. * Creates a pentagon bokeh effect
  119371. */
  119372. enablePentagonBokeh(): void;
  119373. /**
  119374. * Disables the pentagon bokeh effect
  119375. */
  119376. disablePentagonBokeh(): void;
  119377. /**
  119378. * Enables noise blur
  119379. */
  119380. enableNoiseBlur(): void;
  119381. /**
  119382. * Disables noise blur
  119383. */
  119384. disableNoiseBlur(): void;
  119385. /**
  119386. * Sets the HighlightsGain amount
  119387. * @param amount amount of HighlightsGain
  119388. */
  119389. setHighlightsGain(amount: number): void;
  119390. /**
  119391. * Sets the HighlightsThreshold amount
  119392. * @param amount amount of HighlightsThreshold
  119393. */
  119394. setHighlightsThreshold(amount: number): void;
  119395. /**
  119396. * Disables highlights
  119397. */
  119398. disableHighlights(): void;
  119399. /**
  119400. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119401. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119402. */
  119403. dispose(disableDepthRender?: boolean): void;
  119404. private _createChromaticAberrationPostProcess;
  119405. private _createHighlightsPostProcess;
  119406. private _createDepthOfFieldPostProcess;
  119407. private _createGrainTexture;
  119408. }
  119409. }
  119410. declare module BABYLON {
  119411. /** @hidden */
  119412. export var ssao2PixelShader: {
  119413. name: string;
  119414. shader: string;
  119415. };
  119416. }
  119417. declare module BABYLON {
  119418. /** @hidden */
  119419. export var ssaoCombinePixelShader: {
  119420. name: string;
  119421. shader: string;
  119422. };
  119423. }
  119424. declare module BABYLON {
  119425. /**
  119426. * Render pipeline to produce ssao effect
  119427. */
  119428. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119429. /**
  119430. * @ignore
  119431. * The PassPostProcess id in the pipeline that contains the original scene color
  119432. */
  119433. SSAOOriginalSceneColorEffect: string;
  119434. /**
  119435. * @ignore
  119436. * The SSAO PostProcess id in the pipeline
  119437. */
  119438. SSAORenderEffect: string;
  119439. /**
  119440. * @ignore
  119441. * The horizontal blur PostProcess id in the pipeline
  119442. */
  119443. SSAOBlurHRenderEffect: string;
  119444. /**
  119445. * @ignore
  119446. * The vertical blur PostProcess id in the pipeline
  119447. */
  119448. SSAOBlurVRenderEffect: string;
  119449. /**
  119450. * @ignore
  119451. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119452. */
  119453. SSAOCombineRenderEffect: string;
  119454. /**
  119455. * The output strength of the SSAO post-process. Default value is 1.0.
  119456. */
  119457. totalStrength: number;
  119458. /**
  119459. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119460. */
  119461. maxZ: number;
  119462. /**
  119463. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119464. */
  119465. minZAspect: number;
  119466. private _samples;
  119467. /**
  119468. * Number of samples used for the SSAO calculations. Default value is 8
  119469. */
  119470. samples: number;
  119471. private _textureSamples;
  119472. /**
  119473. * Number of samples to use for antialiasing
  119474. */
  119475. textureSamples: number;
  119476. /**
  119477. * Ratio object used for SSAO ratio and blur ratio
  119478. */
  119479. private _ratio;
  119480. /**
  119481. * Dynamically generated sphere sampler.
  119482. */
  119483. private _sampleSphere;
  119484. /**
  119485. * Blur filter offsets
  119486. */
  119487. private _samplerOffsets;
  119488. private _expensiveBlur;
  119489. /**
  119490. * If bilateral blur should be used
  119491. */
  119492. expensiveBlur: boolean;
  119493. /**
  119494. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119495. */
  119496. radius: number;
  119497. /**
  119498. * The base color of the SSAO post-process
  119499. * The final result is "base + ssao" between [0, 1]
  119500. */
  119501. base: number;
  119502. /**
  119503. * Support test.
  119504. */
  119505. static readonly IsSupported: boolean;
  119506. private _scene;
  119507. private _depthTexture;
  119508. private _normalTexture;
  119509. private _randomTexture;
  119510. private _originalColorPostProcess;
  119511. private _ssaoPostProcess;
  119512. private _blurHPostProcess;
  119513. private _blurVPostProcess;
  119514. private _ssaoCombinePostProcess;
  119515. private _firstUpdate;
  119516. /**
  119517. * Gets active scene
  119518. */
  119519. readonly scene: Scene;
  119520. /**
  119521. * @constructor
  119522. * @param name The rendering pipeline name
  119523. * @param scene The scene linked to this pipeline
  119524. * @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 }
  119525. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119526. */
  119527. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119528. /**
  119529. * Get the class name
  119530. * @returns "SSAO2RenderingPipeline"
  119531. */
  119532. getClassName(): string;
  119533. /**
  119534. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119535. */
  119536. dispose(disableGeometryBufferRenderer?: boolean): void;
  119537. private _createBlurPostProcess;
  119538. /** @hidden */
  119539. _rebuild(): void;
  119540. private _bits;
  119541. private _radicalInverse_VdC;
  119542. private _hammersley;
  119543. private _hemisphereSample_uniform;
  119544. private _generateHemisphere;
  119545. private _createSSAOPostProcess;
  119546. private _createSSAOCombinePostProcess;
  119547. private _createRandomTexture;
  119548. /**
  119549. * Serialize the rendering pipeline (Used when exporting)
  119550. * @returns the serialized object
  119551. */
  119552. serialize(): any;
  119553. /**
  119554. * Parse the serialized pipeline
  119555. * @param source Source pipeline.
  119556. * @param scene The scene to load the pipeline to.
  119557. * @param rootUrl The URL of the serialized pipeline.
  119558. * @returns An instantiated pipeline from the serialized object.
  119559. */
  119560. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119561. }
  119562. }
  119563. declare module BABYLON {
  119564. /** @hidden */
  119565. export var ssaoPixelShader: {
  119566. name: string;
  119567. shader: string;
  119568. };
  119569. }
  119570. declare module BABYLON {
  119571. /**
  119572. * Render pipeline to produce ssao effect
  119573. */
  119574. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119575. /**
  119576. * @ignore
  119577. * The PassPostProcess id in the pipeline that contains the original scene color
  119578. */
  119579. SSAOOriginalSceneColorEffect: string;
  119580. /**
  119581. * @ignore
  119582. * The SSAO PostProcess id in the pipeline
  119583. */
  119584. SSAORenderEffect: string;
  119585. /**
  119586. * @ignore
  119587. * The horizontal blur PostProcess id in the pipeline
  119588. */
  119589. SSAOBlurHRenderEffect: string;
  119590. /**
  119591. * @ignore
  119592. * The vertical blur PostProcess id in the pipeline
  119593. */
  119594. SSAOBlurVRenderEffect: string;
  119595. /**
  119596. * @ignore
  119597. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119598. */
  119599. SSAOCombineRenderEffect: string;
  119600. /**
  119601. * The output strength of the SSAO post-process. Default value is 1.0.
  119602. */
  119603. totalStrength: number;
  119604. /**
  119605. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119606. */
  119607. radius: number;
  119608. /**
  119609. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119610. * Must not be equal to fallOff and superior to fallOff.
  119611. * Default value is 0.0075
  119612. */
  119613. area: number;
  119614. /**
  119615. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119616. * Must not be equal to area and inferior to area.
  119617. * Default value is 0.000001
  119618. */
  119619. fallOff: number;
  119620. /**
  119621. * The base color of the SSAO post-process
  119622. * The final result is "base + ssao" between [0, 1]
  119623. */
  119624. base: number;
  119625. private _scene;
  119626. private _depthTexture;
  119627. private _randomTexture;
  119628. private _originalColorPostProcess;
  119629. private _ssaoPostProcess;
  119630. private _blurHPostProcess;
  119631. private _blurVPostProcess;
  119632. private _ssaoCombinePostProcess;
  119633. private _firstUpdate;
  119634. /**
  119635. * Gets active scene
  119636. */
  119637. readonly scene: Scene;
  119638. /**
  119639. * @constructor
  119640. * @param name - The rendering pipeline name
  119641. * @param scene - The scene linked to this pipeline
  119642. * @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 }
  119643. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119644. */
  119645. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119646. /**
  119647. * Get the class name
  119648. * @returns "SSAORenderingPipeline"
  119649. */
  119650. getClassName(): string;
  119651. /**
  119652. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119653. */
  119654. dispose(disableDepthRender?: boolean): void;
  119655. private _createBlurPostProcess;
  119656. /** @hidden */
  119657. _rebuild(): void;
  119658. private _createSSAOPostProcess;
  119659. private _createSSAOCombinePostProcess;
  119660. private _createRandomTexture;
  119661. }
  119662. }
  119663. declare module BABYLON {
  119664. /** @hidden */
  119665. export var standardPixelShader: {
  119666. name: string;
  119667. shader: string;
  119668. };
  119669. }
  119670. declare module BABYLON {
  119671. /**
  119672. * Standard rendering pipeline
  119673. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119674. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119675. */
  119676. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119677. /**
  119678. * Public members
  119679. */
  119680. /**
  119681. * Post-process which contains the original scene color before the pipeline applies all the effects
  119682. */
  119683. originalPostProcess: Nullable<PostProcess>;
  119684. /**
  119685. * Post-process used to down scale an image x4
  119686. */
  119687. downSampleX4PostProcess: Nullable<PostProcess>;
  119688. /**
  119689. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119690. */
  119691. brightPassPostProcess: Nullable<PostProcess>;
  119692. /**
  119693. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119694. */
  119695. blurHPostProcesses: PostProcess[];
  119696. /**
  119697. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119698. */
  119699. blurVPostProcesses: PostProcess[];
  119700. /**
  119701. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119702. */
  119703. textureAdderPostProcess: Nullable<PostProcess>;
  119704. /**
  119705. * Post-process used to create volumetric lighting effect
  119706. */
  119707. volumetricLightPostProcess: Nullable<PostProcess>;
  119708. /**
  119709. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119710. */
  119711. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119712. /**
  119713. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119714. */
  119715. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119716. /**
  119717. * Post-process used to merge the volumetric light effect and the real scene color
  119718. */
  119719. volumetricLightMergePostProces: Nullable<PostProcess>;
  119720. /**
  119721. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119722. */
  119723. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119724. /**
  119725. * Base post-process used to calculate the average luminance of the final image for HDR
  119726. */
  119727. luminancePostProcess: Nullable<PostProcess>;
  119728. /**
  119729. * Post-processes used to create down sample post-processes in order to get
  119730. * the average luminance of the final image for HDR
  119731. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119732. */
  119733. luminanceDownSamplePostProcesses: PostProcess[];
  119734. /**
  119735. * Post-process used to create a HDR effect (light adaptation)
  119736. */
  119737. hdrPostProcess: Nullable<PostProcess>;
  119738. /**
  119739. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119740. */
  119741. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119742. /**
  119743. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119744. */
  119745. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119746. /**
  119747. * Post-process used to merge the final HDR post-process and the real scene color
  119748. */
  119749. hdrFinalPostProcess: Nullable<PostProcess>;
  119750. /**
  119751. * Post-process used to create a lens flare effect
  119752. */
  119753. lensFlarePostProcess: Nullable<PostProcess>;
  119754. /**
  119755. * Post-process that merges the result of the lens flare post-process and the real scene color
  119756. */
  119757. lensFlareComposePostProcess: Nullable<PostProcess>;
  119758. /**
  119759. * Post-process used to create a motion blur effect
  119760. */
  119761. motionBlurPostProcess: Nullable<PostProcess>;
  119762. /**
  119763. * Post-process used to create a depth of field effect
  119764. */
  119765. depthOfFieldPostProcess: Nullable<PostProcess>;
  119766. /**
  119767. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119768. */
  119769. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119770. /**
  119771. * Represents the brightness threshold in order to configure the illuminated surfaces
  119772. */
  119773. brightThreshold: number;
  119774. /**
  119775. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119776. */
  119777. blurWidth: number;
  119778. /**
  119779. * Sets if the blur for highlighted surfaces must be only horizontal
  119780. */
  119781. horizontalBlur: boolean;
  119782. /**
  119783. * Gets the overall exposure used by the pipeline
  119784. */
  119785. /**
  119786. * Sets the overall exposure used by the pipeline
  119787. */
  119788. exposure: number;
  119789. /**
  119790. * Texture used typically to simulate "dirty" on camera lens
  119791. */
  119792. lensTexture: Nullable<Texture>;
  119793. /**
  119794. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119795. */
  119796. volumetricLightCoefficient: number;
  119797. /**
  119798. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119799. */
  119800. volumetricLightPower: number;
  119801. /**
  119802. * Used the set the blur intensity to smooth the volumetric lights
  119803. */
  119804. volumetricLightBlurScale: number;
  119805. /**
  119806. * Light (spot or directional) used to generate the volumetric lights rays
  119807. * The source light must have a shadow generate so the pipeline can get its
  119808. * depth map
  119809. */
  119810. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119811. /**
  119812. * For eye adaptation, represents the minimum luminance the eye can see
  119813. */
  119814. hdrMinimumLuminance: number;
  119815. /**
  119816. * For eye adaptation, represents the decrease luminance speed
  119817. */
  119818. hdrDecreaseRate: number;
  119819. /**
  119820. * For eye adaptation, represents the increase luminance speed
  119821. */
  119822. hdrIncreaseRate: number;
  119823. /**
  119824. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119825. */
  119826. /**
  119827. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119828. */
  119829. hdrAutoExposure: boolean;
  119830. /**
  119831. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119832. */
  119833. lensColorTexture: Nullable<Texture>;
  119834. /**
  119835. * The overall strengh for the lens flare effect
  119836. */
  119837. lensFlareStrength: number;
  119838. /**
  119839. * Dispersion coefficient for lens flare ghosts
  119840. */
  119841. lensFlareGhostDispersal: number;
  119842. /**
  119843. * Main lens flare halo width
  119844. */
  119845. lensFlareHaloWidth: number;
  119846. /**
  119847. * Based on the lens distortion effect, defines how much the lens flare result
  119848. * is distorted
  119849. */
  119850. lensFlareDistortionStrength: number;
  119851. /**
  119852. * Lens star texture must be used to simulate rays on the flares and is available
  119853. * in the documentation
  119854. */
  119855. lensStarTexture: Nullable<Texture>;
  119856. /**
  119857. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119858. * flare effect by taking account of the dirt texture
  119859. */
  119860. lensFlareDirtTexture: Nullable<Texture>;
  119861. /**
  119862. * Represents the focal length for the depth of field effect
  119863. */
  119864. depthOfFieldDistance: number;
  119865. /**
  119866. * Represents the blur intensity for the blurred part of the depth of field effect
  119867. */
  119868. depthOfFieldBlurWidth: number;
  119869. /**
  119870. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119871. */
  119872. /**
  119873. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119874. */
  119875. motionStrength: number;
  119876. /**
  119877. * Gets wether or not the motion blur post-process is object based or screen based.
  119878. */
  119879. /**
  119880. * Sets wether or not the motion blur post-process should be object based or screen based
  119881. */
  119882. objectBasedMotionBlur: boolean;
  119883. /**
  119884. * List of animations for the pipeline (IAnimatable implementation)
  119885. */
  119886. animations: Animation[];
  119887. /**
  119888. * Private members
  119889. */
  119890. private _scene;
  119891. private _currentDepthOfFieldSource;
  119892. private _basePostProcess;
  119893. private _fixedExposure;
  119894. private _currentExposure;
  119895. private _hdrAutoExposure;
  119896. private _hdrCurrentLuminance;
  119897. private _motionStrength;
  119898. private _isObjectBasedMotionBlur;
  119899. private _floatTextureType;
  119900. private _ratio;
  119901. private _bloomEnabled;
  119902. private _depthOfFieldEnabled;
  119903. private _vlsEnabled;
  119904. private _lensFlareEnabled;
  119905. private _hdrEnabled;
  119906. private _motionBlurEnabled;
  119907. private _fxaaEnabled;
  119908. private _motionBlurSamples;
  119909. private _volumetricLightStepsCount;
  119910. private _samples;
  119911. /**
  119912. * @ignore
  119913. * Specifies if the bloom pipeline is enabled
  119914. */
  119915. BloomEnabled: boolean;
  119916. /**
  119917. * @ignore
  119918. * Specifies if the depth of field pipeline is enabed
  119919. */
  119920. DepthOfFieldEnabled: boolean;
  119921. /**
  119922. * @ignore
  119923. * Specifies if the lens flare pipeline is enabed
  119924. */
  119925. LensFlareEnabled: boolean;
  119926. /**
  119927. * @ignore
  119928. * Specifies if the HDR pipeline is enabled
  119929. */
  119930. HDREnabled: boolean;
  119931. /**
  119932. * @ignore
  119933. * Specifies if the volumetric lights scattering effect is enabled
  119934. */
  119935. VLSEnabled: boolean;
  119936. /**
  119937. * @ignore
  119938. * Specifies if the motion blur effect is enabled
  119939. */
  119940. MotionBlurEnabled: boolean;
  119941. /**
  119942. * Specifies if anti-aliasing is enabled
  119943. */
  119944. fxaaEnabled: boolean;
  119945. /**
  119946. * Specifies the number of steps used to calculate the volumetric lights
  119947. * Typically in interval [50, 200]
  119948. */
  119949. volumetricLightStepsCount: number;
  119950. /**
  119951. * Specifies the number of samples used for the motion blur effect
  119952. * Typically in interval [16, 64]
  119953. */
  119954. motionBlurSamples: number;
  119955. /**
  119956. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119957. */
  119958. samples: number;
  119959. /**
  119960. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119961. * @constructor
  119962. * @param name The rendering pipeline name
  119963. * @param scene The scene linked to this pipeline
  119964. * @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)
  119965. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119966. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119967. */
  119968. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119969. private _buildPipeline;
  119970. private _createDownSampleX4PostProcess;
  119971. private _createBrightPassPostProcess;
  119972. private _createBlurPostProcesses;
  119973. private _createTextureAdderPostProcess;
  119974. private _createVolumetricLightPostProcess;
  119975. private _createLuminancePostProcesses;
  119976. private _createHdrPostProcess;
  119977. private _createLensFlarePostProcess;
  119978. private _createDepthOfFieldPostProcess;
  119979. private _createMotionBlurPostProcess;
  119980. private _getDepthTexture;
  119981. private _disposePostProcesses;
  119982. /**
  119983. * Dispose of the pipeline and stop all post processes
  119984. */
  119985. dispose(): void;
  119986. /**
  119987. * Serialize the rendering pipeline (Used when exporting)
  119988. * @returns the serialized object
  119989. */
  119990. serialize(): any;
  119991. /**
  119992. * Parse the serialized pipeline
  119993. * @param source Source pipeline.
  119994. * @param scene The scene to load the pipeline to.
  119995. * @param rootUrl The URL of the serialized pipeline.
  119996. * @returns An instantiated pipeline from the serialized object.
  119997. */
  119998. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119999. /**
  120000. * Luminance steps
  120001. */
  120002. static LuminanceSteps: number;
  120003. }
  120004. }
  120005. declare module BABYLON {
  120006. /** @hidden */
  120007. export var tonemapPixelShader: {
  120008. name: string;
  120009. shader: string;
  120010. };
  120011. }
  120012. declare module BABYLON {
  120013. /** Defines operator used for tonemapping */
  120014. export enum TonemappingOperator {
  120015. /** Hable */
  120016. Hable = 0,
  120017. /** Reinhard */
  120018. Reinhard = 1,
  120019. /** HejiDawson */
  120020. HejiDawson = 2,
  120021. /** Photographic */
  120022. Photographic = 3
  120023. }
  120024. /**
  120025. * Defines a post process to apply tone mapping
  120026. */
  120027. export class TonemapPostProcess extends PostProcess {
  120028. private _operator;
  120029. /** Defines the required exposure adjustement */
  120030. exposureAdjustment: number;
  120031. /**
  120032. * Creates a new TonemapPostProcess
  120033. * @param name defines the name of the postprocess
  120034. * @param _operator defines the operator to use
  120035. * @param exposureAdjustment defines the required exposure adjustement
  120036. * @param camera defines the camera to use (can be null)
  120037. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120038. * @param engine defines the hosting engine (can be ignore if camera is set)
  120039. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120040. */
  120041. constructor(name: string, _operator: TonemappingOperator,
  120042. /** Defines the required exposure adjustement */
  120043. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120044. }
  120045. }
  120046. declare module BABYLON {
  120047. /** @hidden */
  120048. export var depthVertexShader: {
  120049. name: string;
  120050. shader: string;
  120051. };
  120052. }
  120053. declare module BABYLON {
  120054. /** @hidden */
  120055. export var volumetricLightScatteringPixelShader: {
  120056. name: string;
  120057. shader: string;
  120058. };
  120059. }
  120060. declare module BABYLON {
  120061. /** @hidden */
  120062. export var volumetricLightScatteringPassPixelShader: {
  120063. name: string;
  120064. shader: string;
  120065. };
  120066. }
  120067. declare module BABYLON {
  120068. /**
  120069. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120070. */
  120071. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120072. private _volumetricLightScatteringPass;
  120073. private _volumetricLightScatteringRTT;
  120074. private _viewPort;
  120075. private _screenCoordinates;
  120076. private _cachedDefines;
  120077. /**
  120078. * If not undefined, the mesh position is computed from the attached node position
  120079. */
  120080. attachedNode: {
  120081. position: Vector3;
  120082. };
  120083. /**
  120084. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120085. */
  120086. customMeshPosition: Vector3;
  120087. /**
  120088. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120089. */
  120090. useCustomMeshPosition: boolean;
  120091. /**
  120092. * If the post-process should inverse the light scattering direction
  120093. */
  120094. invert: boolean;
  120095. /**
  120096. * The internal mesh used by the post-process
  120097. */
  120098. mesh: Mesh;
  120099. /**
  120100. * @hidden
  120101. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120102. */
  120103. useDiffuseColor: boolean;
  120104. /**
  120105. * Array containing the excluded meshes not rendered in the internal pass
  120106. */
  120107. excludedMeshes: AbstractMesh[];
  120108. /**
  120109. * Controls the overall intensity of the post-process
  120110. */
  120111. exposure: number;
  120112. /**
  120113. * Dissipates each sample's contribution in range [0, 1]
  120114. */
  120115. decay: number;
  120116. /**
  120117. * Controls the overall intensity of each sample
  120118. */
  120119. weight: number;
  120120. /**
  120121. * Controls the density of each sample
  120122. */
  120123. density: number;
  120124. /**
  120125. * @constructor
  120126. * @param name The post-process name
  120127. * @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)
  120128. * @param camera The camera that the post-process will be attached to
  120129. * @param mesh The mesh used to create the light scattering
  120130. * @param samples The post-process quality, default 100
  120131. * @param samplingModeThe post-process filtering mode
  120132. * @param engine The babylon engine
  120133. * @param reusable If the post-process is reusable
  120134. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120135. */
  120136. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120137. /**
  120138. * Returns the string "VolumetricLightScatteringPostProcess"
  120139. * @returns "VolumetricLightScatteringPostProcess"
  120140. */
  120141. getClassName(): string;
  120142. private _isReady;
  120143. /**
  120144. * Sets the new light position for light scattering effect
  120145. * @param position The new custom light position
  120146. */
  120147. setCustomMeshPosition(position: Vector3): void;
  120148. /**
  120149. * Returns the light position for light scattering effect
  120150. * @return Vector3 The custom light position
  120151. */
  120152. getCustomMeshPosition(): Vector3;
  120153. /**
  120154. * Disposes the internal assets and detaches the post-process from the camera
  120155. */
  120156. dispose(camera: Camera): void;
  120157. /**
  120158. * Returns the render target texture used by the post-process
  120159. * @return the render target texture used by the post-process
  120160. */
  120161. getPass(): RenderTargetTexture;
  120162. private _meshExcluded;
  120163. private _createPass;
  120164. private _updateMeshScreenCoordinates;
  120165. /**
  120166. * Creates a default mesh for the Volumeric Light Scattering post-process
  120167. * @param name The mesh name
  120168. * @param scene The scene where to create the mesh
  120169. * @return the default mesh
  120170. */
  120171. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120172. }
  120173. }
  120174. declare module BABYLON {
  120175. interface Scene {
  120176. /** @hidden (Backing field) */
  120177. _boundingBoxRenderer: BoundingBoxRenderer;
  120178. /** @hidden (Backing field) */
  120179. _forceShowBoundingBoxes: boolean;
  120180. /**
  120181. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120182. */
  120183. forceShowBoundingBoxes: boolean;
  120184. /**
  120185. * Gets the bounding box renderer associated with the scene
  120186. * @returns a BoundingBoxRenderer
  120187. */
  120188. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120189. }
  120190. interface AbstractMesh {
  120191. /** @hidden (Backing field) */
  120192. _showBoundingBox: boolean;
  120193. /**
  120194. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120195. */
  120196. showBoundingBox: boolean;
  120197. }
  120198. /**
  120199. * Component responsible of rendering the bounding box of the meshes in a scene.
  120200. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120201. */
  120202. export class BoundingBoxRenderer implements ISceneComponent {
  120203. /**
  120204. * The component name helpfull to identify the component in the list of scene components.
  120205. */
  120206. readonly name: string;
  120207. /**
  120208. * The scene the component belongs to.
  120209. */
  120210. scene: Scene;
  120211. /**
  120212. * Color of the bounding box lines placed in front of an object
  120213. */
  120214. frontColor: Color3;
  120215. /**
  120216. * Color of the bounding box lines placed behind an object
  120217. */
  120218. backColor: Color3;
  120219. /**
  120220. * Defines if the renderer should show the back lines or not
  120221. */
  120222. showBackLines: boolean;
  120223. /**
  120224. * @hidden
  120225. */
  120226. renderList: SmartArray<BoundingBox>;
  120227. private _colorShader;
  120228. private _vertexBuffers;
  120229. private _indexBuffer;
  120230. private _fillIndexBuffer;
  120231. private _fillIndexData;
  120232. /**
  120233. * Instantiates a new bounding box renderer in a scene.
  120234. * @param scene the scene the renderer renders in
  120235. */
  120236. constructor(scene: Scene);
  120237. /**
  120238. * Registers the component in a given scene
  120239. */
  120240. register(): void;
  120241. private _evaluateSubMesh;
  120242. private _activeMesh;
  120243. private _prepareRessources;
  120244. private _createIndexBuffer;
  120245. /**
  120246. * Rebuilds the elements related to this component in case of
  120247. * context lost for instance.
  120248. */
  120249. rebuild(): void;
  120250. /**
  120251. * @hidden
  120252. */
  120253. reset(): void;
  120254. /**
  120255. * Render the bounding boxes of a specific rendering group
  120256. * @param renderingGroupId defines the rendering group to render
  120257. */
  120258. render(renderingGroupId: number): void;
  120259. /**
  120260. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120261. * @param mesh Define the mesh to render the occlusion bounding box for
  120262. */
  120263. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120264. /**
  120265. * Dispose and release the resources attached to this renderer.
  120266. */
  120267. dispose(): void;
  120268. }
  120269. }
  120270. declare module BABYLON {
  120271. /** @hidden */
  120272. export var depthPixelShader: {
  120273. name: string;
  120274. shader: string;
  120275. };
  120276. }
  120277. declare module BABYLON {
  120278. /**
  120279. * This represents a depth renderer in Babylon.
  120280. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120281. */
  120282. export class DepthRenderer {
  120283. private _scene;
  120284. private _depthMap;
  120285. private _effect;
  120286. private readonly _storeNonLinearDepth;
  120287. private readonly _clearColor;
  120288. /** Get if the depth renderer is using packed depth or not */
  120289. readonly isPacked: boolean;
  120290. private _cachedDefines;
  120291. private _camera;
  120292. /**
  120293. * Specifiess that the depth renderer will only be used within
  120294. * the camera it is created for.
  120295. * This can help forcing its rendering during the camera processing.
  120296. */
  120297. useOnlyInActiveCamera: boolean;
  120298. /** @hidden */
  120299. static _SceneComponentInitialization: (scene: Scene) => void;
  120300. /**
  120301. * Instantiates a depth renderer
  120302. * @param scene The scene the renderer belongs to
  120303. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120304. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120305. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120306. */
  120307. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  120308. /**
  120309. * Creates the depth rendering effect and checks if the effect is ready.
  120310. * @param subMesh The submesh to be used to render the depth map of
  120311. * @param useInstances If multiple world instances should be used
  120312. * @returns if the depth renderer is ready to render the depth map
  120313. */
  120314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120315. /**
  120316. * Gets the texture which the depth map will be written to.
  120317. * @returns The depth map texture
  120318. */
  120319. getDepthMap(): RenderTargetTexture;
  120320. /**
  120321. * Disposes of the depth renderer.
  120322. */
  120323. dispose(): void;
  120324. }
  120325. }
  120326. declare module BABYLON {
  120327. interface Scene {
  120328. /** @hidden (Backing field) */
  120329. _depthRenderer: {
  120330. [id: string]: DepthRenderer;
  120331. };
  120332. /**
  120333. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120334. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120335. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  120336. * @returns the created depth renderer
  120337. */
  120338. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  120339. /**
  120340. * Disables a depth renderer for a given camera
  120341. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120342. */
  120343. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120344. }
  120345. /**
  120346. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120347. * in several rendering techniques.
  120348. */
  120349. export class DepthRendererSceneComponent implements ISceneComponent {
  120350. /**
  120351. * The component name helpfull to identify the component in the list of scene components.
  120352. */
  120353. readonly name: string;
  120354. /**
  120355. * The scene the component belongs to.
  120356. */
  120357. scene: Scene;
  120358. /**
  120359. * Creates a new instance of the component for the given scene
  120360. * @param scene Defines the scene to register the component in
  120361. */
  120362. constructor(scene: Scene);
  120363. /**
  120364. * Registers the component in a given scene
  120365. */
  120366. register(): void;
  120367. /**
  120368. * Rebuilds the elements related to this component in case of
  120369. * context lost for instance.
  120370. */
  120371. rebuild(): void;
  120372. /**
  120373. * Disposes the component and the associated ressources
  120374. */
  120375. dispose(): void;
  120376. private _gatherRenderTargets;
  120377. private _gatherActiveCameraRenderTargets;
  120378. }
  120379. }
  120380. declare module BABYLON {
  120381. /** @hidden */
  120382. export var outlinePixelShader: {
  120383. name: string;
  120384. shader: string;
  120385. };
  120386. }
  120387. declare module BABYLON {
  120388. /** @hidden */
  120389. export var outlineVertexShader: {
  120390. name: string;
  120391. shader: string;
  120392. };
  120393. }
  120394. declare module BABYLON {
  120395. interface Scene {
  120396. /** @hidden */
  120397. _outlineRenderer: OutlineRenderer;
  120398. /**
  120399. * Gets the outline renderer associated with the scene
  120400. * @returns a OutlineRenderer
  120401. */
  120402. getOutlineRenderer(): OutlineRenderer;
  120403. }
  120404. interface AbstractMesh {
  120405. /** @hidden (Backing field) */
  120406. _renderOutline: boolean;
  120407. /**
  120408. * Gets or sets a boolean indicating if the outline must be rendered as well
  120409. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120410. */
  120411. renderOutline: boolean;
  120412. /** @hidden (Backing field) */
  120413. _renderOverlay: boolean;
  120414. /**
  120415. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120416. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120417. */
  120418. renderOverlay: boolean;
  120419. }
  120420. /**
  120421. * This class is responsible to draw bothe outline/overlay of meshes.
  120422. * It should not be used directly but through the available method on mesh.
  120423. */
  120424. export class OutlineRenderer implements ISceneComponent {
  120425. /**
  120426. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120427. */
  120428. private static _StencilReference;
  120429. /**
  120430. * The name of the component. Each component must have a unique name.
  120431. */
  120432. name: string;
  120433. /**
  120434. * The scene the component belongs to.
  120435. */
  120436. scene: Scene;
  120437. /**
  120438. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120439. */
  120440. zOffset: number;
  120441. private _engine;
  120442. private _effect;
  120443. private _cachedDefines;
  120444. private _savedDepthWrite;
  120445. /**
  120446. * Instantiates a new outline renderer. (There could be only one per scene).
  120447. * @param scene Defines the scene it belongs to
  120448. */
  120449. constructor(scene: Scene);
  120450. /**
  120451. * Register the component to one instance of a scene.
  120452. */
  120453. register(): void;
  120454. /**
  120455. * Rebuilds the elements related to this component in case of
  120456. * context lost for instance.
  120457. */
  120458. rebuild(): void;
  120459. /**
  120460. * Disposes the component and the associated ressources.
  120461. */
  120462. dispose(): void;
  120463. /**
  120464. * Renders the outline in the canvas.
  120465. * @param subMesh Defines the sumesh to render
  120466. * @param batch Defines the batch of meshes in case of instances
  120467. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120468. */
  120469. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120470. /**
  120471. * Returns whether or not the outline renderer is ready for a given submesh.
  120472. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120473. * @param subMesh Defines the submesh to check readyness for
  120474. * @param useInstances Defines wheter wee are trying to render instances or not
  120475. * @returns true if ready otherwise false
  120476. */
  120477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120478. private _beforeRenderingMesh;
  120479. private _afterRenderingMesh;
  120480. }
  120481. }
  120482. declare module BABYLON {
  120483. /**
  120484. * Defines the list of states available for a task inside a AssetsManager
  120485. */
  120486. export enum AssetTaskState {
  120487. /**
  120488. * Initialization
  120489. */
  120490. INIT = 0,
  120491. /**
  120492. * Running
  120493. */
  120494. RUNNING = 1,
  120495. /**
  120496. * Done
  120497. */
  120498. DONE = 2,
  120499. /**
  120500. * Error
  120501. */
  120502. ERROR = 3
  120503. }
  120504. /**
  120505. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120506. */
  120507. export abstract class AbstractAssetTask {
  120508. /**
  120509. * Task name
  120510. */ name: string;
  120511. /**
  120512. * Callback called when the task is successful
  120513. */
  120514. onSuccess: (task: any) => void;
  120515. /**
  120516. * Callback called when the task is not successful
  120517. */
  120518. onError: (task: any, message?: string, exception?: any) => void;
  120519. /**
  120520. * Creates a new AssetsManager
  120521. * @param name defines the name of the task
  120522. */
  120523. constructor(
  120524. /**
  120525. * Task name
  120526. */ name: string);
  120527. private _isCompleted;
  120528. private _taskState;
  120529. private _errorObject;
  120530. /**
  120531. * Get if the task is completed
  120532. */
  120533. readonly isCompleted: boolean;
  120534. /**
  120535. * Gets the current state of the task
  120536. */
  120537. readonly taskState: AssetTaskState;
  120538. /**
  120539. * Gets the current error object (if task is in error)
  120540. */
  120541. readonly errorObject: {
  120542. message?: string;
  120543. exception?: any;
  120544. };
  120545. /**
  120546. * Internal only
  120547. * @hidden
  120548. */
  120549. _setErrorObject(message?: string, exception?: any): void;
  120550. /**
  120551. * Execute the current task
  120552. * @param scene defines the scene where you want your assets to be loaded
  120553. * @param onSuccess is a callback called when the task is successfully executed
  120554. * @param onError is a callback called if an error occurs
  120555. */
  120556. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120557. /**
  120558. * Execute the current task
  120559. * @param scene defines the scene where you want your assets to be loaded
  120560. * @param onSuccess is a callback called when the task is successfully executed
  120561. * @param onError is a callback called if an error occurs
  120562. */
  120563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120564. /**
  120565. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120566. * This can be used with failed tasks that have the reason for failure fixed.
  120567. */
  120568. reset(): void;
  120569. private onErrorCallback;
  120570. private onDoneCallback;
  120571. }
  120572. /**
  120573. * Define the interface used by progress events raised during assets loading
  120574. */
  120575. export interface IAssetsProgressEvent {
  120576. /**
  120577. * Defines the number of remaining tasks to process
  120578. */
  120579. remainingCount: number;
  120580. /**
  120581. * Defines the total number of tasks
  120582. */
  120583. totalCount: number;
  120584. /**
  120585. * Defines the task that was just processed
  120586. */
  120587. task: AbstractAssetTask;
  120588. }
  120589. /**
  120590. * Class used to share progress information about assets loading
  120591. */
  120592. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120593. /**
  120594. * Defines the number of remaining tasks to process
  120595. */
  120596. remainingCount: number;
  120597. /**
  120598. * Defines the total number of tasks
  120599. */
  120600. totalCount: number;
  120601. /**
  120602. * Defines the task that was just processed
  120603. */
  120604. task: AbstractAssetTask;
  120605. /**
  120606. * Creates a AssetsProgressEvent
  120607. * @param remainingCount defines the number of remaining tasks to process
  120608. * @param totalCount defines the total number of tasks
  120609. * @param task defines the task that was just processed
  120610. */
  120611. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120612. }
  120613. /**
  120614. * Define a task used by AssetsManager to load meshes
  120615. */
  120616. export class MeshAssetTask extends AbstractAssetTask {
  120617. /**
  120618. * Defines the name of the task
  120619. */
  120620. name: string;
  120621. /**
  120622. * Defines the list of mesh's names you want to load
  120623. */
  120624. meshesNames: any;
  120625. /**
  120626. * Defines the root url to use as a base to load your meshes and associated resources
  120627. */
  120628. rootUrl: string;
  120629. /**
  120630. * Defines the filename of the scene to load from
  120631. */
  120632. sceneFilename: string;
  120633. /**
  120634. * Gets the list of loaded meshes
  120635. */
  120636. loadedMeshes: Array<AbstractMesh>;
  120637. /**
  120638. * Gets the list of loaded particle systems
  120639. */
  120640. loadedParticleSystems: Array<IParticleSystem>;
  120641. /**
  120642. * Gets the list of loaded skeletons
  120643. */
  120644. loadedSkeletons: Array<Skeleton>;
  120645. /**
  120646. * Gets the list of loaded animation groups
  120647. */
  120648. loadedAnimationGroups: Array<AnimationGroup>;
  120649. /**
  120650. * Callback called when the task is successful
  120651. */
  120652. onSuccess: (task: MeshAssetTask) => void;
  120653. /**
  120654. * Callback called when the task is successful
  120655. */
  120656. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120657. /**
  120658. * Creates a new MeshAssetTask
  120659. * @param name defines the name of the task
  120660. * @param meshesNames defines the list of mesh's names you want to load
  120661. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120662. * @param sceneFilename defines the filename of the scene to load from
  120663. */
  120664. constructor(
  120665. /**
  120666. * Defines the name of the task
  120667. */
  120668. name: string,
  120669. /**
  120670. * Defines the list of mesh's names you want to load
  120671. */
  120672. meshesNames: any,
  120673. /**
  120674. * Defines the root url to use as a base to load your meshes and associated resources
  120675. */
  120676. rootUrl: string,
  120677. /**
  120678. * Defines the filename of the scene to load from
  120679. */
  120680. sceneFilename: string);
  120681. /**
  120682. * Execute the current task
  120683. * @param scene defines the scene where you want your assets to be loaded
  120684. * @param onSuccess is a callback called when the task is successfully executed
  120685. * @param onError is a callback called if an error occurs
  120686. */
  120687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120688. }
  120689. /**
  120690. * Define a task used by AssetsManager to load text content
  120691. */
  120692. export class TextFileAssetTask extends AbstractAssetTask {
  120693. /**
  120694. * Defines the name of the task
  120695. */
  120696. name: string;
  120697. /**
  120698. * Defines the location of the file to load
  120699. */
  120700. url: string;
  120701. /**
  120702. * Gets the loaded text string
  120703. */
  120704. text: string;
  120705. /**
  120706. * Callback called when the task is successful
  120707. */
  120708. onSuccess: (task: TextFileAssetTask) => void;
  120709. /**
  120710. * Callback called when the task is successful
  120711. */
  120712. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120713. /**
  120714. * Creates a new TextFileAssetTask object
  120715. * @param name defines the name of the task
  120716. * @param url defines the location of the file to load
  120717. */
  120718. constructor(
  120719. /**
  120720. * Defines the name of the task
  120721. */
  120722. name: string,
  120723. /**
  120724. * Defines the location of the file to load
  120725. */
  120726. url: string);
  120727. /**
  120728. * Execute the current task
  120729. * @param scene defines the scene where you want your assets to be loaded
  120730. * @param onSuccess is a callback called when the task is successfully executed
  120731. * @param onError is a callback called if an error occurs
  120732. */
  120733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120734. }
  120735. /**
  120736. * Define a task used by AssetsManager to load binary data
  120737. */
  120738. export class BinaryFileAssetTask extends AbstractAssetTask {
  120739. /**
  120740. * Defines the name of the task
  120741. */
  120742. name: string;
  120743. /**
  120744. * Defines the location of the file to load
  120745. */
  120746. url: string;
  120747. /**
  120748. * Gets the lodaded data (as an array buffer)
  120749. */
  120750. data: ArrayBuffer;
  120751. /**
  120752. * Callback called when the task is successful
  120753. */
  120754. onSuccess: (task: BinaryFileAssetTask) => void;
  120755. /**
  120756. * Callback called when the task is successful
  120757. */
  120758. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120759. /**
  120760. * Creates a new BinaryFileAssetTask object
  120761. * @param name defines the name of the new task
  120762. * @param url defines the location of the file to load
  120763. */
  120764. constructor(
  120765. /**
  120766. * Defines the name of the task
  120767. */
  120768. name: string,
  120769. /**
  120770. * Defines the location of the file to load
  120771. */
  120772. url: string);
  120773. /**
  120774. * Execute the current task
  120775. * @param scene defines the scene where you want your assets to be loaded
  120776. * @param onSuccess is a callback called when the task is successfully executed
  120777. * @param onError is a callback called if an error occurs
  120778. */
  120779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120780. }
  120781. /**
  120782. * Define a task used by AssetsManager to load images
  120783. */
  120784. export class ImageAssetTask extends AbstractAssetTask {
  120785. /**
  120786. * Defines the name of the task
  120787. */
  120788. name: string;
  120789. /**
  120790. * Defines the location of the image to load
  120791. */
  120792. url: string;
  120793. /**
  120794. * Gets the loaded images
  120795. */
  120796. image: HTMLImageElement;
  120797. /**
  120798. * Callback called when the task is successful
  120799. */
  120800. onSuccess: (task: ImageAssetTask) => void;
  120801. /**
  120802. * Callback called when the task is successful
  120803. */
  120804. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120805. /**
  120806. * Creates a new ImageAssetTask
  120807. * @param name defines the name of the task
  120808. * @param url defines the location of the image to load
  120809. */
  120810. constructor(
  120811. /**
  120812. * Defines the name of the task
  120813. */
  120814. name: string,
  120815. /**
  120816. * Defines the location of the image to load
  120817. */
  120818. url: string);
  120819. /**
  120820. * Execute the current task
  120821. * @param scene defines the scene where you want your assets to be loaded
  120822. * @param onSuccess is a callback called when the task is successfully executed
  120823. * @param onError is a callback called if an error occurs
  120824. */
  120825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120826. }
  120827. /**
  120828. * Defines the interface used by texture loading tasks
  120829. */
  120830. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120831. /**
  120832. * Gets the loaded texture
  120833. */
  120834. texture: TEX;
  120835. }
  120836. /**
  120837. * Define a task used by AssetsManager to load 2D textures
  120838. */
  120839. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120840. /**
  120841. * Defines the name of the task
  120842. */
  120843. name: string;
  120844. /**
  120845. * Defines the location of the file to load
  120846. */
  120847. url: string;
  120848. /**
  120849. * Defines if mipmap should not be generated (default is false)
  120850. */
  120851. noMipmap?: boolean | undefined;
  120852. /**
  120853. * Defines if texture must be inverted on Y axis (default is false)
  120854. */
  120855. invertY?: boolean | undefined;
  120856. /**
  120857. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120858. */
  120859. samplingMode: number;
  120860. /**
  120861. * Gets the loaded texture
  120862. */
  120863. texture: Texture;
  120864. /**
  120865. * Callback called when the task is successful
  120866. */
  120867. onSuccess: (task: TextureAssetTask) => void;
  120868. /**
  120869. * Callback called when the task is successful
  120870. */
  120871. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120872. /**
  120873. * Creates a new TextureAssetTask object
  120874. * @param name defines the name of the task
  120875. * @param url defines the location of the file to load
  120876. * @param noMipmap defines if mipmap should not be generated (default is false)
  120877. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120878. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120879. */
  120880. constructor(
  120881. /**
  120882. * Defines the name of the task
  120883. */
  120884. name: string,
  120885. /**
  120886. * Defines the location of the file to load
  120887. */
  120888. url: string,
  120889. /**
  120890. * Defines if mipmap should not be generated (default is false)
  120891. */
  120892. noMipmap?: boolean | undefined,
  120893. /**
  120894. * Defines if texture must be inverted on Y axis (default is false)
  120895. */
  120896. invertY?: boolean | undefined,
  120897. /**
  120898. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120899. */
  120900. samplingMode?: number);
  120901. /**
  120902. * Execute the current task
  120903. * @param scene defines the scene where you want your assets to be loaded
  120904. * @param onSuccess is a callback called when the task is successfully executed
  120905. * @param onError is a callback called if an error occurs
  120906. */
  120907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120908. }
  120909. /**
  120910. * Define a task used by AssetsManager to load cube textures
  120911. */
  120912. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120913. /**
  120914. * Defines the name of the task
  120915. */
  120916. name: string;
  120917. /**
  120918. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120919. */
  120920. url: string;
  120921. /**
  120922. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120923. */
  120924. extensions?: string[] | undefined;
  120925. /**
  120926. * Defines if mipmaps should not be generated (default is false)
  120927. */
  120928. noMipmap?: boolean | undefined;
  120929. /**
  120930. * Defines the explicit list of files (undefined by default)
  120931. */
  120932. files?: string[] | undefined;
  120933. /**
  120934. * Gets the loaded texture
  120935. */
  120936. texture: CubeTexture;
  120937. /**
  120938. * Callback called when the task is successful
  120939. */
  120940. onSuccess: (task: CubeTextureAssetTask) => void;
  120941. /**
  120942. * Callback called when the task is successful
  120943. */
  120944. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120945. /**
  120946. * Creates a new CubeTextureAssetTask
  120947. * @param name defines the name of the task
  120948. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120949. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120950. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120951. * @param files defines the explicit list of files (undefined by default)
  120952. */
  120953. constructor(
  120954. /**
  120955. * Defines the name of the task
  120956. */
  120957. name: string,
  120958. /**
  120959. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120960. */
  120961. url: string,
  120962. /**
  120963. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120964. */
  120965. extensions?: string[] | undefined,
  120966. /**
  120967. * Defines if mipmaps should not be generated (default is false)
  120968. */
  120969. noMipmap?: boolean | undefined,
  120970. /**
  120971. * Defines the explicit list of files (undefined by default)
  120972. */
  120973. files?: string[] | undefined);
  120974. /**
  120975. * Execute the current task
  120976. * @param scene defines the scene where you want your assets to be loaded
  120977. * @param onSuccess is a callback called when the task is successfully executed
  120978. * @param onError is a callback called if an error occurs
  120979. */
  120980. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120981. }
  120982. /**
  120983. * Define a task used by AssetsManager to load HDR cube textures
  120984. */
  120985. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120986. /**
  120987. * Defines the name of the task
  120988. */
  120989. name: string;
  120990. /**
  120991. * Defines the location of the file to load
  120992. */
  120993. url: string;
  120994. /**
  120995. * Defines the desired size (the more it increases the longer the generation will be)
  120996. */
  120997. size: number;
  120998. /**
  120999. * Defines if mipmaps should not be generated (default is false)
  121000. */
  121001. noMipmap: boolean;
  121002. /**
  121003. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121004. */
  121005. generateHarmonics: boolean;
  121006. /**
  121007. * 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)
  121008. */
  121009. gammaSpace: boolean;
  121010. /**
  121011. * Internal Use Only
  121012. */
  121013. reserved: boolean;
  121014. /**
  121015. * Gets the loaded texture
  121016. */
  121017. texture: HDRCubeTexture;
  121018. /**
  121019. * Callback called when the task is successful
  121020. */
  121021. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  121022. /**
  121023. * Callback called when the task is successful
  121024. */
  121025. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  121026. /**
  121027. * Creates a new HDRCubeTextureAssetTask object
  121028. * @param name defines the name of the task
  121029. * @param url defines the location of the file to load
  121030. * @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.
  121031. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121032. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121033. * @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)
  121034. * @param reserved Internal use only
  121035. */
  121036. constructor(
  121037. /**
  121038. * Defines the name of the task
  121039. */
  121040. name: string,
  121041. /**
  121042. * Defines the location of the file to load
  121043. */
  121044. url: string,
  121045. /**
  121046. * Defines the desired size (the more it increases the longer the generation will be)
  121047. */
  121048. size: number,
  121049. /**
  121050. * Defines if mipmaps should not be generated (default is false)
  121051. */
  121052. noMipmap?: boolean,
  121053. /**
  121054. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121055. */
  121056. generateHarmonics?: boolean,
  121057. /**
  121058. * 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)
  121059. */
  121060. gammaSpace?: boolean,
  121061. /**
  121062. * Internal Use Only
  121063. */
  121064. reserved?: boolean);
  121065. /**
  121066. * Execute the current task
  121067. * @param scene defines the scene where you want your assets to be loaded
  121068. * @param onSuccess is a callback called when the task is successfully executed
  121069. * @param onError is a callback called if an error occurs
  121070. */
  121071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121072. }
  121073. /**
  121074. * Define a task used by AssetsManager to load Equirectangular cube textures
  121075. */
  121076. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121077. /**
  121078. * Defines the name of the task
  121079. */
  121080. name: string;
  121081. /**
  121082. * Defines the location of the file to load
  121083. */
  121084. url: string;
  121085. /**
  121086. * Defines the desired size (the more it increases the longer the generation will be)
  121087. */
  121088. size: number;
  121089. /**
  121090. * Defines if mipmaps should not be generated (default is false)
  121091. */
  121092. noMipmap: boolean;
  121093. /**
  121094. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121095. * but the standard material would require them in Gamma space) (default is true)
  121096. */
  121097. gammaSpace: boolean;
  121098. /**
  121099. * Gets the loaded texture
  121100. */
  121101. texture: EquiRectangularCubeTexture;
  121102. /**
  121103. * Callback called when the task is successful
  121104. */
  121105. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121106. /**
  121107. * Callback called when the task is successful
  121108. */
  121109. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121110. /**
  121111. * Creates a new EquiRectangularCubeTextureAssetTask object
  121112. * @param name defines the name of the task
  121113. * @param url defines the location of the file to load
  121114. * @param size defines the desired size (the more it increases the longer the generation will be)
  121115. * If the size is omitted this implies you are using a preprocessed cubemap.
  121116. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121117. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121118. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121119. * (default is true)
  121120. */
  121121. constructor(
  121122. /**
  121123. * Defines the name of the task
  121124. */
  121125. name: string,
  121126. /**
  121127. * Defines the location of the file to load
  121128. */
  121129. url: string,
  121130. /**
  121131. * Defines the desired size (the more it increases the longer the generation will be)
  121132. */
  121133. size: number,
  121134. /**
  121135. * Defines if mipmaps should not be generated (default is false)
  121136. */
  121137. noMipmap?: boolean,
  121138. /**
  121139. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121140. * but the standard material would require them in Gamma space) (default is true)
  121141. */
  121142. gammaSpace?: boolean);
  121143. /**
  121144. * Execute the current task
  121145. * @param scene defines the scene where you want your assets to be loaded
  121146. * @param onSuccess is a callback called when the task is successfully executed
  121147. * @param onError is a callback called if an error occurs
  121148. */
  121149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121150. }
  121151. /**
  121152. * This class can be used to easily import assets into a scene
  121153. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121154. */
  121155. export class AssetsManager {
  121156. private _scene;
  121157. private _isLoading;
  121158. protected _tasks: AbstractAssetTask[];
  121159. protected _waitingTasksCount: number;
  121160. protected _totalTasksCount: number;
  121161. /**
  121162. * Callback called when all tasks are processed
  121163. */
  121164. onFinish: (tasks: AbstractAssetTask[]) => void;
  121165. /**
  121166. * Callback called when a task is successful
  121167. */
  121168. onTaskSuccess: (task: AbstractAssetTask) => void;
  121169. /**
  121170. * Callback called when a task had an error
  121171. */
  121172. onTaskError: (task: AbstractAssetTask) => void;
  121173. /**
  121174. * Callback called when a task is done (whatever the result is)
  121175. */
  121176. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121177. /**
  121178. * Observable called when all tasks are processed
  121179. */
  121180. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121181. /**
  121182. * Observable called when a task had an error
  121183. */
  121184. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121185. /**
  121186. * Observable called when all tasks were executed
  121187. */
  121188. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121189. /**
  121190. * Observable called when a task is done (whatever the result is)
  121191. */
  121192. onProgressObservable: Observable<IAssetsProgressEvent>;
  121193. /**
  121194. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121196. */
  121197. useDefaultLoadingScreen: boolean;
  121198. /**
  121199. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121200. * when all assets have been downloaded.
  121201. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121202. */
  121203. autoHideLoadingUI: boolean;
  121204. /**
  121205. * Creates a new AssetsManager
  121206. * @param scene defines the scene to work on
  121207. */
  121208. constructor(scene: Scene);
  121209. /**
  121210. * Add a MeshAssetTask to the list of active tasks
  121211. * @param taskName defines the name of the new task
  121212. * @param meshesNames defines the name of meshes to load
  121213. * @param rootUrl defines the root url to use to locate files
  121214. * @param sceneFilename defines the filename of the scene file
  121215. * @returns a new MeshAssetTask object
  121216. */
  121217. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121218. /**
  121219. * Add a TextFileAssetTask to the list of active tasks
  121220. * @param taskName defines the name of the new task
  121221. * @param url defines the url of the file to load
  121222. * @returns a new TextFileAssetTask object
  121223. */
  121224. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121225. /**
  121226. * Add a BinaryFileAssetTask to the list of active tasks
  121227. * @param taskName defines the name of the new task
  121228. * @param url defines the url of the file to load
  121229. * @returns a new BinaryFileAssetTask object
  121230. */
  121231. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121232. /**
  121233. * Add a ImageAssetTask to the list of active tasks
  121234. * @param taskName defines the name of the new task
  121235. * @param url defines the url of the file to load
  121236. * @returns a new ImageAssetTask object
  121237. */
  121238. addImageTask(taskName: string, url: string): ImageAssetTask;
  121239. /**
  121240. * Add a TextureAssetTask to the list of active tasks
  121241. * @param taskName defines the name of the new task
  121242. * @param url defines the url of the file to load
  121243. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121244. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121245. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121246. * @returns a new TextureAssetTask object
  121247. */
  121248. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121249. /**
  121250. * Add a CubeTextureAssetTask to the list of active tasks
  121251. * @param taskName defines the name of the new task
  121252. * @param url defines the url of the file to load
  121253. * @param extensions defines the extension to use to load the cube map (can be null)
  121254. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121255. * @param files defines the list of files to load (can be null)
  121256. * @returns a new CubeTextureAssetTask object
  121257. */
  121258. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121259. /**
  121260. *
  121261. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121262. * @param taskName defines the name of the new task
  121263. * @param url defines the url of the file to load
  121264. * @param size defines the size you want for the cubemap (can be null)
  121265. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121266. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121267. * @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)
  121268. * @param reserved Internal use only
  121269. * @returns a new HDRCubeTextureAssetTask object
  121270. */
  121271. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121272. /**
  121273. *
  121274. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121275. * @param taskName defines the name of the new task
  121276. * @param url defines the url of the file to load
  121277. * @param size defines the size you want for the cubemap (can be null)
  121278. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121279. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121280. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121281. * @returns a new EquiRectangularCubeTextureAssetTask object
  121282. */
  121283. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121284. /**
  121285. * Remove a task from the assets manager.
  121286. * @param task the task to remove
  121287. */
  121288. removeTask(task: AbstractAssetTask): void;
  121289. private _decreaseWaitingTasksCount;
  121290. private _runTask;
  121291. /**
  121292. * Reset the AssetsManager and remove all tasks
  121293. * @return the current instance of the AssetsManager
  121294. */
  121295. reset(): AssetsManager;
  121296. /**
  121297. * Start the loading process
  121298. * @return the current instance of the AssetsManager
  121299. */
  121300. load(): AssetsManager;
  121301. /**
  121302. * Start the loading process as an async operation
  121303. * @return a promise returning the list of failed tasks
  121304. */
  121305. loadAsync(): Promise<void>;
  121306. }
  121307. }
  121308. declare module BABYLON {
  121309. /**
  121310. * Wrapper class for promise with external resolve and reject.
  121311. */
  121312. export class Deferred<T> {
  121313. /**
  121314. * The promise associated with this deferred object.
  121315. */
  121316. readonly promise: Promise<T>;
  121317. private _resolve;
  121318. private _reject;
  121319. /**
  121320. * The resolve method of the promise associated with this deferred object.
  121321. */
  121322. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121323. /**
  121324. * The reject method of the promise associated with this deferred object.
  121325. */
  121326. readonly reject: (reason?: any) => void;
  121327. /**
  121328. * Constructor for this deferred object.
  121329. */
  121330. constructor();
  121331. }
  121332. }
  121333. declare module BABYLON {
  121334. /**
  121335. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121336. */
  121337. export class MeshExploder {
  121338. private _centerMesh;
  121339. private _meshes;
  121340. private _meshesOrigins;
  121341. private _toCenterVectors;
  121342. private _scaledDirection;
  121343. private _newPosition;
  121344. private _centerPosition;
  121345. /**
  121346. * Explodes meshes from a center mesh.
  121347. * @param meshes The meshes to explode.
  121348. * @param centerMesh The mesh to be center of explosion.
  121349. */
  121350. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121351. private _setCenterMesh;
  121352. /**
  121353. * Get class name
  121354. * @returns "MeshExploder"
  121355. */
  121356. getClassName(): string;
  121357. /**
  121358. * "Exploded meshes"
  121359. * @returns Array of meshes with the centerMesh at index 0.
  121360. */
  121361. getMeshes(): Array<Mesh>;
  121362. /**
  121363. * Explodes meshes giving a specific direction
  121364. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121365. */
  121366. explode(direction?: number): void;
  121367. }
  121368. }
  121369. declare module BABYLON {
  121370. /**
  121371. * Class used to help managing file picking and drag'n'drop
  121372. */
  121373. export class FilesInput {
  121374. /**
  121375. * List of files ready to be loaded
  121376. */
  121377. static readonly FilesToLoad: {
  121378. [key: string]: File;
  121379. };
  121380. /**
  121381. * Callback called when a file is processed
  121382. */
  121383. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121384. private _engine;
  121385. private _currentScene;
  121386. private _sceneLoadedCallback;
  121387. private _progressCallback;
  121388. private _additionalRenderLoopLogicCallback;
  121389. private _textureLoadingCallback;
  121390. private _startingProcessingFilesCallback;
  121391. private _onReloadCallback;
  121392. private _errorCallback;
  121393. private _elementToMonitor;
  121394. private _sceneFileToLoad;
  121395. private _filesToLoad;
  121396. /**
  121397. * Creates a new FilesInput
  121398. * @param engine defines the rendering engine
  121399. * @param scene defines the hosting scene
  121400. * @param sceneLoadedCallback callback called when scene is loaded
  121401. * @param progressCallback callback called to track progress
  121402. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121403. * @param textureLoadingCallback callback called when a texture is loading
  121404. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121405. * @param onReloadCallback callback called when a reload is requested
  121406. * @param errorCallback callback call if an error occurs
  121407. */
  121408. 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);
  121409. private _dragEnterHandler;
  121410. private _dragOverHandler;
  121411. private _dropHandler;
  121412. /**
  121413. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121414. * @param elementToMonitor defines the DOM element to track
  121415. */
  121416. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121417. /**
  121418. * Release all associated resources
  121419. */
  121420. dispose(): void;
  121421. private renderFunction;
  121422. private drag;
  121423. private drop;
  121424. private _traverseFolder;
  121425. private _processFiles;
  121426. /**
  121427. * Load files from a drop event
  121428. * @param event defines the drop event to use as source
  121429. */
  121430. loadFiles(event: any): void;
  121431. private _processReload;
  121432. /**
  121433. * Reload the current scene from the loaded files
  121434. */
  121435. reload(): void;
  121436. }
  121437. }
  121438. declare module BABYLON {
  121439. /**
  121440. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121442. */
  121443. export class SceneOptimization {
  121444. /**
  121445. * Defines the priority of this optimization (0 by default which means first in the list)
  121446. */
  121447. priority: number;
  121448. /**
  121449. * Gets a string describing the action executed by the current optimization
  121450. * @returns description string
  121451. */
  121452. getDescription(): string;
  121453. /**
  121454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121455. * @param scene defines the current scene where to apply this optimization
  121456. * @param optimizer defines the current optimizer
  121457. * @returns true if everything that can be done was applied
  121458. */
  121459. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121460. /**
  121461. * Creates the SceneOptimization object
  121462. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121463. * @param desc defines the description associated with the optimization
  121464. */
  121465. constructor(
  121466. /**
  121467. * Defines the priority of this optimization (0 by default which means first in the list)
  121468. */
  121469. priority?: number);
  121470. }
  121471. /**
  121472. * Defines an optimization used to reduce the size of render target textures
  121473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121474. */
  121475. export class TextureOptimization extends SceneOptimization {
  121476. /**
  121477. * Defines the priority of this optimization (0 by default which means first in the list)
  121478. */
  121479. priority: number;
  121480. /**
  121481. * 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
  121482. */
  121483. maximumSize: number;
  121484. /**
  121485. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121486. */
  121487. step: number;
  121488. /**
  121489. * Gets a string describing the action executed by the current optimization
  121490. * @returns description string
  121491. */
  121492. getDescription(): string;
  121493. /**
  121494. * Creates the TextureOptimization object
  121495. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121496. * @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
  121497. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121498. */
  121499. constructor(
  121500. /**
  121501. * Defines the priority of this optimization (0 by default which means first in the list)
  121502. */
  121503. priority?: number,
  121504. /**
  121505. * 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
  121506. */
  121507. maximumSize?: number,
  121508. /**
  121509. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121510. */
  121511. step?: number);
  121512. /**
  121513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121514. * @param scene defines the current scene where to apply this optimization
  121515. * @param optimizer defines the current optimizer
  121516. * @returns true if everything that can be done was applied
  121517. */
  121518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121519. }
  121520. /**
  121521. * Defines an optimization used to increase or decrease the rendering resolution
  121522. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121523. */
  121524. export class HardwareScalingOptimization extends SceneOptimization {
  121525. /**
  121526. * Defines the priority of this optimization (0 by default which means first in the list)
  121527. */
  121528. priority: number;
  121529. /**
  121530. * Defines the maximum scale to use (2 by default)
  121531. */
  121532. maximumScale: number;
  121533. /**
  121534. * Defines the step to use between two passes (0.5 by default)
  121535. */
  121536. step: number;
  121537. private _currentScale;
  121538. private _directionOffset;
  121539. /**
  121540. * Gets a string describing the action executed by the current optimization
  121541. * @return description string
  121542. */
  121543. getDescription(): string;
  121544. /**
  121545. * Creates the HardwareScalingOptimization object
  121546. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121547. * @param maximumScale defines the maximum scale to use (2 by default)
  121548. * @param step defines the step to use between two passes (0.5 by default)
  121549. */
  121550. constructor(
  121551. /**
  121552. * Defines the priority of this optimization (0 by default which means first in the list)
  121553. */
  121554. priority?: number,
  121555. /**
  121556. * Defines the maximum scale to use (2 by default)
  121557. */
  121558. maximumScale?: number,
  121559. /**
  121560. * Defines the step to use between two passes (0.5 by default)
  121561. */
  121562. step?: number);
  121563. /**
  121564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121565. * @param scene defines the current scene where to apply this optimization
  121566. * @param optimizer defines the current optimizer
  121567. * @returns true if everything that can be done was applied
  121568. */
  121569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121570. }
  121571. /**
  121572. * Defines an optimization used to remove shadows
  121573. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121574. */
  121575. export class ShadowsOptimization extends SceneOptimization {
  121576. /**
  121577. * Gets a string describing the action executed by the current optimization
  121578. * @return description string
  121579. */
  121580. getDescription(): string;
  121581. /**
  121582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121583. * @param scene defines the current scene where to apply this optimization
  121584. * @param optimizer defines the current optimizer
  121585. * @returns true if everything that can be done was applied
  121586. */
  121587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121588. }
  121589. /**
  121590. * Defines an optimization used to turn post-processes off
  121591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121592. */
  121593. export class PostProcessesOptimization extends SceneOptimization {
  121594. /**
  121595. * Gets a string describing the action executed by the current optimization
  121596. * @return description string
  121597. */
  121598. getDescription(): string;
  121599. /**
  121600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121601. * @param scene defines the current scene where to apply this optimization
  121602. * @param optimizer defines the current optimizer
  121603. * @returns true if everything that can be done was applied
  121604. */
  121605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121606. }
  121607. /**
  121608. * Defines an optimization used to turn lens flares off
  121609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121610. */
  121611. export class LensFlaresOptimization extends SceneOptimization {
  121612. /**
  121613. * Gets a string describing the action executed by the current optimization
  121614. * @return description string
  121615. */
  121616. getDescription(): string;
  121617. /**
  121618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121619. * @param scene defines the current scene where to apply this optimization
  121620. * @param optimizer defines the current optimizer
  121621. * @returns true if everything that can be done was applied
  121622. */
  121623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121624. }
  121625. /**
  121626. * Defines an optimization based on user defined callback.
  121627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121628. */
  121629. export class CustomOptimization extends SceneOptimization {
  121630. /**
  121631. * Callback called to apply the custom optimization.
  121632. */
  121633. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121634. /**
  121635. * Callback called to get custom description
  121636. */
  121637. onGetDescription: () => string;
  121638. /**
  121639. * Gets a string describing the action executed by the current optimization
  121640. * @returns description string
  121641. */
  121642. getDescription(): string;
  121643. /**
  121644. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121645. * @param scene defines the current scene where to apply this optimization
  121646. * @param optimizer defines the current optimizer
  121647. * @returns true if everything that can be done was applied
  121648. */
  121649. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121650. }
  121651. /**
  121652. * Defines an optimization used to turn particles off
  121653. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121654. */
  121655. export class ParticlesOptimization extends SceneOptimization {
  121656. /**
  121657. * Gets a string describing the action executed by the current optimization
  121658. * @return description string
  121659. */
  121660. getDescription(): string;
  121661. /**
  121662. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121663. * @param scene defines the current scene where to apply this optimization
  121664. * @param optimizer defines the current optimizer
  121665. * @returns true if everything that can be done was applied
  121666. */
  121667. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121668. }
  121669. /**
  121670. * Defines an optimization used to turn render targets off
  121671. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121672. */
  121673. export class RenderTargetsOptimization extends SceneOptimization {
  121674. /**
  121675. * Gets a string describing the action executed by the current optimization
  121676. * @return description string
  121677. */
  121678. getDescription(): string;
  121679. /**
  121680. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121681. * @param scene defines the current scene where to apply this optimization
  121682. * @param optimizer defines the current optimizer
  121683. * @returns true if everything that can be done was applied
  121684. */
  121685. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121686. }
  121687. /**
  121688. * Defines an optimization used to merge meshes with compatible materials
  121689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121690. */
  121691. export class MergeMeshesOptimization extends SceneOptimization {
  121692. private static _UpdateSelectionTree;
  121693. /**
  121694. * Gets or sets a boolean which defines if optimization octree has to be updated
  121695. */
  121696. /**
  121697. * Gets or sets a boolean which defines if optimization octree has to be updated
  121698. */
  121699. static UpdateSelectionTree: boolean;
  121700. /**
  121701. * Gets a string describing the action executed by the current optimization
  121702. * @return description string
  121703. */
  121704. getDescription(): string;
  121705. private _canBeMerged;
  121706. /**
  121707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121708. * @param scene defines the current scene where to apply this optimization
  121709. * @param optimizer defines the current optimizer
  121710. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121711. * @returns true if everything that can be done was applied
  121712. */
  121713. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121714. }
  121715. /**
  121716. * Defines a list of options used by SceneOptimizer
  121717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121718. */
  121719. export class SceneOptimizerOptions {
  121720. /**
  121721. * Defines the target frame rate to reach (60 by default)
  121722. */
  121723. targetFrameRate: number;
  121724. /**
  121725. * Defines the interval between two checkes (2000ms by default)
  121726. */
  121727. trackerDuration: number;
  121728. /**
  121729. * Gets the list of optimizations to apply
  121730. */
  121731. optimizations: SceneOptimization[];
  121732. /**
  121733. * Creates a new list of options used by SceneOptimizer
  121734. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121735. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121736. */
  121737. constructor(
  121738. /**
  121739. * Defines the target frame rate to reach (60 by default)
  121740. */
  121741. targetFrameRate?: number,
  121742. /**
  121743. * Defines the interval between two checkes (2000ms by default)
  121744. */
  121745. trackerDuration?: number);
  121746. /**
  121747. * Add a new optimization
  121748. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121749. * @returns the current SceneOptimizerOptions
  121750. */
  121751. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121752. /**
  121753. * Add a new custom optimization
  121754. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121755. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121756. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121757. * @returns the current SceneOptimizerOptions
  121758. */
  121759. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121760. /**
  121761. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121762. * @param targetFrameRate defines the target frame rate (60 by default)
  121763. * @returns a SceneOptimizerOptions object
  121764. */
  121765. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121766. /**
  121767. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121768. * @param targetFrameRate defines the target frame rate (60 by default)
  121769. * @returns a SceneOptimizerOptions object
  121770. */
  121771. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121772. /**
  121773. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121774. * @param targetFrameRate defines the target frame rate (60 by default)
  121775. * @returns a SceneOptimizerOptions object
  121776. */
  121777. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121778. }
  121779. /**
  121780. * Class used to run optimizations in order to reach a target frame rate
  121781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121782. */
  121783. export class SceneOptimizer implements IDisposable {
  121784. private _isRunning;
  121785. private _options;
  121786. private _scene;
  121787. private _currentPriorityLevel;
  121788. private _targetFrameRate;
  121789. private _trackerDuration;
  121790. private _currentFrameRate;
  121791. private _sceneDisposeObserver;
  121792. private _improvementMode;
  121793. /**
  121794. * Defines an observable called when the optimizer reaches the target frame rate
  121795. */
  121796. onSuccessObservable: Observable<SceneOptimizer>;
  121797. /**
  121798. * Defines an observable called when the optimizer enables an optimization
  121799. */
  121800. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121801. /**
  121802. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121803. */
  121804. onFailureObservable: Observable<SceneOptimizer>;
  121805. /**
  121806. * Gets a boolean indicating if the optimizer is in improvement mode
  121807. */
  121808. readonly isInImprovementMode: boolean;
  121809. /**
  121810. * Gets the current priority level (0 at start)
  121811. */
  121812. readonly currentPriorityLevel: number;
  121813. /**
  121814. * Gets the current frame rate checked by the SceneOptimizer
  121815. */
  121816. readonly currentFrameRate: number;
  121817. /**
  121818. * Gets or sets the current target frame rate (60 by default)
  121819. */
  121820. /**
  121821. * Gets or sets the current target frame rate (60 by default)
  121822. */
  121823. targetFrameRate: number;
  121824. /**
  121825. * Gets or sets the current interval between two checks (every 2000ms by default)
  121826. */
  121827. /**
  121828. * Gets or sets the current interval between two checks (every 2000ms by default)
  121829. */
  121830. trackerDuration: number;
  121831. /**
  121832. * Gets the list of active optimizations
  121833. */
  121834. readonly optimizations: SceneOptimization[];
  121835. /**
  121836. * Creates a new SceneOptimizer
  121837. * @param scene defines the scene to work on
  121838. * @param options defines the options to use with the SceneOptimizer
  121839. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121840. * @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)
  121841. */
  121842. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121843. /**
  121844. * Stops the current optimizer
  121845. */
  121846. stop(): void;
  121847. /**
  121848. * Reset the optimizer to initial step (current priority level = 0)
  121849. */
  121850. reset(): void;
  121851. /**
  121852. * Start the optimizer. By default it will try to reach a specific framerate
  121853. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121854. */
  121855. start(): void;
  121856. private _checkCurrentState;
  121857. /**
  121858. * Release all resources
  121859. */
  121860. dispose(): void;
  121861. /**
  121862. * Helper function to create a SceneOptimizer with one single line of code
  121863. * @param scene defines the scene to work on
  121864. * @param options defines the options to use with the SceneOptimizer
  121865. * @param onSuccess defines a callback to call on success
  121866. * @param onFailure defines a callback to call on failure
  121867. * @returns the new SceneOptimizer object
  121868. */
  121869. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121870. }
  121871. }
  121872. declare module BABYLON {
  121873. /**
  121874. * Class used to serialize a scene into a string
  121875. */
  121876. export class SceneSerializer {
  121877. /**
  121878. * Clear cache used by a previous serialization
  121879. */
  121880. static ClearCache(): void;
  121881. /**
  121882. * Serialize a scene into a JSON compatible object
  121883. * @param scene defines the scene to serialize
  121884. * @returns a JSON compatible object
  121885. */
  121886. static Serialize(scene: Scene): any;
  121887. /**
  121888. * Serialize a mesh into a JSON compatible object
  121889. * @param toSerialize defines the mesh to serialize
  121890. * @param withParents defines if parents must be serialized as well
  121891. * @param withChildren defines if children must be serialized as well
  121892. * @returns a JSON compatible object
  121893. */
  121894. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121895. }
  121896. }
  121897. declare module BABYLON {
  121898. /**
  121899. * Class used to host texture specific utilities
  121900. */
  121901. export class TextureTools {
  121902. /**
  121903. * Uses the GPU to create a copy texture rescaled at a given size
  121904. * @param texture Texture to copy from
  121905. * @param width defines the desired width
  121906. * @param height defines the desired height
  121907. * @param useBilinearMode defines if bilinear mode has to be used
  121908. * @return the generated texture
  121909. */
  121910. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121911. }
  121912. }
  121913. declare module BABYLON {
  121914. /**
  121915. * This represents the different options available for the video capture.
  121916. */
  121917. export interface VideoRecorderOptions {
  121918. /** Defines the mime type of the video. */
  121919. mimeType: string;
  121920. /** Defines the FPS the video should be recorded at. */
  121921. fps: number;
  121922. /** Defines the chunk size for the recording data. */
  121923. recordChunckSize: number;
  121924. /** The audio tracks to attach to the recording. */
  121925. audioTracks?: MediaStreamTrack[];
  121926. }
  121927. /**
  121928. * This can help with recording videos from BabylonJS.
  121929. * This is based on the available WebRTC functionalities of the browser.
  121930. *
  121931. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121932. */
  121933. export class VideoRecorder {
  121934. private static readonly _defaultOptions;
  121935. /**
  121936. * Returns whether or not the VideoRecorder is available in your browser.
  121937. * @param engine Defines the Babylon Engine.
  121938. * @returns true if supported otherwise false.
  121939. */
  121940. static IsSupported(engine: Engine): boolean;
  121941. private readonly _options;
  121942. private _canvas;
  121943. private _mediaRecorder;
  121944. private _recordedChunks;
  121945. private _fileName;
  121946. private _resolve;
  121947. private _reject;
  121948. /**
  121949. * True when a recording is already in progress.
  121950. */
  121951. readonly isRecording: boolean;
  121952. /**
  121953. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121954. * @param engine Defines the BabylonJS Engine you wish to record.
  121955. * @param options Defines options that can be used to customize the capture.
  121956. */
  121957. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121958. /**
  121959. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121960. */
  121961. stopRecording(): void;
  121962. /**
  121963. * Starts recording the canvas for a max duration specified in parameters.
  121964. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121965. * If null no automatic download will start and you can rely on the promise to get the data back.
  121966. * @param maxDuration Defines the maximum recording time in seconds.
  121967. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121968. * @return A promise callback at the end of the recording with the video data in Blob.
  121969. */
  121970. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121971. /**
  121972. * Releases internal resources used during the recording.
  121973. */
  121974. dispose(): void;
  121975. private _handleDataAvailable;
  121976. private _handleError;
  121977. private _handleStop;
  121978. }
  121979. }
  121980. declare module BABYLON {
  121981. /**
  121982. * Class containing a set of static utilities functions for screenshots
  121983. */
  121984. export class ScreenshotTools {
  121985. /**
  121986. * Captures a screenshot of the current rendering
  121987. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121988. * @param engine defines the rendering engine
  121989. * @param camera defines the source camera
  121990. * @param size This parameter can be set to a single number or to an object with the
  121991. * following (optional) properties: precision, width, height. If a single number is passed,
  121992. * it will be used for both width and height. If an object is passed, the screenshot size
  121993. * will be derived from the parameters. The precision property is a multiplier allowing
  121994. * rendering at a higher or lower resolution
  121995. * @param successCallback defines the callback receives a single parameter which contains the
  121996. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121997. * src parameter of an <img> to display it
  121998. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121999. * Check your browser for supported MIME types
  122000. */
  122001. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122002. /**
  122003. * Generates an image screenshot from the specified camera.
  122004. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122005. * @param engine The engine to use for rendering
  122006. * @param camera The camera to use for rendering
  122007. * @param size This parameter can be set to a single number or to an object with the
  122008. * following (optional) properties: precision, width, height. If a single number is passed,
  122009. * it will be used for both width and height. If an object is passed, the screenshot size
  122010. * will be derived from the parameters. The precision property is a multiplier allowing
  122011. * rendering at a higher or lower resolution
  122012. * @param successCallback The callback receives a single parameter which contains the
  122013. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122014. * src parameter of an <img> to display it
  122015. * @param mimeType The MIME type of the screenshot image (default: image/png).
  122016. * Check your browser for supported MIME types
  122017. * @param samples Texture samples (default: 1)
  122018. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  122019. * @param fileName A name for for the downloaded file.
  122020. */
  122021. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  122022. }
  122023. }
  122024. declare module BABYLON {
  122025. /**
  122026. * A cursor which tracks a point on a path
  122027. */
  122028. export class PathCursor {
  122029. private path;
  122030. /**
  122031. * Stores path cursor callbacks for when an onchange event is triggered
  122032. */
  122033. private _onchange;
  122034. /**
  122035. * The value of the path cursor
  122036. */
  122037. value: number;
  122038. /**
  122039. * The animation array of the path cursor
  122040. */
  122041. animations: Animation[];
  122042. /**
  122043. * Initializes the path cursor
  122044. * @param path The path to track
  122045. */
  122046. constructor(path: Path2);
  122047. /**
  122048. * Gets the cursor point on the path
  122049. * @returns A point on the path cursor at the cursor location
  122050. */
  122051. getPoint(): Vector3;
  122052. /**
  122053. * Moves the cursor ahead by the step amount
  122054. * @param step The amount to move the cursor forward
  122055. * @returns This path cursor
  122056. */
  122057. moveAhead(step?: number): PathCursor;
  122058. /**
  122059. * Moves the cursor behind by the step amount
  122060. * @param step The amount to move the cursor back
  122061. * @returns This path cursor
  122062. */
  122063. moveBack(step?: number): PathCursor;
  122064. /**
  122065. * Moves the cursor by the step amount
  122066. * If the step amount is greater than one, an exception is thrown
  122067. * @param step The amount to move the cursor
  122068. * @returns This path cursor
  122069. */
  122070. move(step: number): PathCursor;
  122071. /**
  122072. * Ensures that the value is limited between zero and one
  122073. * @returns This path cursor
  122074. */
  122075. private ensureLimits;
  122076. /**
  122077. * Runs onchange callbacks on change (used by the animation engine)
  122078. * @returns This path cursor
  122079. */
  122080. private raiseOnChange;
  122081. /**
  122082. * Executes a function on change
  122083. * @param f A path cursor onchange callback
  122084. * @returns This path cursor
  122085. */
  122086. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122087. }
  122088. }
  122089. declare module BABYLON {
  122090. /** @hidden */
  122091. export var blurPixelShader: {
  122092. name: string;
  122093. shader: string;
  122094. };
  122095. }
  122096. declare module BABYLON {
  122097. /** @hidden */
  122098. export var pointCloudVertexDeclaration: {
  122099. name: string;
  122100. shader: string;
  122101. };
  122102. }
  122103. // Mixins
  122104. interface Window {
  122105. mozIndexedDB: IDBFactory;
  122106. webkitIndexedDB: IDBFactory;
  122107. msIndexedDB: IDBFactory;
  122108. webkitURL: typeof URL;
  122109. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122110. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122111. WebGLRenderingContext: WebGLRenderingContext;
  122112. MSGesture: MSGesture;
  122113. CANNON: any;
  122114. AudioContext: AudioContext;
  122115. webkitAudioContext: AudioContext;
  122116. PointerEvent: any;
  122117. Math: Math;
  122118. Uint8Array: Uint8ArrayConstructor;
  122119. Float32Array: Float32ArrayConstructor;
  122120. mozURL: typeof URL;
  122121. msURL: typeof URL;
  122122. VRFrameData: any; // WebVR, from specs 1.1
  122123. DracoDecoderModule: any;
  122124. setImmediate(handler: (...args: any[]) => void): number;
  122125. }
  122126. interface HTMLCanvasElement {
  122127. requestPointerLock(): void;
  122128. msRequestPointerLock?(): void;
  122129. mozRequestPointerLock?(): void;
  122130. webkitRequestPointerLock?(): void;
  122131. /** Track wether a record is in progress */
  122132. isRecording: boolean;
  122133. /** Capture Stream method defined by some browsers */
  122134. captureStream(fps?: number): MediaStream;
  122135. }
  122136. interface CanvasRenderingContext2D {
  122137. msImageSmoothingEnabled: boolean;
  122138. }
  122139. interface MouseEvent {
  122140. mozMovementX: number;
  122141. mozMovementY: number;
  122142. webkitMovementX: number;
  122143. webkitMovementY: number;
  122144. msMovementX: number;
  122145. msMovementY: number;
  122146. }
  122147. interface Navigator {
  122148. mozGetVRDevices: (any: any) => any;
  122149. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122150. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122151. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122152. webkitGetGamepads(): Gamepad[];
  122153. msGetGamepads(): Gamepad[];
  122154. webkitGamepads(): Gamepad[];
  122155. }
  122156. interface HTMLVideoElement {
  122157. mozSrcObject: any;
  122158. }
  122159. interface Math {
  122160. fround(x: number): number;
  122161. imul(a: number, b: number): number;
  122162. }
  122163. interface WebGLRenderingContext {
  122164. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122165. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122166. vertexAttribDivisor(index: number, divisor: number): void;
  122167. createVertexArray(): any;
  122168. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122169. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122170. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122171. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122172. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122173. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122174. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122175. // Queries
  122176. createQuery(): WebGLQuery;
  122177. deleteQuery(query: WebGLQuery): void;
  122178. beginQuery(target: number, query: WebGLQuery): void;
  122179. endQuery(target: number): void;
  122180. getQueryParameter(query: WebGLQuery, pname: number): any;
  122181. getQuery(target: number, pname: number): any;
  122182. MAX_SAMPLES: number;
  122183. RGBA8: number;
  122184. READ_FRAMEBUFFER: number;
  122185. DRAW_FRAMEBUFFER: number;
  122186. UNIFORM_BUFFER: number;
  122187. HALF_FLOAT_OES: number;
  122188. RGBA16F: number;
  122189. RGBA32F: number;
  122190. R32F: number;
  122191. RG32F: number;
  122192. RGB32F: number;
  122193. R16F: number;
  122194. RG16F: number;
  122195. RGB16F: number;
  122196. RED: number;
  122197. RG: number;
  122198. R8: number;
  122199. RG8: number;
  122200. UNSIGNED_INT_24_8: number;
  122201. DEPTH24_STENCIL8: number;
  122202. /* Multiple Render Targets */
  122203. drawBuffers(buffers: number[]): void;
  122204. readBuffer(src: number): void;
  122205. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122206. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122207. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122208. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122209. // Occlusion Query
  122210. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122211. ANY_SAMPLES_PASSED: number;
  122212. QUERY_RESULT_AVAILABLE: number;
  122213. QUERY_RESULT: number;
  122214. }
  122215. interface WebGLProgram {
  122216. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122217. }
  122218. interface EXT_disjoint_timer_query {
  122219. QUERY_COUNTER_BITS_EXT: number;
  122220. TIME_ELAPSED_EXT: number;
  122221. TIMESTAMP_EXT: number;
  122222. GPU_DISJOINT_EXT: number;
  122223. QUERY_RESULT_EXT: number;
  122224. QUERY_RESULT_AVAILABLE_EXT: number;
  122225. queryCounterEXT(query: WebGLQuery, target: number): void;
  122226. createQueryEXT(): WebGLQuery;
  122227. beginQueryEXT(target: number, query: WebGLQuery): void;
  122228. endQueryEXT(target: number): void;
  122229. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122230. deleteQueryEXT(query: WebGLQuery): void;
  122231. }
  122232. interface WebGLUniformLocation {
  122233. _currentState: any;
  122234. }
  122235. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122236. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122237. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122238. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122239. interface WebGLRenderingContext {
  122240. readonly RASTERIZER_DISCARD: number;
  122241. readonly DEPTH_COMPONENT24: number;
  122242. readonly TEXTURE_3D: number;
  122243. readonly TEXTURE_2D_ARRAY: number;
  122244. readonly TEXTURE_COMPARE_FUNC: number;
  122245. readonly TEXTURE_COMPARE_MODE: number;
  122246. readonly COMPARE_REF_TO_TEXTURE: number;
  122247. readonly TEXTURE_WRAP_R: number;
  122248. readonly HALF_FLOAT: number;
  122249. readonly RGB8: number;
  122250. readonly RED_INTEGER: number;
  122251. readonly RG_INTEGER: number;
  122252. readonly RGB_INTEGER: number;
  122253. readonly RGBA_INTEGER: number;
  122254. readonly R8_SNORM: number;
  122255. readonly RG8_SNORM: number;
  122256. readonly RGB8_SNORM: number;
  122257. readonly RGBA8_SNORM: number;
  122258. readonly R8I: number;
  122259. readonly RG8I: number;
  122260. readonly RGB8I: number;
  122261. readonly RGBA8I: number;
  122262. readonly R8UI: number;
  122263. readonly RG8UI: number;
  122264. readonly RGB8UI: number;
  122265. readonly RGBA8UI: number;
  122266. readonly R16I: number;
  122267. readonly RG16I: number;
  122268. readonly RGB16I: number;
  122269. readonly RGBA16I: number;
  122270. readonly R16UI: number;
  122271. readonly RG16UI: number;
  122272. readonly RGB16UI: number;
  122273. readonly RGBA16UI: number;
  122274. readonly R32I: number;
  122275. readonly RG32I: number;
  122276. readonly RGB32I: number;
  122277. readonly RGBA32I: number;
  122278. readonly R32UI: number;
  122279. readonly RG32UI: number;
  122280. readonly RGB32UI: number;
  122281. readonly RGBA32UI: number;
  122282. readonly RGB10_A2UI: number;
  122283. readonly R11F_G11F_B10F: number;
  122284. readonly RGB9_E5: number;
  122285. readonly RGB10_A2: number;
  122286. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122287. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122288. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122289. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122290. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122291. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122292. 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;
  122293. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122294. readonly TRANSFORM_FEEDBACK: number;
  122295. readonly INTERLEAVED_ATTRIBS: number;
  122296. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122297. createTransformFeedback(): WebGLTransformFeedback;
  122298. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122299. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122300. beginTransformFeedback(primitiveMode: number): void;
  122301. endTransformFeedback(): void;
  122302. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122303. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122304. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122305. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122306. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122307. }
  122308. interface ImageBitmap {
  122309. readonly width: number;
  122310. readonly height: number;
  122311. close(): void;
  122312. }
  122313. interface WebGLQuery extends WebGLObject {
  122314. }
  122315. declare var WebGLQuery: {
  122316. prototype: WebGLQuery;
  122317. new(): WebGLQuery;
  122318. };
  122319. interface WebGLSampler extends WebGLObject {
  122320. }
  122321. declare var WebGLSampler: {
  122322. prototype: WebGLSampler;
  122323. new(): WebGLSampler;
  122324. };
  122325. interface WebGLSync extends WebGLObject {
  122326. }
  122327. declare var WebGLSync: {
  122328. prototype: WebGLSync;
  122329. new(): WebGLSync;
  122330. };
  122331. interface WebGLTransformFeedback extends WebGLObject {
  122332. }
  122333. declare var WebGLTransformFeedback: {
  122334. prototype: WebGLTransformFeedback;
  122335. new(): WebGLTransformFeedback;
  122336. };
  122337. interface WebGLVertexArrayObject extends WebGLObject {
  122338. }
  122339. declare var WebGLVertexArrayObject: {
  122340. prototype: WebGLVertexArrayObject;
  122341. new(): WebGLVertexArrayObject;
  122342. };
  122343. // Type definitions for WebVR API
  122344. // Project: https://w3c.github.io/webvr/
  122345. // Definitions by: six a <https://github.com/lostfictions>
  122346. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122347. interface VRDisplay extends EventTarget {
  122348. /**
  122349. * Dictionary of capabilities describing the VRDisplay.
  122350. */
  122351. readonly capabilities: VRDisplayCapabilities;
  122352. /**
  122353. * z-depth defining the far plane of the eye view frustum
  122354. * enables mapping of values in the render target depth
  122355. * attachment to scene coordinates. Initially set to 10000.0.
  122356. */
  122357. depthFar: number;
  122358. /**
  122359. * z-depth defining the near plane of the eye view frustum
  122360. * enables mapping of values in the render target depth
  122361. * attachment to scene coordinates. Initially set to 0.01.
  122362. */
  122363. depthNear: number;
  122364. /**
  122365. * An identifier for this distinct VRDisplay. Used as an
  122366. * association point in the Gamepad API.
  122367. */
  122368. readonly displayId: number;
  122369. /**
  122370. * A display name, a user-readable name identifying it.
  122371. */
  122372. readonly displayName: string;
  122373. readonly isConnected: boolean;
  122374. readonly isPresenting: boolean;
  122375. /**
  122376. * If this VRDisplay supports room-scale experiences, the optional
  122377. * stage attribute contains details on the room-scale parameters.
  122378. */
  122379. readonly stageParameters: VRStageParameters | null;
  122380. /**
  122381. * Passing the value returned by `requestAnimationFrame` to
  122382. * `cancelAnimationFrame` will unregister the callback.
  122383. * @param handle Define the hanle of the request to cancel
  122384. */
  122385. cancelAnimationFrame(handle: number): void;
  122386. /**
  122387. * Stops presenting to the VRDisplay.
  122388. * @returns a promise to know when it stopped
  122389. */
  122390. exitPresent(): Promise<void>;
  122391. /**
  122392. * Return the current VREyeParameters for the given eye.
  122393. * @param whichEye Define the eye we want the parameter for
  122394. * @returns the eye parameters
  122395. */
  122396. getEyeParameters(whichEye: string): VREyeParameters;
  122397. /**
  122398. * Populates the passed VRFrameData with the information required to render
  122399. * the current frame.
  122400. * @param frameData Define the data structure to populate
  122401. * @returns true if ok otherwise false
  122402. */
  122403. getFrameData(frameData: VRFrameData): boolean;
  122404. /**
  122405. * Get the layers currently being presented.
  122406. * @returns the list of VR layers
  122407. */
  122408. getLayers(): VRLayer[];
  122409. /**
  122410. * Return a VRPose containing the future predicted pose of the VRDisplay
  122411. * when the current frame will be presented. The value returned will not
  122412. * change until JavaScript has returned control to the browser.
  122413. *
  122414. * The VRPose will contain the position, orientation, velocity,
  122415. * and acceleration of each of these properties.
  122416. * @returns the pose object
  122417. */
  122418. getPose(): VRPose;
  122419. /**
  122420. * Return the current instantaneous pose of the VRDisplay, with no
  122421. * prediction applied.
  122422. * @returns the current instantaneous pose
  122423. */
  122424. getImmediatePose(): VRPose;
  122425. /**
  122426. * The callback passed to `requestAnimationFrame` will be called
  122427. * any time a new frame should be rendered. When the VRDisplay is
  122428. * presenting the callback will be called at the native refresh
  122429. * rate of the HMD. When not presenting this function acts
  122430. * identically to how window.requestAnimationFrame acts. Content should
  122431. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122432. * asynchronously from other displays and at differing refresh rates.
  122433. * @param callback Define the eaction to run next frame
  122434. * @returns the request handle it
  122435. */
  122436. requestAnimationFrame(callback: FrameRequestCallback): number;
  122437. /**
  122438. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122439. * Repeat calls while already presenting will update the VRLayers being displayed.
  122440. * @param layers Define the list of layer to present
  122441. * @returns a promise to know when the request has been fulfilled
  122442. */
  122443. requestPresent(layers: VRLayer[]): Promise<void>;
  122444. /**
  122445. * Reset the pose for this display, treating its current position and
  122446. * orientation as the "origin/zero" values. VRPose.position,
  122447. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122448. * updated when calling resetPose(). This should be called in only
  122449. * sitting-space experiences.
  122450. */
  122451. resetPose(): void;
  122452. /**
  122453. * The VRLayer provided to the VRDisplay will be captured and presented
  122454. * in the HMD. Calling this function has the same effect on the source
  122455. * canvas as any other operation that uses its source image, and canvases
  122456. * created without preserveDrawingBuffer set to true will be cleared.
  122457. * @param pose Define the pose to submit
  122458. */
  122459. submitFrame(pose?: VRPose): void;
  122460. }
  122461. declare var VRDisplay: {
  122462. prototype: VRDisplay;
  122463. new(): VRDisplay;
  122464. };
  122465. interface VRLayer {
  122466. leftBounds?: number[] | Float32Array | null;
  122467. rightBounds?: number[] | Float32Array | null;
  122468. source?: HTMLCanvasElement | null;
  122469. }
  122470. interface VRDisplayCapabilities {
  122471. readonly canPresent: boolean;
  122472. readonly hasExternalDisplay: boolean;
  122473. readonly hasOrientation: boolean;
  122474. readonly hasPosition: boolean;
  122475. readonly maxLayers: number;
  122476. }
  122477. interface VREyeParameters {
  122478. /** @deprecated */
  122479. readonly fieldOfView: VRFieldOfView;
  122480. readonly offset: Float32Array;
  122481. readonly renderHeight: number;
  122482. readonly renderWidth: number;
  122483. }
  122484. interface VRFieldOfView {
  122485. readonly downDegrees: number;
  122486. readonly leftDegrees: number;
  122487. readonly rightDegrees: number;
  122488. readonly upDegrees: number;
  122489. }
  122490. interface VRFrameData {
  122491. readonly leftProjectionMatrix: Float32Array;
  122492. readonly leftViewMatrix: Float32Array;
  122493. readonly pose: VRPose;
  122494. readonly rightProjectionMatrix: Float32Array;
  122495. readonly rightViewMatrix: Float32Array;
  122496. readonly timestamp: number;
  122497. }
  122498. interface VRPose {
  122499. readonly angularAcceleration: Float32Array | null;
  122500. readonly angularVelocity: Float32Array | null;
  122501. readonly linearAcceleration: Float32Array | null;
  122502. readonly linearVelocity: Float32Array | null;
  122503. readonly orientation: Float32Array | null;
  122504. readonly position: Float32Array | null;
  122505. readonly timestamp: number;
  122506. }
  122507. interface VRStageParameters {
  122508. sittingToStandingTransform?: Float32Array;
  122509. sizeX?: number;
  122510. sizeY?: number;
  122511. }
  122512. interface Navigator {
  122513. getVRDisplays(): Promise<VRDisplay[]>;
  122514. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122515. }
  122516. interface Window {
  122517. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122518. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122519. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122520. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122521. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122522. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122523. }
  122524. interface Gamepad {
  122525. readonly displayId: number;
  122526. }
  122527. type XRSessionMode =
  122528. | "inline"
  122529. | "immersive-vr"
  122530. | "immersive-ar";
  122531. type XRReferenceSpaceType =
  122532. | "viewer"
  122533. | "local"
  122534. | "local-floor"
  122535. | "bounded-floor"
  122536. | "unbounded";
  122537. type XREnvironmentBlendMode =
  122538. | "opaque"
  122539. | "additive"
  122540. | "alpha-blend";
  122541. type XRVisibilityState =
  122542. | "visible"
  122543. | "visible-blurred"
  122544. | "hidden";
  122545. type XRHandedness =
  122546. | "none"
  122547. | "left"
  122548. | "right";
  122549. type XRTargetRayMode =
  122550. | "gaze"
  122551. | "tracked-pointer"
  122552. | "screen";
  122553. type XREye =
  122554. | "none"
  122555. | "left"
  122556. | "right";
  122557. interface XRSpace extends EventTarget {
  122558. }
  122559. interface XRRenderState {
  122560. depthNear: number ;
  122561. depthFar: number ;
  122562. inlineVerticalFieldOfView: number | undefined;
  122563. baseLayer: XRWebGLLayer | undefined;
  122564. }
  122565. interface XRInputSource {
  122566. handedness: XRHandedness;
  122567. targetRayMode: XRTargetRayMode;
  122568. targetRaySpace: XRSpace;
  122569. gripSpace: XRSpace | undefined;
  122570. gamepad: Gamepad | undefined;
  122571. profiles: Array<string>;
  122572. }
  122573. interface XRSession {
  122574. addEventListener: Function;
  122575. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122576. updateRenderState(XRRenderStateInit: any): Promise<void>;
  122577. requestAnimationFrame: Function;
  122578. end(): Promise<void>;
  122579. renderState: XRRenderState;
  122580. inputSources: Array<XRInputSource>;
  122581. }
  122582. interface XRReferenceSpace extends XRSpace {
  122583. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  122584. onreset: any;
  122585. }
  122586. interface XRFrame {
  122587. session: XRSession;
  122588. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  122589. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  122590. }
  122591. interface XRViewerPose extends XRPose {
  122592. views: Array<XRView>;
  122593. }
  122594. interface XRPose {
  122595. transform: XRRigidTransform;
  122596. emulatedPosition: boolean;
  122597. }
  122598. declare var XRWebGLLayer: {
  122599. prototype: XRWebGLLayer;
  122600. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  122601. };
  122602. interface XRWebGLLayer {
  122603. framebuffer: WebGLFramebuffer;
  122604. framebufferWidth: number;
  122605. framebufferHeight: number;
  122606. getViewport: Function;
  122607. }
  122608. interface XRRigidTransform {
  122609. position: DOMPointReadOnly;
  122610. orientation: DOMPointReadOnly;
  122611. matrix: Float32Array;
  122612. inverse: XRRigidTransform;
  122613. }
  122614. interface XRView {
  122615. eye: XREye;
  122616. projectionMatrix: Float32Array;
  122617. transform: XRRigidTransform;
  122618. }
  122619. interface XRInputSourceChangeEvent {
  122620. session: XRSession;
  122621. removed: Array<XRInputSource>;
  122622. added: Array<XRInputSource>;
  122623. }